Visitar URL original
build: refactor Android build system by MeowShe · Pull Request #44207 · nodejs/node · GitHub
The Wayback Machine - https://web.archive.org/web/20221002014741/https://github.com/nodejs/node/pull/44207
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: refactor Android build system #44207

Merged
merged 5 commits into from Sep 12, 2022

Conversation

MeowShe
Copy link
Contributor

@MeowShe MeowShe commented Aug 11, 2022 •

Completely rewritten the Android build process in Python to make it more complete and CI ready.

  • Supported building node for android on macOS (Intel)

Refs: #36287

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. needs-ci PRs that need a full CI run. labels Aug 11, 2022
@MeowShe MeowShe closed this Aug 11, 2022
@MeowShe MeowShe reopened this Aug 11, 2022
@MeowShe MeowShe force-pushed the android-configure branch 4 times, most recently from 8ef2283 to 4e6f250 Compare Aug 15, 2022
@MeowShe MeowShe changed the title build: improved build for Android platform build: refactored Android build system Aug 16, 2022
@MeowShe MeowShe force-pushed the android-configure branch 2 times, most recently from 12b559b to dc5aad2 Compare Aug 17, 2022
@tniessen
Copy link
Member

tniessen commented Aug 23, 2022

cc @nodejs/build

@MeowShe
Copy link
Contributor Author

MeowShe commented Aug 30, 2022 •

cc @nodejs/build

Is there anything I can do to advance this pull request plz?

@MeowShe MeowShe closed this Sep 4, 2022
@tniessen
Copy link
Member

tniessen commented Sep 4, 2022

I'm very sorry about the lack of activity on the project's side here. I'm afraid I don't know if any of the current project members actively maintain support for Android. There is no platform team for Android, and android-configure appears to be modified about once a year only.

I'm going to try pinging those folks who approved previous PRs: @cclauss @devnexen @F3n67u @yashLadha @bnoordhuis

@cclauss
Copy link
Contributor

cclauss commented Sep 4, 2022

I do know Android so I have not commented.

@MeowShe MeowShe reopened this Sep 5, 2022
@F3n67u F3n67u added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 5, 2022
android_configure.py Outdated Show resolved Hide resolved
@F3n67u F3n67u removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 5, 2022
@MeowShe MeowShe requested a review from F3n67u Sep 5, 2022
android_configure.py Outdated Show resolved Hide resolved
android-configure Outdated Show resolved Hide resolved
sys.exit(0)

if len(sys.argv) != 4:
print("Usage: ./android-configure [patch] <path to the Android NDK> <Android SDK version> <target architecture>")
Copy link
Member

@F3n67u F3n67u Sep 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@MeowShe MeowShe Sep 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but in this branch, BUILDING.md is out of date, do I need to create a new branch and pull requests to update it or later?

Copy link
Member

@F3n67u F3n67u Sep 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to update this doc in the same pr.

Copy link
Member

@F3n67u F3n67u Sep 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @MeowShe. Would you update BUILDING.md in this pr?

Copy link
Contributor Author

@MeowShe MeowShe Sep 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @MeowShe. Would you update BUILDING.md in this pr?

I want but I don't seem to know how to do it because the BUILDING.md in this branch is out of date and if I update BUILDING.md it will cause a conflict and I will have to merge main branch to solve it, but the nodejs Pull Request CI doesn't seem to allow me to do that.

Copy link
Contributor Author

@MeowShe MeowShe Sep 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I will update BUILDING.md using rebase when all the fix are ready.

Copy link
Member

@F3n67u F3n67u Sep 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MeowShe would you mind update the BUILDING.md to keep the doc update with this change?

Copy link
Contributor Author

@MeowShe MeowShe Sep 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will open a new pull request to update it, and a macOS build fix will be included, thank you.

Copy link
Member

@F3n67u F3n67u Sep 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. A person asked me in an email if android configure is supported in the latest main branch. So I remember our BUILING.md if lost updated with our codebase.😃

Copy link
Contributor Author

@MeowShe MeowShe Sep 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will commit those changes ASAP 😃

android_configure.py Outdated Show resolved Hide resolved
android_configure.py Outdated Show resolved Hide resolved
android-patches/trap-handler.h.patch Show resolved Hide resolved
@F3n67u
Copy link
Member

F3n67u commented Sep 5, 2022

I tried to build with this change on macOS (Intel), but got the following error:

$ ./android-configure ~/Library/Android/sdk/ndk/25.1.8937393 28 x86_64
$ make
rm -f /Users/feng/dev/node/out/Release/obj.target/tools/icu/libicuucx.a ar-file-list; mkdir -p `dirname /Users/feng/dev/node/out/Release/obj.target/tools/icu/libicuucx.a`
ar crsT /Users/feng/dev/node/out/Release/obj.target/tools/icu/libicuucx.a @/Users/feng/dev/node/out/Release/obj.target/tools/icu/libicuucx.a.ar-file-list
ar: @/Users/feng/dev/node/out/Release/obj.target/tools/icu/libicuucx.a.ar-file-list: No such file or directory
make[1]: *** [/Users/feng/dev/node/out/Release/obj.target/tools/icu/libicuucx.a] Error 1
make: *** [node] Error 2

Do you have any idea why this error happened?

android_configure.py Outdated Show resolved Hide resolved
android_configure.py Outdated Show resolved Hide resolved
android_configure.py Outdated Show resolved Hide resolved
Completely rewritten the Android build system using Python

Co-Authored-By: 东灯 <43312495+Lampese@users.noreply.github.com>
Co-Authored-By: Feng Yu <F3n67u@outlook.com>
@F3n67u
Copy link
Member

F3n67u commented Sep 5, 2022

I tried to build with this change on macOS (Intel), but got the following error:

$ ./android-configure ~/Library/Android/sdk/ndk/25.1.8937393 28 x86_64
$ make
rm -f /Users/feng/dev/node/out/Release/obj.target/tools/icu/libicuucx.a ar-file-list; mkdir -p `dirname /Users/feng/dev/node/out/Release/obj.target/tools/icu/libicuucx.a`
ar crsT /Users/feng/dev/node/out/Release/obj.target/tools/icu/libicuucx.a @/Users/feng/dev/node/out/Release/obj.target/tools/icu/libicuucx.a.ar-file-list
ar: @/Users/feng/dev/node/out/Release/obj.target/tools/icu/libicuucx.a.ar-file-list: No such file or directory
make[1]: *** [/Users/feng/dev/node/out/Release/obj.target/tools/icu/libicuucx.a] Error 1
make: *** [node] Error 2

Do you have any idea why this error happened?

I cannot build for Android with main branch too, so feel free to ignore this comment.

print("- Patches List -")
print("[1] [deps/v8/src/trap-handler/trap-handler.h] related to https://github.com/nodejs/node/issues/36287")
if platform.system() == "Linux":
os.system('patch -f ./deps/v8/src/trap-handler/trap-handler.h < ./android-patches/trap-handler.h.patch')
Copy link
Contributor

@cclauss cclauss Sep 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use subprocess.run() instead of os.system() for security and compatibility reasons.

android_configure.py Outdated Show resolved Hide resolved
@F3n67u F3n67u changed the title build: refactored Android build system build: refactor Android build system Sep 5, 2022
@F3n67u
Copy link
Member

F3n67u commented Sep 11, 2022

Hi @F3n67u, Do you know how to replace the ar in the Apple LLVM toolchain with llvm-ar in the Android NDK?

I am sorry. I don't know.

Just create a link called ar to the environment variable PATH for Android NDK/toolchains/llvm/prebuilt/YOUR_OS-ARCH/bin/llvm-ar, and I recommend that you back up your old environment variable PATH, then try to rebuild Node.js for android.

It works. After replacing ar with llvm-ar, the ar operation failure is solved. But I still fail with:

$ make
LD_LIBRARY_PATH=/Users/feng/dev/node/out/Release/lib.host:/Users/feng/dev/node/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../tools/icu; mkdir -p /Users/feng/dev/node/out/Release/obj/gen; "/Users/feng/dev/node/out/Release/icupkg" -tl ../../deps/icu-tmp/icudt71l.dat "/Users/feng/dev/node/out/Release/obj/gen/icudt71l.dat"
/bin/sh: /Users/feng/dev/node/out/Release/icupkg: cannot execute binary file
make[1]: *** [tools/icu/icudata.target.mk:13: /Users/feng/dev/node/out/Release/obj/gen/icudt71l.dat] Error 126
make: *** [Makefile:113: node] Error 2

This time fail at "/Users/feng/dev/node/out/Release/icupkg" -tl ../../deps/icu-tmp/icudt71l.dat "/Users/feng/dev/node/out/Release/obj/gen/icudt71l.dat", seems out/Release/icupkg is broken:

$ out/Release/icupkg
zsh: exec format error: out/Release/icupkg

android_configure.py Outdated Show resolved Hide resolved
Co-authored-by: Christian Clauss <cclauss@me.com>
@MeowShe
Copy link
Contributor Author

MeowShe commented Sep 12, 2022 •

Hi @F3n67u, Do you know how to replace the ar in the Apple LLVM toolchain with llvm-ar in the Android NDK?

I am sorry. I don't know.

Just create a link called ar to the environment variable PATH for Android NDK/toolchains/llvm/prebuilt/YOUR_OS-ARCH/bin/llvm-ar, and I recommend that you back up your old environment variable PATH, then try to rebuild Node.js for android.

It works. After replacing ar with llvm-ar, the ar operation failure is solved. But I still fail with:

$ make

LD_LIBRARY_PATH=/Users/feng/dev/node/out/Release/lib.host:/Users/feng/dev/node/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../tools/icu; mkdir -p /Users/feng/dev/node/out/Release/obj/gen; "/Users/feng/dev/node/out/Release/icupkg" -tl ../../deps/icu-tmp/icudt71l.dat "/Users/feng/dev/node/out/Release/obj/gen/icudt71l.dat"

/bin/sh: /Users/feng/dev/node/out/Release/icupkg: cannot execute binary file

make[1]: *** [tools/icu/icudata.target.mk:13: /Users/feng/dev/node/out/Release/obj/gen/icudt71l.dat] Error 126

make: *** [Makefile:113: node] Error 2

This time fail at "/Users/feng/dev/node/out/Release/icupkg" -tl ../../deps/icu-tmp/icudt71l.dat "/Users/feng/dev/node/out/Release/obj/gen/icudt71l.dat", seems out/Release/icupkg is broken:

$ out/Release/icupkg

zsh: exec format error: out/Release/icupkg

All of the errors above were generated in building icupkg for macOS, we might as well build icupkg for macOS separately and I will include this in next commit.

Before that, could you try to build Node.js for Android without icu?

F3n67u
F3n67u approved these changes Sep 12, 2022
@F3n67u F3n67u added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 12, 2022
@F3n67u
Copy link
Member

F3n67u commented Sep 12, 2022 •

I think it's fine to land this pr first to move fast. Let's land this first and leave the rest of work to separate pr.

@F3n67u F3n67u added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Sep 12, 2022
@MeowShe
Copy link
Contributor Author

MeowShe commented Sep 12, 2022

I think it's fine to land this pr first to move fast. Let's land this first and leave the rest of work to separate pr.

It's sounds great.

@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 12, 2022
@nodejs-github-bot
Copy link
Contributor

nodejs-github-bot commented Sep 12, 2022

@nodejs-github-bot
Copy link
Contributor

nodejs-github-bot commented Sep 12, 2022

@F3n67u F3n67u added commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. commit-queue Add this label to land a pull request using GitHub Actions. labels Sep 12, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Sep 12, 2022
@nodejs-github-bot nodejs-github-bot merged commit ee9aac1 into nodejs:main Sep 12, 2022
54 checks passed
@nodejs-github-bot
Copy link
Contributor

nodejs-github-bot commented Sep 12, 2022

Landed in ee9aac1

@MeowShe MeowShe deleted the android-configure branch Sep 12, 2022
Fyko pushed a commit to Fyko/node that referenced this pull request Sep 15, 2022
Completely rewritten the Android build system using Python

Co-Authored-By: 东灯 <43312495+Lampese@users.noreply.github.com>
Co-Authored-By: Feng Yu <F3n67u@outlook.com>
PR-URL: nodejs#44207
Refs: nodejs#36287
Reviewed-By: Feng Yu <F3n67u@outlook.com>
Reviewed-By: Christian Clauss <cclauss@me.com>
RafaelGSS pushed a commit that referenced this pull request Sep 26, 2022
Completely rewritten the Android build system using Python

Co-Authored-By: 东灯 <43312495+Lampese@users.noreply.github.com>
Co-Authored-By: Feng Yu <F3n67u@outlook.com>
PR-URL: #44207
Refs: #36287
Reviewed-By: Feng Yu <F3n67u@outlook.com>
Reviewed-By: Christian Clauss <cclauss@me.com>
@RafaelGSS RafaelGSS mentioned this pull request Sep 26, 2022
@tniessen
Copy link
Member

tniessen commented Sep 26, 2022

Thanks for the contribution @MeowShe.

RafaelGSS pushed a commit that referenced this pull request Sep 26, 2022
Completely rewritten the Android build system using Python

Co-Authored-By: 东灯 <43312495+Lampese@users.noreply.github.com>
Co-Authored-By: Feng Yu <F3n67u@outlook.com>
PR-URL: #44207
Refs: #36287
Reviewed-By: Feng Yu <F3n67u@outlook.com>
Reviewed-By: Christian Clauss <cclauss@me.com>
RafaelGSS pushed a commit that referenced this pull request Sep 26, 2022
Completely rewritten the Android build system using Python

Co-Authored-By: 东灯 <43312495+Lampese@users.noreply.github.com>
Co-Authored-By: Feng Yu <F3n67u@outlook.com>
PR-URL: #44207
Refs: #36287
Reviewed-By: Feng Yu <F3n67u@outlook.com>
Reviewed-By: Christian Clauss <cclauss@me.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. build Issues and PRs related to build files or the CI. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants