diff --git a/source/dub/commandline.d b/source/dub/commandline.d
index 117b390..042279e 100644
--- a/source/dub/commandline.d
+++ b/source/dub/commandline.d
@@ -325,6 +325,7 @@
abstract class PackageBuildCommand : Command {
protected {
string m_buildType;
+ BuildMode m_buildMode;
string m_buildConfig;
string m_compilerName = .determineCompiler();
string m_arch;
@@ -363,6 +364,10 @@
args.getopt("force-remove", &m_forceRemove, [
"Force deletion of fetched packages with untracked files when upgrading"
]);
+ args.getopt("build-mode", &m_buildMode, [
+ "Specifies the way the compiler and linker are invoked. Valid values:",
+ " separate (default), allAtOnce"
+ ]);
}
protected void setupPackage(Dub dub, string package_name)
@@ -522,6 +527,7 @@
gensettings.platform = m_buildPlatform;
gensettings.config = m_buildConfig.length ? m_buildConfig : m_defaultConfig;
gensettings.buildType = m_buildType;
+ gensettings.buildMode = m_buildMode;
gensettings.compiler = m_compiler;
gensettings.buildSettings = m_buildSettings;
gensettings.combined = m_combined;
@@ -627,6 +633,8 @@
`run the unit tests.`
];
this.acceptsAppArgs = true;
+
+ m_buildType = "unittest";
}
override void prepare(scope CommandArgs args)
@@ -654,7 +662,8 @@
GeneratorSettings settings;
settings.platform = m_buildPlatform;
settings.compiler = getCompiler(m_buildPlatform.compilerBinary);
- settings.buildType = "unittest";
+ settings.buildType = m_buildType;
+ settings.buildMode = m_buildMode;
settings.buildSettings = m_buildSettings;
settings.combined = m_combined;
settings.force = m_force;
diff --git a/source/dub/generators/build.d b/source/dub/generators/build.d
index 06545d5..1d4bfbb 100644
--- a/source/dub/generators/build.d
+++ b/source/dub/generators/build.d
@@ -351,7 +351,7 @@
on the other compilers. Later this should be integrated somehow in the build process
(either in the package.json, or using a command line flag)
*/
- if (settings.platform.compilerBinary != "dmd" || !generate_binary || is_static_library) {
+ if (settings.buildMode == BuildMode.allAtOnce || settings.platform.compilerBinary != "dmd" || !generate_binary || is_static_library) {
// setup for command line
if (generate_binary) settings.compiler.setTarget(buildsettings, settings.platform);
settings.compiler.prepareBuildSettings(buildsettings, BuildSetting.commandLine);
diff --git a/source/dub/generators/generator.d b/source/dub/generators/generator.d
index 11968da..783bc13 100644
--- a/source/dub/generators/generator.d
+++ b/source/dub/generators/generator.d
@@ -100,12 +100,11 @@
}
}
if (tt != TargetType.none && tt != TargetType.sourceLibrary && shallowbs.sourceFiles.empty) {
- logWarn(`Package %s contains no source files. Please add {"targetType": "none"} to it's package description to avoid building it.`,
- pack.name);
+ logWarn(`Configuration '%s' of package %s contains no source files. Please add {"targetType": "none"} to it's package description to avoid building it.`,
+ configs[pack.name], pack.name);
tt = TargetType.none;
}
-
shallowbs.targetType = tt;
bool generates_binary = tt != TargetType.sourceLibrary && tt != TargetType.none;
@@ -203,6 +202,7 @@
string config;
string buildType;
BuildSettings buildSettings;
+ BuildMode buildMode = BuildMode.separate;
bool combined; // compile all in one go instead of each dependency separately
@@ -216,6 +216,19 @@
/**
+ Determines the mode in which the compiler and linker are invoked.
+*/
+enum BuildMode {
+ separate, /// Compile and link separately
+ allAtOnce, /// Perform compile and link with a single compiler invocation
+ //singleFile, /// Compile each file separately
+ //multipleObjects, /// Generate an object file per module
+ //multipleObjectsPerModule, /// Use the -multiobj switch to generate multiple object files per module
+ //compileOnly /// Do not invoke the linker (can be done using a post build command)
+}
+
+
+/**
Creates a project generator of the given type for the specified project.
*/
ProjectGenerator createProjectGenerator(string generator_type, Project app, PackageManager mgr)
diff --git a/source/dub/generators/visuald.d b/source/dub/generators/visuald.d
index 75ac0a8..2afa06a 100644
--- a/source/dub/generators/visuald.d
+++ b/source/dub/generators/visuald.d
@@ -330,7 +330,14 @@
ret.put(" 0\n");
ret.put(" 0\n");
ret.put(" 0\n");
- ret.put(" 2\n");
+ int singlefilemode;
+ final switch (settings.buildMode) with (BuildMode) {
+ case separate: singlefilemode = 2; break;
+ case allAtOnce: singlefilemode = 0; break;
+ //case singleFile: singlefilemode = 1; break;
+ //case compileOnly: singlefilemode = 3; break;
+ }
+ ret.formattedWrite(" %s\n");
ret.put(" 0\n");
ret.put(" 0\n");
ret.put(" 0\n");