Skip to content

Comments

Allow passing additional DFLAGS to the DMD build#8089

Merged
RazvanN7 merged 1 commit intodlang:masterfrom
wilzbach:override-make
Apr 2, 2018
Merged

Allow passing additional DFLAGS to the DMD build#8089
RazvanN7 merged 1 commit intodlang:masterfrom
wilzbach:override-make

Conversation

@wilzbach
Copy link
Contributor

There are many predefined ways to build DMD, but AFAIK one can't easily
pass in its own DFLAGS without modifying the Makefile.
With this change the following is now possible:

make -f posix.mak DFLAGS="-version=FooBar"

Learn more about override: https://www.gnu.org/software/make/manual/make.html#Override-Directive

@wilzbach
Copy link
Contributor Author

Hmm, environment variables are respected too and I think we don't want a global DFLAGS setting to affect the DMD build, so it looks like it's not as simple as this :/

There are many predefined ways to build DMD, but AFAIK one can't easily
pass in its own `DFLAGS` without modifying the Makefile.
With this change the following is now possible:

```
make -f posix.mak DFLAGS="-version=FooBar"
```

Learn more about `override`: https://www.gnu.org/software/make/manual/make.html#Override-Directive
@dlang-bot
Copy link
Contributor

Thanks for your pull request, @wilzbach!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + dmd#8089"

@wilzbach
Copy link
Contributor Author

So looking at the manual there's a good solution:

Variables in make can come from the environment in which make is run. Every environment variable that make sees when it starts up is transformed into a make variable with the same name and value. However, an explicit assignment in the makefile, or with a command argument, overrides the environment.

https://www.gnu.org/software/make/manual/html_node/Environment.html#Environment

which means that:

DFLAGS=
override DFLAGS += -version=MARS $(PIC)

will ignore environment variables, but allow user-defined command line arguments:

> pmake -j20 DFLAGS="-version=FooBar"
CC="c++" dmd -of../generated/linux/release/64/dmd -m64 -vtls -J../generated/linux/release/64 -J../res -L-lstdc++ -version=FooBar -version=MARS -fPIC -w -de
> DFLAGS="-version=FooBar" pmake -j20
CC="c++" dmd -of../generated/linux/release/64/dmd -m64 -vtls -J../generated/linux/release/64 -J../res -L-lstdc++  -version=MARS -fPIC -w -de 

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.

3 participants