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: remove requirement to re-run ./configure #21371

Closed
wants to merge 2 commits into from

Conversation

addaleax
Copy link
Member

Instead of requiring ./configure to be run again after
the file changed, first try to re-run the configure script
with the arguments with which it was originally run.

Usually, those arguments will either contain no flags,
or all flags that were passed are still supported.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Instead of requiring `./configure` to be run again after
the file changed, first try to re-run the configure script
with the arguments with which it was originally run.

Usually, those arguments will either contain no flags,
or all flags that were passed are still supported.
devsnek added a commit to devsnek/zero-archive that referenced this pull request Jun 16, 2018
@devsnek devsnek added the build Issues and PRs related to build files or the CI. label Jun 16, 2018
refack
refack previously requested changes Jun 16, 2018
@@ -98,7 +98,12 @@ out/Makefile: common.gypi deps/uv/uv.gyp deps/http_parser/http_parser.gyp \
$(PYTHON) tools/gyp_node.py -f make

config.gypi: configure
$(error Missing or stale $@, please run ./$<)
@if [ -x config.status ]; then \
./config.status; \
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather have:

$(PYTHON) configure $(something that reads .configure_args as args)

So it will be easier to implement for Windows

Copy link
Contributor

Choose a reason for hiding this comment

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

btw shouldn't this be dependant on ls -R *.gyp? as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

So it will be easier to implement for Windows

We could follow the same approach pretty easily, I think

btw shouldn't this be dependant on ls -R *.gyp? as well?

I don’t know, somebody else would have to answer that

Copy link
Contributor

Choose a reason for hiding this comment

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

Now I understand why your pattern makes perfect sense for autotools, since it only assumes a POSIX compatible shell...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah … I heard escaping parameters for cmd is fun :)

Otherwise we should be able to follow the same format here if we like

Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this be dependant on ls -R *.gyp?

Ideally, yes, but can be done in a separate PR.

@@ -69,6 +69,7 @@ ipch/

/config.mk
/config.gypi
/config.status
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggesting a .configure_args approach, and .* files are ignored by default.

@refack
Copy link
Contributor

refack commented Jun 16, 2018

tl;dr if we simply store the args as .configure_args it could be reused in #21284

Another idea, add a --args=.configure_args to configure, then no file reading is needed.

@addaleax
Copy link
Member Author

@refack This approach and filename match what it’s how the autotools configure script works, which is the reason it’s named configure in the first place.

@refack refack dismissed their stale review June 17, 2018 00:06

Dismissing for autotools similarity

@refack
Copy link
Contributor

refack commented Jun 17, 2018

refack This approach and filename match what it’s how the autotools configure script works, which is the reason it’s named configure in the first place.

But configure is not autotools generated, and we do need to consider cross platform and code reuse. I'm not going to block, but seems like a shame to miss out on this.

My suggestion is:

---
 configure | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 97a75b98569..c8a21c35703 100755
--- a/configure
+++ b/configure
@@ -554,7 +554,13 @@ parser.add_option('-C',
     dest='compile_commands_json',
     help=optparse.SUPPRESS_HELP)
 
-(options, args) = parser.parse_args()
+args = sys.argv[1:]
+if args[0] == '--reuse':
+  with open('.used_configure_flags') as f
+  args = f.readlines()
+else:
+  write('.used_configure_flags', '\n'.join(args)
+(options, args) = parser.parse_args(args)
 
 # Expand ~ in the install prefix now, it gets written to multiple files.
 options.prefix = os.path.expanduser(options.prefix or '')

@addaleax
Copy link
Member Author

@refack How would this work on Windows? vcbuild.bat runs configure unconditionally anyway, right?

@refack
Copy link
Contributor

refack commented Jun 17, 2018

#21284 is a PR to avoid that (get it to work similar to this after your change, only there it needs to do CMD batch acrobatics).

configure Outdated
@@ -1513,6 +1518,10 @@ pprint.pprint(output, indent=2)
write('config.gypi', do_not_edit +
pprint.pformat(output, indent=2) + '\n')

write('config.status', '#!/bin/sh\nset -ex\n./configure ' +
Copy link
Member

Choose a reason for hiding this comment

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

nit: How about exec ./configure …? This should allow getting rid of the set -e.

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!

configure Outdated
@@ -1513,6 +1518,10 @@ pprint.pprint(output, indent=2)
write('config.gypi', do_not_edit +
pprint.pformat(output, indent=2) + '\n')

write('config.status', '#!/bin/sh\nset -ex\n./configure ' +
' '.join([shell_quote(arg) for arg in original_argv]) + '\n')
Copy link
Member

Choose a reason for hiding this comment

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

Use pipes.quote(arg) for this (officially deprecated but shlex.quote doesn't exist in python 2.7.)

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!

@@ -98,7 +98,12 @@ out/Makefile: common.gypi deps/uv/uv.gyp deps/http_parser/http_parser.gyp \
$(PYTHON) tools/gyp_node.py -f make

config.gypi: configure
$(error Missing or stale $@, please run ./$<)
@if [ -x config.status ]; then \
./config.status; \
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this be dependant on ls -R *.gyp?

Ideally, yes, but can be done in a separate PR.

@addaleax
Copy link
Member Author

@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jun 25, 2018
jasnell pushed a commit that referenced this pull request Jun 29, 2018
Instead of requiring `./configure` to be run again after
the file changed, first try to re-run the configure script
with the arguments with which it was originally run.

Usually, those arguments will either contain no flags,
or all flags that were passed are still supported.

PR-URL: #21371
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Ujjwal Sharma <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
@jasnell
Copy link
Member

jasnell commented Jun 29, 2018

Landed in 074e7f8

@jasnell jasnell closed this Jun 29, 2018
targos pushed a commit that referenced this pull request Jun 30, 2018
Instead of requiring `./configure` to be run again after
the file changed, first try to re-run the configure script
with the arguments with which it was originally run.

Usually, those arguments will either contain no flags,
or all flags that were passed are still supported.

PR-URL: #21371
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Ujjwal Sharma <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
@targos targos mentioned this pull request Jul 3, 2018
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants