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,test: make building addon tests less fragile #17407

Closed
wants to merge 6 commits into from

Conversation

bnoordhuis
Copy link
Member

@bnoordhuis bnoordhuis commented Nov 30, 2017

  • get rid of recursive make for building the node binary
  • use module name 'binding' in addons.md and addons-napi/*/binding.gyp
  • make addons-verify.js write out dependencies for generated add-ons
  • make gyp write out dependencies for all static deps

This is prep work for a dusted off and super-powered version of #12231.

make finally works as intended now:

$ make
make: Nothing to be done for 'all'.

And make -j8 test (finally!) builds add-ons in parallel.

CI: https://ci.nodejs.org/job/node-test-pull-request/11830/
CI: https://ci.nodejs.org/job/node-test-pull-request/11831/

@nodejs-github-bot nodejs-github-bot added the build Issues and PRs related to build files or the CI. label Nov 30, 2017
@gibfahn
Copy link
Member

gibfahn commented Dec 1, 2017

Awesome, I'll get that CI stuff working post-haste

make finally works as intended now:

Can you elaborate? Is the point that if nothing has changed it doesn't still do a load of stuff?

@@ -2227,3 +2234,10 @@ def CalculateMakefilePath(build_file, base_name):
root_makefile.write(SHARED_FOOTER)

root_makefile.close()

# Hack to get rid of $(obj)/path/to/foo.o deps that node.gyp adds manually.
Copy link
Member

Choose a reason for hiding this comment

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

Should we float the gyp changes in a separate commit in case we lose them in a future gyp update?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. I'll split it out before landing.

@bnoordhuis
Copy link
Member Author

Can you elaborate? Is the point that if nothing has changed it doesn't still do a load of stuff?

Yep. Right now it always does this:

$ make
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C out BUILDTYPE=Release V=1
  touch d271701384a263aa7913b46019f582dfe64aaf59.intermediate
  LD_LIBRARY_PATH=/Users/bnoordhuis/src/v1.x/out/Release/lib.host:/Users/bnoordhuis/src/v1.x/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../deps/v8/src/inspector; mkdir -p /Users/bnoordhuis/src/v1.x/out/Release/obj/gen/src/inspector/protocol /Users/bnoordhuis/src/v1.x/out/Release/obj/gen/include/inspector; python ../../third_party/inspector_protocol/CodeGenerator.py --jinja_dir ../../third_party --output_base "/Users/bnoordhuis/src/v1.x/out/Release/obj/gen/src/inspector" --config inspector_protocol_config.json
  LD_LIBRARY_PATH=/Users/bnoordhuis/src/v1.x/out/Release/lib.host:/Users/bnoordhuis/src/v1.x/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../deps/v8/src/inspector; mkdir -p /Users/bnoordhuis/src/v1.x/out/Release/obj/gen/src; python ../../third_party/inspector_protocol/CheckProtocolCompatibility.py --stamp "/Users/bnoordhuis/src/v1.x/out/Release/obj/gen/src/js_protocol.stamp" js_protocol.json
if [ ! -r node -o ! -L node ]; then ln -fs out/Release/node node; fi

Makefile Outdated
@@ -601,11 +530,8 @@ docopen: $(apidocs_html)
docclean:
$(RM) -r out/doc

build-ci:
run-ci:
Copy link
Member

Choose a reason for hiding this comment

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

cc @nodejs/build in case there are any jobs directly running the build-ci target.

Makefile Outdated
$(NODE_G_EXE): out/Debug/node out/Makefile
ln -fs $< $@

out/Release/node: $(ALL_DEPS)
Copy link
Member

Choose a reason for hiding this comment

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

Does $(ALL_DEPS) include out/Makefile? Since this target recursively executes make it should have a dependency on the makefile.

Makefile Outdated
@@ -601,11 +530,8 @@ docopen: $(apidocs_html)
docclean:
$(RM) -r out/doc

build-ci:
run-ci:
Copy link
Member

Choose a reason for hiding this comment

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

For some reason the CI is complaining

+ make run-ci -j 2
make -C out BUILDTYPE=Release V=1
make[1]: *** out: No such file or directory.  Stop.
Makefile:91: *** Missing or stale config.gypi, please run ./configure.  Stop.
Build step 'Execute shell' marked build as failure

@BridgeAR
Copy link
Member

Ping @bnoordhuis

This seems pretty nice but since the Makefile is a place where things change often, I hope we can get this done fast and land it.

@bnoordhuis
Copy link
Member Author

@BridgeAR IIRC, it needs some CI tweaks and @gibfahn was going to look at that.

@gibfahn
Copy link
Member

gibfahn commented Dec 11, 2017

@BridgeAR IIRC, it needs some CI tweaks and @gibfahn was going to look at that.

I don't recall saying I was going to look at this. I'm happy to, but the CI we were talking about was a build with cmake.

CI fails as this needs a rebase. https://ci.nodejs.org/job/node-test-commit/14743/console

@bnoordhuis bnoordhuis force-pushed the better-addon-building branch 2 times, most recently from 266bb7e to 3416edf Compare December 15, 2017 20:36
@bnoordhuis
Copy link
Member Author

bnoordhuis commented Dec 15, 2017

Rebased and I decided to check in the documentation add-ons. They don't change often enough to go through the trouble of generating them dynamically. Too race-y, too special.

https://ci.nodejs.org/job/node-test-commit/14876/ - mostly green except for an inscrutable AIX issue.
https://ci.nodejs.org/job/node-test-commit/14888/

@bnoordhuis
Copy link
Member Author

Glorious green! Please (re)review. The biggest change from the previous changeset:

  • Check in auto-generated add-on tests from doc/api/addons.md. The
    files change rarely and generating them dynamically causes no end of
    race conditions and special-casing during the build.

Makefile Outdated
deps/zlib/zlib.gyp deps/v8/gypfiles/toolchain.gypi \
deps/v8/gypfiles/features.gypi deps/v8/src/v8.gyp node.gyp \
config.gypi
common.gypi
Copy link
Member

Choose a reason for hiding this comment

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

Is config.gypi intentionally dropped here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but it's no longer necessary. I've pushed up a commit that restores it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I take back what I wrote - it's still necessary because of the config.gypi: configure rule below. But since it's correct to depend on config.gypi here, I'll just remove the other rule.

@@ -1,3 +1,6 @@
<!--
Run `node tools/doc/addon-verify.js` when you change examples in this document.
Copy link
Member

@gibfahn gibfahn Dec 17, 2017

Choose a reason for hiding this comment

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

Is there a way we could validate this? Maybe a test that contains the shasum of everything inside a js code block in this file, that you have to update when it changes.

I guess tools/doc/addon-verify.js would be the place to do it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added a commit that adds a --check flag to addon-verify.js and calls that from make test.

Makefile Outdated
test: all ## Default test target. Runs default tests, linters, and builds docs.
$(MAKE) -s build-addons
$(MAKE) -s build-addons-napi
check-doc-addons: $(NODE)
Copy link
Member

Choose a reason for hiding this comment

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

This should be marked as phony.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@bnoordhuis
Copy link
Member Author

bnoordhuis commented Dec 19, 2017

@richardlau
Copy link
Member

With the config.gypi rule removed, we now get this which is probably less helpful for newcomers:

-bash-4.2$ git clean -fdX
-bash-4.2$ make
make: *** No rule to make target `config.gypi', needed by `out/Makefile'.  Stop.
-bash-4.2$

Is there a reason the makefile doesn't just run configure to generate config.gypi? In most cases it should yield sensible defaults(?).

@bnoordhuis
Copy link
Member Author

bnoordhuis commented Dec 19, 2017

Is there a reason the makefile doesn't just run configure to generate config.gypi?

It used to and it was supremely annoying because it overwrote your settings. I removed it a few years ago.

edit: to expand on that, you'd get situations like these:

$ ./configure --prefix=/path/to/dir
# edit some files, time passes
$ make -j8 install
# runs configure again but without --prefix and installs to the wrong location

@gibfahn
Copy link
Member

gibfahn commented Dec 19, 2017

With the config.gypi rule removed, we now get this which is probably less helpful for newcomers:

Is there a reason we can't have the config.gypi rule with these changes? I'm a fan of the more helpful error message.

Is there a reason the makefile doesn't just run configure to generate config.gypi?

It used to and it was supremely annoying because it overwrote your settings. I removed it a few years ago.

How about only generating a new config.gypi if there isn't one there already?

MylesBorins pushed a commit that referenced this pull request Feb 20, 2018
Ensure `common.tmpDir` exists before trying to chdir into it.  Fixes a
"ENOENT: no such file or directory, uv_chdir" error when the temporary
directory is removed before running the test.

PR-URL: #17407
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
MylesBorins pushed a commit that referenced this pull request Feb 21, 2018
Ensure `common.tmpDir` exists before trying to chdir into it.  Fixes a
"ENOENT: no such file or directory, uv_chdir" error when the temporary
directory is removed before running the test.

PR-URL: #17407
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
MylesBorins pushed a commit that referenced this pull request Feb 21, 2018
Ensure `common.tmpDir` exists before trying to chdir into it.  Fixes a
"ENOENT: no such file or directory, uv_chdir" error when the temporary
directory is removed before running the test.

PR-URL: #17407
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
@MylesBorins MylesBorins mentioned this pull request Feb 21, 2018
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
Make GYP write a .deps file in the top-level directory that we can use
in the Makefile to get a proper dependency chain for the `node` target.
Preparatory work for getting rid of recursive make invocations.

PR-URL: nodejs#17407
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
Make the script synchronous and clean it up.  This is preparatory work
for follow-ups commits.

PR-URL: nodejs#17407
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
* Get rid of recursive `make` when building the node binary.  An earlier
  commit makes GYP write out rules that we can use for proper dependency
  tracking.

* Use module name 'binding' in addons.md and addons-napi/*/binding.gyp.
  This massively simplifies the logic for generating the build rules.

* Check in auto-generated add-on tests from `doc/api/addons.md`.  The
  files change rarely and generating them dynamically causes no end of
  race conditions and special-casing during the build.

PR-URL: nodejs#17407
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
Add a `--check` flag to `tools/doc/addon-verify.js` and use that in the
`make test` target to determine if the generated files in `test/addons`
are fresh or stale.

PR-URL: nodejs#17407
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
Ensure `common.tmpDir` exists before trying to chdir into it.  Fixes a
"ENOENT: no such file or directory, uv_chdir" error when the temporary
directory is removed before running the test.

PR-URL: nodejs#17407
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
This reverts commit 2cb9e2a.

Reverted along with d9b59de as this introduces freshness checks that
are too stringent without the comprehensive dependency checking of
introduced in d9b59de so `make test` won't work with this.

Ref: nodejs#17407
PR-URL: nodejs#18287
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
This reverts commit d9b59de.

Breaks downloadable source tarball builds as we remove some files prior
to creating a tarball but those files are included in the comprehensive
list of dependencies listed in .deps.

Ref: nodejs#17407
PR-URL: nodejs#18287
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
This reverts commit c668263.

Reverted along with d9b59de as this breaks compilation from
downloadable source tarballs.

Ref: nodejs#17407
PR-URL: nodejs#18287
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
This reverts commit 920c132.

Reverted along with d9b59de as this breaks compilation from
downloadable source tarballs.

Ref: nodejs#17407
PR-URL: nodejs#18287
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants