diff --git a/source/dub/commandline.d b/source/dub/commandline.d index 69475a5..d75b235 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -457,6 +457,7 @@ protected { string m_generator; bool m_rdmd = false; + bool m_tempBuild = false; bool m_run = false; bool m_force = false; bool m_combined = false; @@ -538,6 +539,7 @@ gensettings.runArgs = app_args; gensettings.force = m_force; gensettings.rdmd = m_rdmd; + gensettings.tempBuild = m_tempBuild; logDiagnostic("Generating using %s", m_generator); if (m_generator == "visuald-combined") { @@ -567,6 +569,7 @@ args.getopt("rdmd", &m_rdmd, [ "Use rdmd instead of directly invoking the compiler" ]); + args.getopt("f|force", &m_force, [ "Forces a recompilation even if the target is up to date" ]); @@ -594,6 +597,10 @@ override void prepare(scope CommandArgs args) { + args.getopt("temp-build", &m_tempBuild, [ + "Builds the project in the temp folder if possible." + ]); + super.prepare(args); m_run = true; } diff --git a/source/dub/generators/build.d b/source/dub/generators/build.d index 00bc4e6..50b5972 100644 --- a/source/dub/generators/build.d +++ b/source/dub/generators/build.d @@ -125,8 +125,9 @@ return true; } - if (!isWritableDir(target_path, true)) { - logInfo("Build directory %s is not writable. Falling back to direct build in the system's temp folder.", target_path.relativeTo(cwd).toNativeString()); + if (settings.tempBuild || !isWritableDir(target_path, true)) { + if (!settings.tempBuild) + logInfo("Build directory %s is not writable. Falling back to direct build in the system's temp folder.", target_path.relativeTo(cwd).toNativeString()); performDirectBuild(settings, buildsettings, pack, config); return false; } @@ -177,7 +178,7 @@ Path exe_file_path; bool tmp_target = false; if (generate_binary) { - if (settings.run && !isWritableDir(Path(buildsettings.targetPath), true)) { + if (settings.tempBuild || (settings.run && !isWritableDir(Path(buildsettings.targetPath), true))) { import std.random; auto rnd = to!string(uniform(uint.min, uint.max)) ~ "-"; auto tmpdir = getTempDir()~".rdmd/source/"; @@ -242,7 +243,7 @@ Path exe_file_path; bool is_temp_target = false; if (generate_binary) { - if (settings.run && !isWritableDir(Path(buildsettings.targetPath), true)) { + if (settings.tempBuild || (settings.run && !isWritableDir(Path(buildsettings.targetPath), true))) { import std.random; auto rnd = to!string(uniform(uint.min, uint.max)); auto tmppath = getTempDir()~("dub/"~rnd~"/"); diff --git a/source/dub/generators/generator.d b/source/dub/generators/generator.d index 0472796..723361c 100644 --- a/source/dub/generators/generator.d +++ b/source/dub/generators/generator.d @@ -208,7 +208,7 @@ bool combined; // compile all in one go instead of each dependency separately // only used for generator "build" - bool run, force, direct, clean, rdmd; + bool run, force, direct, clean, rdmd, tempBuild; string[] runArgs; void delegate(int status, string output) compileCallback; void delegate(int status, string output) linkCallback;