diff --git a/source/dub/compilers/gdc.d b/source/dub/compilers/gdc.d index 59f55dc..d83758c 100644 --- a/source/dub/compilers/gdc.d +++ b/source/dub/compilers/gdc.d @@ -150,7 +150,7 @@ void invoke(in BuildSettings settings, in BuildPlatform platform) { auto res_file = getTempDir() ~ ("dub-build-"~uniform(0, uint.max).to!string~"-.rsp"); - std.file.write(res_file.toNativeString(), join(settings.dflags.map!(s => s.canFind(' ') ? "\""~s~"\"" : s), "\n")); + std.file.write(res_file.toNativeString(), join(settings.dflags.map!(s => escape(s)), "\n")); scope (exit) remove(res_file.toNativeString()); logDiagnostic("%s %s", platform.compilerBinary, join(cast(string[])settings.dflags, " ")); @@ -164,3 +164,16 @@ assert(false, "Separate linking not implemented for GDC"); } } + +private string escape(string str) +{ + auto ret = appender!string(); + foreach (char ch; str) { + switch (ch) { + default: ret.put(ch); break; + case '\\': ret.put(`\\`); break; + case ' ': ret.put(`\ `); break; + } + } + return ret.data; +} \ No newline at end of file