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

Makefile improvements #195

Merged
merged 4 commits into from Aug 20, 2020
Merged

Conversation

greg0ire
Copy link
Member

@greg0ire greg0ire commented Jun 3, 2020

No description provided.

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
Copy link
Member Author

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?

Copy link
Member

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

Copy link
Member Author

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?

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member Author

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?

Copy link
Member Author

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.

@greg0ire
Copy link
Member Author

greg0ire commented Jun 3, 2020

Oh wow the build is so broken… seems to have to do with Composer. Looks like we are already using v2 for some reason.

@greg0ire

This comment has been minimized.

@greg0ire

This comment has been minimized.

@greg0ire

This comment has been minimized.

@greg0ire

This comment has been minimized.

@greg0ire
Copy link
Member Author

greg0ire commented Jun 3, 2020

I cherry-picked the last commit in #196 , since it is far more urgent.

@greg0ire greg0ire requested a review from a team June 3, 2020 19:50
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', '>=');")
Copy link
Member

Choose a reason for hiding this comment

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

why this change?

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

@greg0ire greg0ire Jun 4, 2020

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).

Copy link
Member Author

@greg0ire greg0ire Jun 4, 2020

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.

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
Copy link
Member

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?

Copy link
Member Author

@greg0ire greg0ire Jun 4, 2020

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)

Copy link
Member

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 👍

Copy link
Member

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.

Copy link
Member Author

@greg0ire greg0ire Jun 4, 2020

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?

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

ostrolucky
ostrolucky previously approved these changes Jun 4, 2020
SenseException
SenseException previously approved these changes Jun 4, 2020
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
@greg0ire greg0ire requested review from morozov and a team June 20, 2020 10:36
@lcobucci lcobucci added this to the 9.0.0 milestone Jun 22, 2020
@lcobucci lcobucci self-assigned this Jun 22, 2020
@greg0ire
Copy link
Member Author

@lcobucci why did you assign this to yourself? Do you mean to test it locally before merging, maybe?

@lcobucci
Copy link
Member

I was going to test it locally and merge it but then life happened.

@greg0ire
Copy link
Member Author

ping @lcobucci 🙏

@lcobucci lcobucci merged commit 98aa0e9 into doctrine:master Aug 20, 2020
@lcobucci
Copy link
Member

@greg0ire sorry, mate! 🚢

@greg0ire greg0ire deleted the makefile-improvements branch August 20, 2020 17:24
@greg0ire greg0ire modified the milestones: 9.0.0, 8.2.0 Oct 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants