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: Allow to add EXTRA_FLAGS to FLAGS #5860

Merged
merged 1 commit into from Apr 9, 2018

Conversation

jirutka
Copy link
Contributor

@jirutka jirutka commented Mar 24, 2018

No description provided.

@RX14
Copy link
Contributor

RX14 commented Mar 24, 2018

Why not rename it CRYSTAL_FLAGS and then make it append: CRYSTAL_FLAGS := $(CRYSTAL_FLAGS)...?

By default FLAGS is empty so "set FLAGS and don't set anything else" is an override but you can optionally set stuff like release and have both.

Makefile Outdated
@@ -27,7 +27,7 @@ static ?= ## Enable static linking
O := .build
SOURCES := $(shell find src -name '*.cr')
SPEC_SOURCES := $(shell find spec -name '*.cr')
FLAGS := $(if $(release),--release )$(if $(stats),--stats )$(if $(progress),--progress )$(if $(threads),--threads $(threads) )$(if $(debug),-d )$(if $(static),--static )$(if $(LDFLAGS),--link-flags="$(LDFLAGS)" )
FLAGS := $(if $(release),--release )$(if $(stats),--stats )$(if $(progress),--progress )$(if $(threads),--threads $(threads) )$(if $(debug),-d )$(if $(static),--static )$(if $(LDFLAGS),--link-flags="$(LDFLAGS)" ) $(EXTRA_FLAGS)
Copy link

@Jens0512 Jens0512 Mar 24, 2018

Choose a reason for hiding this comment

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

Would it not to be better to just do something like

override FLAGS += $(if $(release),--release )$(if $(stats),--stats )$(if $(progress),--progress )$(if $(threads),--threads $(threads) )$(if $(debug),-d )$(if $(static),--static )$(if $(LDFLAGS),--link-flags="$(LDFLAGS)" )

That way specifying make all FLAGS=--totally-existant-flag would just prepend --totally-existant-flag to the old FLAGS. And you wouldn't have to type the extra EXTRA_

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah thats what I meant, I should learn more makefile...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That way specifying make all FLAGS=--totally-existant-flag would just prepend --totally-existant-flag to the old FLAGS. And you wouldn't have to type the extra EXTRA_

That indeed an option, but it would not be backward compatible – now you can completely override FLAGS. If Crystal maintainers are okay with this change of behaviour, I’ll change it to the suggested variant.

Copy link
Member

Choose a reason for hiding this comment

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

I had the same concern at first but then there are actually no default values in FLAGS, all depend on another variable being set. So previously specifying FLAGS and for example release didn't work, you already had to do FLAGS=--release --whatever, which will continue to work just the same. Only if you would have specified release=1 FLAGS=--release there would be a slight change, but that was kinda invalid previously already.

Choose a reason for hiding this comment

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

With my suggested change, make all release=1 FLAGS=--no-debug would build with the flags --no-debug --release

Copy link
Contributor Author

@jirutka jirutka Mar 25, 2018

Choose a reason for hiding this comment

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

@Jens0512 Is override really necessary? I think that FLAGS += … should work too; what difference does it make?

Choose a reason for hiding this comment

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

@jirutka Override is absolutely necessary

Choose a reason for hiding this comment

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

@jirutka See RX14s, and my comment for why.

@RX14
Copy link
Contributor

RX14 commented Mar 25, 2018

If a variable has been set with a command argument (see Overriding Variables), then ordinary assignments in the makefile are ignored.

From the make docs.

This change currently actually does nothing, as += doesn't make sense without override in this case.

@Jens0512
Copy link

Jens0512 commented Mar 25, 2018

@jirutka Without override, the += does nothing when FLAGS=... is passed to make, as Chris said. So make all release=1 FLAGS=--time would run with just the flag --time. In other words, += works just the same as := in this case, and nothing will really be changed from how it initially was.

@Jens0512
Copy link

As to the suggestion to rename FLAGS. If FLAGS should be renamed, following Make convention; it should be renamed to CRFLAGS, not CRYSTAL_FLAGS. Though that’s just the Make convention.

Copy link

@Jens0512 Jens0512 left a comment

Choose a reason for hiding this comment

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

This does absolutely nothing. An override is needed.

@RX14
Copy link
Contributor

RX14 commented Mar 31, 2018

@Jens0512 yes - we realise that. It doesn't mean @jirutka has had time to update the PR. Please be patient.

@RX14
Copy link
Contributor

RX14 commented Apr 7, 2018

@jirutka ping? If you don't have time for this I can do it myself.

@jirutka
Copy link
Contributor Author

jirutka commented Apr 9, 2018

Sorry for delay, I’ve updated it now.

@RX14 RX14 added this to the Next milestone Apr 9, 2018
@RX14 RX14 merged commit 1a6d597 into crystal-lang:master Apr 9, 2018
@jirutka jirutka deleted the makefile-extra-flags branch April 10, 2018 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants