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,tools: make addons tests work with GN #50737

Closed
wants to merge 3 commits into from

Conversation

zcbenz
Copy link
Contributor

@zcbenz zcbenz commented Nov 15, 2023

This PR refactors the install and build_addons scripts so they can be reused by node-ci and electron projects to build the addons tests.

In detail, this PR does following things:

  1. Minor modifications of the GN configurations to fix loading native modules.
  2. Add some flags to tools/install.py script to allow customize locations of config.gypi, v8, etc. With some refactoring to remove global variables.
  3. Rewrite the tools/build_addons.py script:
    1. Rewrite it from js to python, because implementing cmd args handling with vanilla Node.js would take much longer time than a simple rewrite.
    2. Add a few more flags to make it easier to use for embedders.
  4. Modify the Makefile to generate headers in out dir first, and then calls build_addons.py --headers-dir=out_dir/headers (which calls node-gyp --nodedir=out_dir/headers) to build addons. Previously the build system was just calling node-gyp --nodedir=., which relied on quirky behavior of node-gyp and did not really test whether the generated headers work.

Users that rely on make or vcbuild.bat to work on Node are not affected.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/tsc

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. dependencies Pull requests that update a dependency file. libuv Issues and PRs related to the libuv dependency or the uv binding. needs-ci PRs that need a full CI run. openssl Issues and PRs related to the OpenSSL dependency. python PRs and issues that require attention from people who are familiar with Python. tools Issues and PRs related to the tools directory. windows Issues and PRs related to the Windows platform. labels Nov 15, 2023
@zcbenz zcbenz force-pushed the build-addons-gn branch 2 times, most recently from 507f7ab to 353afc9 Compare November 15, 2023 11:06
@zcbenz zcbenz force-pushed the build-addons-gn branch 2 times, most recently from 0940864 to 13f87fc Compare November 16, 2023 07:32
@zcbenz
Copy link
Contributor Author

zcbenz commented Nov 16, 2023

I have separated some changes out of this PR so review should be easier.

/cc @nodejs/gyp @joyeecheung @richardlau for reviewing changes on tools.

tools/build_addons.py Outdated Show resolved Hide resolved
@gengjiawen gengjiawen added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 17, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 17, 2023
@nodejs-github-bot
Copy link
Collaborator

@zcbenz
Copy link
Contributor Author

zcbenz commented Nov 28, 2023

Ping @nodejs/gyp @joyeecheung @anonrig for review after the holiday.

Copy link
Member

@joyeecheung joyeecheung left a comment

Choose a reason for hiding this comment

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

LGTM % a correction but I think ideally we should have someone from @nodejs/build to confirm that it works with our releases.

Makefile Outdated Show resolved Hide resolved
@gengjiawen gengjiawen added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 4, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 4, 2023
@nodejs-github-bot
Copy link
Collaborator

@zcbenz zcbenz force-pushed the build-addons-gn branch 3 times, most recently from 974401b to 3be1111 Compare January 4, 2024 02:28
@zcbenz zcbenz 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 Feb 23, 2024
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Feb 23, 2024
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/50737
✔  Done loading data for nodejs/node/pull/50737
----------------------------------- PR info ------------------------------------
Title      build,tools: make addons tests work with GN (#50737)
   ⚠  Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch     zcbenz:build-addons-gn -> nodejs:main
Labels     windows, build, openssl, libuv, tools, python, needs-ci, dependencies, commit-queue-squash
Commits    3
 - build,tools: make addons tests work with GN
 - build,tools: generate node headers on request
 - build,tools: there are 2 out dirs on windows
Committers 1
 - Cheng Zhao 
PR-URL: https://github.com/nodejs/node/pull/50737
Reviewed-By: Joyee Cheung 
Reviewed-By: Benjamin Gruenbaum 
Reviewed-By: Yagiz Nizipli 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/50737
Reviewed-By: Joyee Cheung 
Reviewed-By: Benjamin Gruenbaum 
Reviewed-By: Yagiz Nizipli 
--------------------------------------------------------------------------------
   ⚠  Commits were pushed since the last approving review:
   ⚠  - build,tools: make addons tests work with GN
   ⚠  - build,tools: generate node headers on request
   ⚠  - build,tools: there are 2 out dirs on windows
   ℹ  This PR was created on Wed, 15 Nov 2023 08:29:46 GMT
   ✔  Approvals: 3
   ✔  - Joyee Cheung (@joyeecheung) (TSC): https://github.com/nodejs/node/pull/50737#pullrequestreview-1810123695
   ✔  - Benjamin Gruenbaum (@benjamingr) (TSC): https://github.com/nodejs/node/pull/50737#pullrequestreview-1756204771
   ✔  - Yagiz Nizipli (@anonrig) (TSC): https://github.com/nodejs/node/pull/50737#pullrequestreview-1805222548
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2024-02-23T01:17:58Z: https://ci.nodejs.org/job/node-test-pull-request/57320/
- Querying data for job/node-test-pull-request/57320/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/8015803850

zcbenz added a commit that referenced this pull request Feb 23, 2024
PR-URL: #50737
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
@zcbenz
Copy link
Contributor Author

zcbenz commented Feb 23, 2024

Landed in b1468d2

@zcbenz zcbenz closed this Feb 23, 2024
@zcbenz zcbenz deleted the build-addons-gn branch February 23, 2024 07:17
marco-ippolito pushed a commit that referenced this pull request Feb 26, 2024
PR-URL: #50737
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
marco-ippolito pushed a commit that referenced this pull request Feb 26, 2024
PR-URL: #50737
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
marco-ippolito pushed a commit that referenced this pull request Feb 27, 2024
PR-URL: #50737
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
@batrla
Copy link
Contributor

batrla commented Feb 28, 2024

Sorry to report it, but this PR caused regression, build in --shared mode now fails:

11:02:41: stdout installing /some_dir/build/prototype/i386/some_bindir/node
11:02:41: stderr Traceback (most recent call last):
11:02:41: stderr   File "/some_dir/build/amd64/tools/install.py", line 419, in <module>
11:02:41: stderr     run(parse_options(sys.argv[1:]))
11:02:41: stderr   File "/some_dir/build/amd64/tools/install.py", line 372, in run
11:02:41: stderr     files(options, install)
11:02:41: stderr   File "/some_dir/build/amd64/tools/install.py", line 179, in files
11:02:41: stderr     action(options, [os.path.join(output_prefix, output_lib)],
11:02:41: stderr                                   ^^^^^^^^^^^^^
11:02:42: stderr UnboundLocalError: cannot access local variable 'output_prefix' where it is not associated with a value   

The problem in source code is obvious, the variable 'output_prefix' is only defined in some branches.
Later in code the variable is used in a branch where it was not defined before.

@zcbenz
Copy link
Contributor Author

zcbenz commented Feb 28, 2024

Sorry for breaking it! I'll create a fix soon.

zcbenz added a commit to zcbenz/node that referenced this pull request Feb 28, 2024
Fix a bug caused by nodejs#50737 that,
make install fails for --shared mode.
@marco-ippolito marco-ippolito mentioned this pull request Mar 1, 2024
nodejs-github-bot pushed a commit that referenced this pull request Mar 1, 2024
Fix a bug caused by #50737 that,
make install fails for --shared mode.

PR-URL: #51910
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
marco-ippolito pushed a commit that referenced this pull request Mar 1, 2024
Fix a bug caused by #50737 that,
make install fails for --shared mode.

PR-URL: #51910
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
marco-ippolito pushed a commit that referenced this pull request Mar 1, 2024
Fix a bug caused by #50737 that,
make install fails for --shared mode.

PR-URL: #51910
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
zcbenz pushed a commit to photoionization/node_ci that referenced this pull request Mar 6, 2024
- Use node in-tree gn configs when possible.
  Some in-tree configs (deps/openssl) were modified in our mirror until
  they are fixed in the upstream node repo [1].
- Trigger landmine to clean out directory (required due to changed
  targets with new build files)
- Update to node-ci-2024-01-17
- Add fp16 to update_deps.py

[1] nodejs/node#50737.

Bug: v8:14572

Change-Id: I86cc19d23151b2a64d7173cf8f0aa6adc417c091
Reviewed-on: https://chromium-review.googlesource.com/c/v8/node-ci/+/5203209
Commit-Queue: Patrick Thier <pthier@chromium.org>
Reviewed-by: Victor Gomes <victorgomes@chromium.org>
richardlau pushed a commit that referenced this pull request Mar 25, 2024
PR-URL: #50737
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
richardlau pushed a commit that referenced this pull request Mar 25, 2024
Fix a bug caused by #50737 that,
make install fails for --shared mode.

PR-URL: #51910
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
richardlau pushed a commit that referenced this pull request Mar 25, 2024
PR-URL: #50737
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
richardlau pushed a commit that referenced this pull request Mar 25, 2024
Fix a bug caused by #50737 that,
make install fails for --shared mode.

PR-URL: #51910
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@richardlau richardlau mentioned this pull request Mar 25, 2024
rdw-msft pushed a commit to rdw-msft/node that referenced this pull request Mar 26, 2024
PR-URL: nodejs#50737
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
rdw-msft pushed a commit to rdw-msft/node that referenced this pull request Mar 26, 2024
Fix a bug caused by nodejs#50737 that,
make install fails for --shared mode.

PR-URL: nodejs#51910
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI. commit-queue-failed An error occurred while landing this pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. dependencies Pull requests that update a dependency file. libuv Issues and PRs related to the libuv dependency or the uv binding. needs-ci PRs that need a full CI run. openssl Issues and PRs related to the OpenSSL dependency. python PRs and issues that require attention from people who are familiar with Python. tools Issues and PRs related to the tools directory. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants