www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to specify a version from dub build command

reply adnan338 <relay.dev.adnan338 protonmail.com> writes:
I have a separate version for flatpak builds in my app. Let's say 
I have a large project that builds with dub that goes like this:

import std.stdio;

void main()
{
	version (flatpak) {
		writeln(`Flatpak build`);
	} else {
		writeln("Edit source/app.d to start your project.");
	}
}

Now if I try `dub build --version=flatpak` it's not recognized by 
the compiler. How can I set the version __from command line__ 
before building my project? I cannot depend on dflags inside 
dub.json because dub.json has no idea whether if it's being 
parsed in a flatpak version build or a regular build.
Jul 06 2020
parent mw <mingwu gmail.com> writes:
On Tuesday, 7 July 2020 at 06:34:15 UTC, adnan338 wrote:
 I have a separate version for flatpak builds in my app. Let's 
 say I have a large project that builds with dub that goes like 
 this:

 import std.stdio;

 void main()
 {
 	version (flatpak) {
 		writeln(`Flatpak build`);
 	} else {
 		writeln("Edit source/app.d to start your project.");
 	}
 }

 Now if I try `dub build --version=flatpak` it's not recognized 
 by the compiler. How can I set the version __from command 
 line__ before building my project? I cannot depend on dflags 
 inside dub.json because dub.json has no idea whether if it's 
 being parsed in a flatpak version build or a regular build.
try dub Configurations? https://dub.pm/package-format-json.html#configurations
Jul 07 2020