-
Notifications
You must be signed in to change notification settings - Fork 56
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
Makefile improvements #195
Conversation
Makefile
Outdated
@@ -18,9 +18,10 @@ test-fix: vendor | |||
update-compatibility-patch: | |||
@git apply tests/php-compatibility.patch | |||
@echo -e "Please open your editor and apply your changes\n" | |||
@until [ "$${compatibility_resolved}" == "y" ]; do read -p "Have finished your changes (y|n)? " compatibility_resolved; done && compatibility_resolved= | |||
@$$EDITOR tests/expected_report.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can somebody that uses Mac OS test this please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would you like me to run? just make update-compatibility-patch
?
-e Please open your editor and apply your changes
/bin/sh: tests/expected_report.txt: Permission denied
make: *** [update-compatibility-patch] Error 126
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like your version of echo doesn't support -e
. Also, looks like you don't have a $EDITOR
variable set, can you confirm that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well yeah I confirm that. Setup should be made to deal with that though, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setup should be made to deal with that though, right?
Can you elaborate? I don't understand what you mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean Makefile should handle the case when $EDITOR is not defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah is see, with EDITOR ?= vim
for instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems a bit forceful, I will just drop that commit.
Oh wow the build is so broken… seems to have to do with Composer. Looks like we are already using v2 for some reason. |
2072f5a
to
294364e
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I cherry-picked the last commit in #196 , since it is far more urgent. |
Makefile
Outdated
@@ -1,6 +1,6 @@ | |||
.PHONY: test test-report test-fix update-compatibility-patch | |||
|
|||
PHP_74_OR_NEWER=`php -r "echo (int) version_compare(PHP_VERSION, '7.4', '>=');"` | |||
PHP_74_OR_NEWER=$(shell php -r "echo (int) version_compare(PHP_VERSION, '7.4', '>=');") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this change, the command is run every time the variable is evaluated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, is that Makefile specific thing? Because this shouldn't be the case in bash. And is same justification used for both changes: changing `` into $()
AND adding `shell`? Where can I find something more about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's very much Makefile specific. It looks like an alternative would be to use :=
note that using backticks is deprecated in favor of $()
in bash.
Also note that $(shell foo)
is a function call and does not result in make calling an hypothetical shell
binary. I think I am going to go with :=
, (or both that and $(shell)
? I have yet to figure out whether to stick with backticks or not).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I'm going to go with both: https://stackoverflow.com/questions/1435861/computing-makefile-variable-on-assignment, but the most important is the $(shell )
here.
d23d995
to
88a2bbd
Compare
Makefile
Outdated
@git diff -- tests/expected_report.txt tests/fixed > .tmp-patch && mv .tmp-patch tests/php-compatibility.patch && git apply -R tests/php-compatibility.patch | ||
@git commit -m 'Update compatibility patch' tests/php-compatibility.patch | ||
|
||
vendor: composer.json | ||
composer update | ||
touch vendor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about this, why are we assuming composer update won't create vendor folder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not assuming it won't create the vendor folder, but we are assuming (rightfully) that it will not change its modification date if it already exists. (touch
is used to create files, not directories, and bumps the modification date when used on either)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this updates timestamp of vendor folder, which will make sure dependant targets like test-report
will run even when vendor wasn't changed 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we only want to modify the date, should we use touch -c
instead? Additionally, are we interested in the directory itself or in all its files (something like $(shell find vendor -type f)
)? That way, we wouldn't have to touch the directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we only want to modify the date, should we use touch -c instead?
@ostrolucky or you @morozov if you use Mac OS can you test touch -c
or better, touch --no-create
with sh
to see if it is portable? I have no idea.
Additionally, are we interested in the directory itself or in all its files (something like $(shell find vendor -type f))? That way, we wouldn't have to touch the directory.
What are you suggesting here? make
only checks the vendor
directory's timestamp (because it is the target). It will not check any of the underlying files.
Ar you suggesting we do
$(shell find vendor -type f)): composer.json
composer update
If yes, how would you even invoke such a target?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@morozov if you use Mac OS
That sounds insulting. No.
What are you suggesting here?
I meant it to be used in the dependency context e.g. target: foo bar $(shell find vendor -type f))
. But I'm not really sure how it's used here, so nevermind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The contents of the vendor
directory only depends on 2 files composer.json
and composer.lock
. And by depends, make
means they are read (by Composer in this case) when generating that directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ostrolucky ran a quick test --no-create
is not supported, but -c
is, let's go with that.
88a2bbd
to
7b124b6
Compare
Make relies on modification dates to decide whether to rebuild a target or to skip it. Running make vendor twice now gives this message the second time: > make: 'vendor' is up to date. And of course, it is much faster.
This should prevent upgrading to Composer v2 by mistake
Looks like echo -e does not work properly with MacOs's sh
bc3659a
to
f66a686
Compare
@lcobucci why did you assign this to yourself? Do you mean to test it locally before merging, maybe? |
I was going to test it locally and merge it but then life happened. |
ping @lcobucci 🙏 |
@greg0ire sorry, mate! 🚢 |
No description provided.