diff --git a/source/dub/compilers/compiler.d b/source/dub/compilers/compiler.d index 5619b5b..4d64589 100644 --- a/source/dub/compilers/compiler.d +++ b/source/dub/compilers/compiler.d @@ -359,6 +359,7 @@ } } +/// Generate a file that will give, at compile time, informations about the compiler (architecture, frontend version...) Path generatePlatformProbeFile() { import dub.internal.vibecompat.core.file; @@ -374,25 +375,25 @@ } fil.write(q{ - import std.array; - import std.stdio; + import std.array, std.conv; void main() { - writeln(`{`); - writefln(` "compiler": "%s",`, determineCompiler()); - writefln(` "frontendVersion": %s,`, __VERSION__); - writefln(` "compilerVendor": "%s",`, __VENDOR__); - writefln(` "platform": [`); - foreach (p; determinePlatform()) writefln(` "%s",`, p); - writefln(` ],`); - writefln(` "architecture": [`); - foreach (p; determineArchitecture()) writefln(` "%s",`, p); - writefln(` ],`); - writeln(`}`); + pragma(msg, `{`); + pragma(msg,` "compiler": "`~ determineCompiler() ~ `",`); + pragma(msg, ` "frontendVersion": ` ~ to!string(__VERSION__) ~ `,`); + pragma(msg, ` "compilerVendor": "` ~ __VENDOR__ ~ `",`); + pragma(msg, ` "platform": [`); + pragma(msg, ` ` ~ determinePlatform()); + pragma(msg, ` ],`); + pragma(msg, ` "architecture": [`); + pragma(msg, ` ` ~ determineArchitecture()); + pragma(msg, ` ],`); + pragma(msg, `}`); } - string[] determinePlatform() + + string determinePlatform() { auto ret = appender!(string[])(); version(Windows) ret.put("windows"); @@ -414,10 +415,11 @@ version(Android) ret.put("android"); version(Cygwin) ret.put("cygwin"); version(MinGW) ret.put("mingw"); - return ret.data; + foreach(ref str; ret.data) str = `"` ~ str ~ `"`; + return ret.data.join(",\n "); } - string[] determineArchitecture() + string determineArchitecture() { auto ret = appender!(string[])(); version(X86) ret.put("x86"); @@ -457,7 +459,8 @@ version(Alpha) ret.put("alpha"); version(Alpha_SoftFP) ret.put("alpha_softfp"); version(Alpha_HardFP) ret.put("alpha_hardfp"); - return ret.data; + foreach(ref str; ret.data) str = `"` ~ str ~ `"`; + return ret.data.join(",\n "); } string determineCompiler() diff --git a/source/dub/compilers/dmd.d b/source/dub/compilers/dmd.d index e189542..10dba58 100644 --- a/source/dub/compilers/dmd.d +++ b/source/dub/compilers/dmd.d @@ -67,7 +67,8 @@ } settings.addDFlags(arch_flags); - auto result = executeShell(escapeShellCommand(compiler_binary ~ arch_flags ~ ["-quiet", "-run", fil.toNativeString()])); + auto result = executeShell(escapeShellCommand(compiler_binary ~ arch_flags ~ ["-quiet", "-od"~getTempDir.toNativeString(), + "-of"~(getTempDir~"dub_platform_probe").toNativeString(), fil.toNativeString()])); enforce(result.status == 0, format("Failed to invoke the compiler %s to determine the build platform: %s", compiler_binary, result.output)); diff --git a/source/dub/compilers/gdc.d b/source/dub/compilers/gdc.d index fbf2102..ac59d50 100644 --- a/source/dub/compilers/gdc.d +++ b/source/dub/compilers/gdc.d @@ -67,12 +67,9 @@ } settings.addDFlags(arch_flags); - auto compiler_result = executeShell(escapeShellCommand(compiler_binary ~ arch_flags ~ ["-o", (getTempDir()~"dub_platform_probe").toNativeString(), fil.toNativeString()])); - enforce(compiler_result.status == 0, format("Failed to invoke the compiler %s to determine the build platform: %s", - compiler_binary, compiler_result.output)); - auto result = execute([(getTempDir()~"dub_platform_probe").toNativeString()]); - enforce(result.status == 0, format("Failed to invoke the build platform probe: %s", - result.output)); + auto result = executeShell(escapeShellCommand(compiler_binary ~ arch_flags ~ ["-o", (getTempDir()~"dub_platform_probe").toNativeString(), fil.toNativeString()])); + enforce(result.status == 0, format("Failed to invoke the compiler %s to determine the build platform: %s", + compiler_binary, result.output)); auto build_platform = readPlatformProbe(result.output); build_platform.compilerBinary = compiler_binary;