SDL icon indicating copy to clipboard operation
SDL copied to clipboard

HarmonyOS/OpenHarmony Port

Open MetsukiMio opened this issue 6 months ago • 58 comments

Description

SDL support for harmonyos

Existing Issue(s)

#9837

MetsukiMio avatar May 31 '25 07:05 MetsukiMio

@slouken Request for review

MetsukiMio avatar May 31 '25 09:05 MetsukiMio

@madebr @sezero Request for review

MetsukiMio avatar May 31 '25 09:05 MetsukiMio

Can you please rebase on top of current master and remove all commits which you did not author?

git fetch https://github.com/libsdl-org/SDL main
git rebase -i FETCH_HEAD
<remove all commits which you did not author. In vim, "dd" removes the current line, "<ESC>:wq" saves and exits)>
git push [email protected]:Jack253-png/SDL HEAD:OpenMinecraft-Dev -f

madebr avatar May 31 '25 21:05 madebr

Seeing you implemented vulkan support, does SDL_gpu work? Do the SDL_gpu_examples work?

madebr avatar May 31 '25 22:05 madebr

Seeing you implemented vulkan support, does SDL_gpu work? Do the SDL_gpu_examples work?

I will test later, because I don't have test platform, I need to find other people to do this.

MetsukiMio avatar May 31 '25 23:05 MetsukiMio

Seeing you implemented vulkan support, does SDL_gpu work? Do the SDL_gpu_examples work?

@StarcloudSea here is the owner of the test platform

MetsukiMio avatar Jun 01 '25 00:06 MetsukiMio

Do you need the dynapi functionality of SDL? If you don't, insert a similar disabler for ohos around here.

sezero avatar Jun 01 '25 03:06 sezero

To clarify, I'm not a developer, I was just called to test because the computer has good performance, and I don't know about HarmonyOS development. 😅

Rwagsu avatar Jun 01 '25 06:06 Rwagsu

Do you need the dynapi functionality of SDL? If you don't, insert a similar disabler for ohos around here.

Maybe I need it, is this PR ready for merging?

MetsukiMio avatar Jun 01 '25 08:06 MetsukiMio

@madebr request for review, I have tested the egl & vulkan surface creation, and it works. I also finished the touch & keyboard event.

MetsukiMio avatar Jun 02 '25 01:06 MetsukiMio

@madebr @sezero Request for review, the video subsystem is nearly complete (except the clipboard)

MetsukiMio avatar Jun 07 '25 08:06 MetsukiMio

@madebr Finish

MetsukiMio avatar Jun 07 '25 23:06 MetsukiMio

Nice work you did here!

Do all unit tests work? (ctest tests with a dummy video driver). Does running test/testautomation --video dummy succeed? Does running test/testautomation --video ohos work? Does test/testsprite --renderer opengl work? Does test/testsprite --renderer vulkan work? Does test/testsprite --renderer gpu work? Does test/testfile work? Does test/testfilesystem work?

Do you also intend to add support for other subsystems? I looked a bit through the sparse English documentation, and it looks like ohos also has camera support.

I need to buy a test platform, I may hang this PR for about 2 weeks, and it is able to create vulkan/egl surface for now (I borrowed another developer's PC and runs the emulator, and it's unavailable for now)

MetsukiMio avatar Jun 07 '25 23:06 MetsukiMio

Nice work you did here!

Do all unit tests work? (ctest tests with a dummy video driver). Does running test/testautomation --video dummy succeed? Does running test/testautomation --video ohos work? Does test/testsprite --renderer opengl work? Does test/testsprite --renderer vulkan work? Does test/testsprite --renderer gpu work? Does test/testfile work? Does test/testfilesystem work?

Do you also intend to add support for other subsystems? I looked a bit through the sparse English documentation, and it looks like ohos also has camera support.

I will try to implement the locale, audio subsystem, and locale api implementation is inside the ets part.

MetsukiMio avatar Jun 07 '25 23:06 MetsukiMio

It would also be useful to write some documentation for the docs directory.

Since openharmony is a relatively new os, documentation about how to package a SDL app would be useful. I hope it's not a mess like Android ;)

madebr avatar Jun 07 '25 23:06 madebr

It would also be useful to write some documentation for the docs directory.

Since openharmony is a relatively new os, documentation about how to package a SDL app would be useful. I hope it's not a mess like Android ;)

I have already written a sample harmony/openharmony app at https://github.com/OpenMinecraft-Dev/sdl-ohos-shell, I will try to put it inside

MetsukiMio avatar Jun 07 '25 23:06 MetsukiMio

Does it work? I changed the commit message

MetsukiMio avatar Jun 08 '25 00:06 MetsukiMio

Does it work? I changed the commit message

Hmph. It still seems to run all the workflows. @madebr: Is the filtering correct?

sezero avatar Jun 08 '25 00:06 sezero

Does it work? I changed the commit message

Hmph. It still seems to run all the workflows. @madebr: Is the filtering correct?

I'm using ${{ github.event.head_commit.message }} to get the commit message. It looks like this works for the run in Jack's fork, but does not for this PR.

madebr avatar Jun 08 '25 00:06 madebr

Does it work? I changed the commit message

Hmph. It still seems to run all the workflows. @madebr: Is the filtering correct?

I'm using ${{ github.event.head_commit.message }} to get the commit message. It looks like this works for the run in Jack's fork, but does not for this PR.

Do you find the problem? Why it works in my repo?

MetsukiMio avatar Jun 08 '25 01:06 MetsukiMio

On pushes, github.event is a push object, which has a .head_commit.message` property.

On pull requests, github.event is a pull_request (synchronize) object. This objects does not have .head_commit.message property. Through github.event.pull_request.commits_url, we can find out the commit message. This url returns paged data with a maximum of 100 items. We need the last item, so it'd require to iterate the list. The event has github.event.pull_request.merge_commit_sha, but does not return the sha of the head commit of the pr. Doing something like git log -n -1 HEAD~1 does not reliably return the correct commit (remember, we test merge commits in pull requests, not the actual head commit)

madebr avatar Jun 08 '25 02:06 madebr

On pushes, github.event is a push object, which has a .head_commit.message` property.

On pull requests, github.event is a pull_request (synchronize) object. This objects does not have .head_commit.message property. Through github.event.pull_request.commits_url, we can find out the commit message. This url returns paged data with a maximum of 100 items. We need the last item, so it'd require to iterate the list. The event has github.event.pull_request.merge_commit_sha, but does not return the sha of the head commit of the pr. Doing something like git log -n -1 HEAD~1 does not reliably return the correct commit (remember, we test merge commits in pull requests, not the actual head commit)

It is an existing bug in SDL GitHub workflow?!

MetsukiMio avatar Jun 08 '25 02:06 MetsukiMio

It is an existing bug in SDL GitHub workflow?!

Yes and no. Yes because parsing commit messages do not work. No because pull requests creators cannot sneakily disable a workflow.

So yes, the problem was already present.

madebr avatar Jun 08 '25 02:06 madebr

. No because pull requests creators cannot sneakily disable a workflow.

So yes, the problem was already present.

Actually that's a good thing and not a problem. A patch causing problems elsewhere would go undetected otherwise.

sezero avatar Jun 08 '25 02:06 sezero

@icculus @sezero opengles2 tested, works (but the renderer doesn't work due to the shader problem, I wrote a demo by myself), after solving the multi threading problem, I will put the ohos project into this pr. It is near to the merge

MetsukiMio avatar Jun 27 '25 14:06 MetsukiMio

@madebr @sezero request for review

MetsukiMio avatar Jun 28 '25 04:06 MetsukiMio

@madebr review

MetsukiMio avatar Jul 01 '25 02:07 MetsukiMio

This looks very great. I've got some questions.

  • This adds support for OpenHarmony 5. What compatibility promise does OpenHarmony make? Do apps built for older SDK's run on newer versions?
  • Can you document how to package a SDL3 app and create an OpenHarmony app?

madebr avatar Jul 01 '25 16:07 madebr

This looks very great. I've got some questions.

  • This adds support for OpenHarmony 5. What compatibility promise does OpenHarmony make? Do apps built for older SDK's run on newer versions?
  • Can you document how to package a SDL3 app and create an OpenHarmony app?

For now the port works on any OpenHarmony/HarmonyOS 5.x/6.x systems (I have tested in the emulators), 4.x (older versions is end-of-life)

Now the building of the app requires DevEco Studio, which is very hard to acquire except in China, but I am trying to put the sdl-ohos-shell project into this repo, and I planned to write the document after the audio subsystem porting

MetsukiMio avatar Jul 03 '25 12:07 MetsukiMio

@madebr review

MetsukiMio avatar Jul 08 '25 08:07 MetsukiMio