aboutsummaryrefslogtreecommitdiff
path: root/backend/ninja
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-09-25 23:22:08 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:39:33 +0200
commitdbb06eac9bae1b8dbc50275b66c975da09b1d09a (patch)
tree4cfa3cc326a11aa8cd8b7ff83d8afb1b2754f150 /backend/ninja
parentc4d1491af938a12a0167dae4fd3ea8f1810c752a (diff)
Fix build with msvc (windows)
Fix freeze when sub process (exec) returns a lot of data (in stdout)
Diffstat (limited to 'backend/ninja')
-rw-r--r--backend/ninja/Ninja.cpp59
1 files changed, 45 insertions, 14 deletions
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;
}
}