diff --git a/source/dub/compilers/buildsettings.d b/source/dub/compilers/buildsettings.d index f64362f..52089b5 100644 --- a/source/dub/compilers/buildsettings.d +++ b/source/dub/compilers/buildsettings.d @@ -185,7 +185,8 @@ library, sourceLibrary, dynamicLibrary, - staticLibrary + staticLibrary, + object } enum BuildRequirements { diff --git a/source/dub/compilers/compiler.d b/source/dub/compilers/compiler.d index 14ce05d..2acc298 100644 --- a/source/dub/compilers/compiler.d +++ b/source/dub/compilers/compiler.d @@ -366,6 +366,10 @@ if( platform.platform.canFind("windows") ) return settings.targetName ~ ".dll"; else return "lib" ~ settings.targetName ~ ".so"; + case TargetType.object: + if (platform.platform.canFind("windows")) + return settings.targetName ~ ".obj"; + else return settings.targetName ~ ".o"; } } diff --git a/source/dub/compilers/dmd.d b/source/dub/compilers/dmd.d index 810c06b..599f809 100644 --- a/source/dub/compilers/dmd.d +++ b/source/dub/compilers/dmd.d @@ -169,6 +169,9 @@ version (Windows) settings.addDFlags("-shared"); else settings.addDFlags("-shared", "-fPIC"); break; + case TargetType.object: + settings.addDFlags("-c"); + break; } if (tpath is null) @@ -189,14 +192,18 @@ { import std.string; auto tpath = Path(settings.targetPath) ~ getTargetFileName(settings, platform); - auto args = [platform.compilerBinary, "-of"~tpath.toNativeString()]; + auto args = ["-of"~tpath.toNativeString()]; args ~= objects; args ~= settings.sourceFiles; version(linux) args ~= "-L--no-as-needed"; // avoids linker errors due to libraries being speficied in the wrong order by DMD args ~= settings.lflags.map!(l => "-L"~l)().array; args ~= settings.dflags.filter!(f => isLinkerDFlag(f)).array; - logDiagnostic("%s", args.join(" ")); - invokeTool(args, output_callback); + + auto res_file = getTempFile("dub-build", ".lnk"); + std.file.write(res_file.toNativeString(), join(args, "\n")); + + logDiagnostic("%s %s", platform.compilerBinary, args.join(" ")); + invokeTool([platform.compilerBinary, "@"~res_file.toNativeString()], output_callback); } private static bool isLinkerDFlag(string arg) diff --git a/source/dub/compilers/gdc.d b/source/dub/compilers/gdc.d index 90bdcea..a82339c 100644 --- a/source/dub/compilers/gdc.d +++ b/source/dub/compilers/gdc.d @@ -167,6 +167,7 @@ case TargetType.executable: break; case TargetType.library: case TargetType.staticLibrary: + case TargetType.object: settings.addDFlags("-c"); break; case TargetType.dynamicLibrary: diff --git a/source/dub/compilers/ldc.d b/source/dub/compilers/ldc.d index fb214dd..32a4520 100644 --- a/source/dub/compilers/ldc.d +++ b/source/dub/compilers/ldc.d @@ -157,6 +157,9 @@ case TargetType.dynamicLibrary: settings.addDFlags("-shared"); break; + case TargetType.object: + settings.addDFlags("-c"); + break; } if (tpath is null) diff --git a/source/dub/generators/build.d b/source/dub/generators/build.d index cc826ad..685b34c 100644 --- a/source/dub/generators/build.d +++ b/source/dub/generators/build.d @@ -350,15 +350,20 @@ /// Output an unique name to represent the source file. /// Calls with path that resolve to the same file on the filesystem will return the same, /// unless they include different symbolic links (which are not resolved). - static string pathToObjName(string path) { return std.path.buildNormalizedPath(getcwd(), path~objSuffix)[1..$].replace("/", "."); } + + static string pathToObjName(string path) + { + return std.path.stripDrive(std.path.buildNormalizedPath(getcwd(), path~objSuffix))[1..$].replace(std.path.dirSeparator, "."); + } + /// Compile a single source file (srcFile), and write the object to objName. static string compileUnit(string srcFile, string objName, BuildSettings bs, GeneratorSettings gs) { Path tempobj = Path(bs.targetPath)~objName; string objPath = tempobj.toNativeString(); bs.libs = null; bs.lflags = null; - bs.addDFlags("-c"); bs.sourceFiles = [ srcFile ]; + bs.targetType = TargetType.object; gs.compiler.prepareBuildSettings(bs, BuildSetting.commandLine); gs.compiler.setTarget(bs, gs.platform, objPath); gs.compiler.invoke(bs, gs.platform, gs.compileCallback);