From dbb06eac9bae1b8dbc50275b66c975da09b1d09a Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 25 Sep 2018 23:22:08 +0200 Subject: Fix build with msvc (windows) Fix freeze when sub process (exec) returns a lot of data (in stdout) --- backend/ninja/Ninja.cpp | 59 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 14 deletions(-) (limited to 'backend') diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp index 9220593..05bb16d 100644 --- a/backend/ninja/Ninja.cpp +++ b/backend/ninja/Ninja.cpp @@ -747,7 +747,7 @@ namespace backend } globalIncDir += dependencyExportIncludeDirs; - globalIncDir += TINYDIR_STRING(" ") + getIncludeOptionFlag(config.getCompiler(), toUtf8(generatedHeadersDir)); + globalIncDir += " " + getIncludeOptionFlag(config.getCompiler(), toUtf8(generatedHeadersDir)); ninjaBuildFile.defineGlobalVariable("globalIncDir", globalIncDir); // TODO: Find a better way to convert includes, this could be slow... ninjaBuildFile.defineGlobalVariable("globalIncDirZig", convertCIncludeSyntaxToZigInclude(config.getCompiler(), globalIncDir)); @@ -774,10 +774,10 @@ namespace backend { // TODO: Executable type does not guarantee the executable should be a console on windows. Find a way to define window type as well case LibraryType::EXECUTABLE: - defines.push_back(ninja::NinjaArg(" _CONSOLE")); + defines.push_back(ninja::NinjaArg::createRaw(" _CONSOLE")); break; case LibraryType::STATIC: - defines.push_back(ninja::NinjaArg(" _LIB")); + defines.push_back(ninja::NinjaArg::createRaw(" _LIB")); break; } } @@ -825,15 +825,15 @@ namespace backend compileCCommand.insert(compileCCommand.end(), baseCompileCArgs.begin(), baseCompileCArgs.end()); compileCCommand.insert(compileCCommand.end(), { - ninja::NinjaArg("-fdiagnostics-show-option"), - ninja::NinjaArg("-fdiagnostics-color=always"), - ninja::NinjaArg("-pipe"), - ninja::NinjaArg("-D_FILE_OFFSET_BITS=64"), - ninja::NinjaArg("-Winvalid-pch"), - ninja::NinjaArg("-fstack-protector"), - ninja::NinjaArg("-MMD"), + ninja::NinjaArg::createRaw("-fdiagnostics-show-option"), + ninja::NinjaArg::createRaw("-fdiagnostics-color=always"), + ninja::NinjaArg::createRaw("-pipe"), + ninja::NinjaArg::createRaw("-D_FILE_OFFSET_BITS=64"), + ninja::NinjaArg::createRaw("-Winvalid-pch"), + ninja::NinjaArg::createRaw("-fstack-protector"), + ninja::NinjaArg::createRaw("-MMD"), ninja::NinjaArg("-I" + config.getPackageName() + "@exe"), - ninja::NinjaArg("$globalIncDir") + ninja::NinjaArg::createRaw("$globalIncDir") }); compileCCommand.insert(compileCCommand.end(), cflags.begin(), cflags.end()); @@ -872,7 +872,8 @@ namespace backend ninja::NinjaArg::createRaw("cl.exe /showIncludes"), ninja::NinjaArg::createRaw("/c"), ninja::NinjaArg::createRaw("$in"), - ninja::NinjaArg::createRaw("/Fo$out") + ninja::NinjaArg::createRaw("/Fo$out"), + ninja::NinjaArg::createRaw("$globalIncDir") }); compileCCommand.insert(compileCCommand.end(), cflags.begin(), cflags.end()); @@ -1101,7 +1102,7 @@ namespace backend buildExeArgs.insert(buildExeArgs.end(), zigLibraryFlags.begin(), zigLibraryFlags.end()); ninja::NinjaRule *buildExeRule = ninjaBuildFile.createRule("build_exec", buildExeArgs); - buildExeRule->build(objectNames, config.getPackageName(), { zigObjectArgsValue }); + buildExeRule->build(objectNames, OS_FAMILY == OS_FAMILY_POSIX ? config.getPackageName() : config.getPackageName() + ".exe", { zigObjectArgsValue }); } else { @@ -1151,6 +1152,16 @@ namespace backend ninja::NinjaArg::createRaw("GlU32.lib"), ninja::NinjaArg::createRaw("Shell32.lib") }); + + switch (SYSTEM_PLATFORM) + { + case PLATFORM_WIN32: + buildExeArgs.push_back(ninja::NinjaArg::createRaw("/MACHINE:X86")); + break; + case PLATFORM_WIN64: + buildExeArgs.push_back(ninja::NinjaArg::createRaw("/MACHINE:X64")); + break; + } break; } } @@ -1159,7 +1170,7 @@ namespace backend buildExeArgs.push_back(ninja::NinjaArg::createRaw(allLinkerFlags)); ninja::NinjaRule *buildExeRule = ninjaBuildFile.createRule("build_exec", buildExeArgs); - buildExeRule->build(objectNames, config.getPackageName(), {}); + buildExeRule->build(objectNames, config.getPackageName() + ".exe", {}); } projectGeneratedBinary += config.getPackageName(); @@ -1221,6 +1232,16 @@ namespace backend ninja::NinjaArg::createRaw("/OUT:$out"), ninja::NinjaArg::createRaw("$in") }); + + switch (SYSTEM_PLATFORM) + { + case PLATFORM_WIN32: + buildStaticArgs.push_back(ninja::NinjaArg::createRaw("/MACHINE:X86")); + break; + case PLATFORM_WIN64: + buildStaticArgs.push_back(ninja::NinjaArg::createRaw("/MACHINE:X64")); + break; + } break; } } @@ -1318,6 +1339,16 @@ namespace backend ninja::NinjaArg::createRaw("GlU32.lib"), ninja::NinjaArg::createRaw("Shell32.lib") }); + + switch (SYSTEM_PLATFORM) + { + case PLATFORM_WIN32: + buildDynamicArgs.push_back(ninja::NinjaArg::createRaw("/MACHINE:X86")); + break; + case PLATFORM_WIN64: + buildDynamicArgs.push_back(ninja::NinjaArg::createRaw("/MACHINE:X64")); + break; + } break; } } -- cgit v1.2.3