public static void ConstructClangCommandLine(CreateCompileCommand export, out string command, out string commandArguments) { bool isDebug = IsDebug(export.Configuration); bool is64Bit = Is64BitTarget(export.Architecture); // Create arguments var compilerFlags = new StringBuilder(); SetConfigurationBasedFlags(isDebug, ref compilerFlags); // Set compiler flags compilerFlags.Append($"-shared -fpic "); compilerFlags.Append($"-D DNNE_ASSEMBLY_NAME={export.AssemblyName} -D DNNE_COMPILE_AS_SOURCE "); compilerFlags.Append($"-I \"{export.PlatformPath}\" -I \"{export.NetHostPath}\" "); compilerFlags.Append($"-o \"{Path.Combine(export.OutputPath, export.OutputName)}\" "); compilerFlags.Append($"\"{export.Source}\" \"{Path.Combine(export.PlatformPath, "platform.c")}\" "); compilerFlags.Append($"-lstdc++ "); compilerFlags.Append($"\"{Path.Combine(export.NetHostPath, "libnethost.a")}\" "); command = "clang"; commandArguments = compilerFlags.ToString(); }
public static void ConstructCommandLine(CreateCompileCommand export, out string command, out string commandArguments) { export.Report(MessageImportance.Low, $"Building for macOS"); ConstructClangCommandLine(export, out command, out commandArguments); }
public static void ConstructCommandLine(CreateCompileCommand export, out string command, out string commandArguments) { export.Report(MessageImportance.Low, $"Building for Windows"); WinSDK winSdk = g_WinSdk.Value; string vsInstall = g_VsInstallPath.Value; string vcToolDir = GetVCToolsRootDir(vsInstall); export.Report(CreateCompileCommand.DevImportance, $"VS Install: {vsInstall}\nVC Tools: {vcToolDir}\nWinSDK Version: {winSdk.Version}"); bool isDebug = IsDebug(export.Configuration); bool is64Bit = Is64BitTarget(export.Architecture, export.RuntimeID); var archDir = is64Bit ? "x64" : "x86"; // VC inc and lib paths var vcIncDir = Path.Combine(vcToolDir, "include"); var libDir = Path.Combine(vcToolDir, "lib", archDir); // For now we assume building always happens on a x64 machine. var binDir = Path.Combine(vcToolDir, "bin\\Hostx64", archDir); // Create arguments var compilerFlags = new StringBuilder(); var linkerFlags = new StringBuilder(); SetConfigurationBasedFlags(isDebug, ref compilerFlags, ref linkerFlags); // Set compiler flags compilerFlags.Append($"/TC /MT /GS /Zi "); compilerFlags.Append($"/D DNNE_ASSEMBLY_NAME={export.AssemblyName} /D DNNE_COMPILE_AS_SOURCE "); compilerFlags.Append($"/I \"{vcIncDir}\" /I \"{export.PlatformPath}\" /I \"{export.NetHostPath}\" "); // Add WinSDK inc paths foreach (var incPath in winSdk.IncPaths) { compilerFlags.Append($"/I \"{incPath}\" "); } // Add user defined inc paths last - these will be searched last on MSVC. // https://docs.microsoft.com/cpp/build/reference/i-additional-include-directories#remarks foreach (var incPath in export.SafeAdditionalIncludeDirectories) { compilerFlags.Append($"/I \"{incPath.ItemSpec}\" "); } compilerFlags.Append($"\"{export.Source}\" \"{Path.Combine(export.PlatformPath, "platform.c")}\" "); // Set linker flags linkerFlags.Append($"/DLL "); linkerFlags.Append($"/LIBPATH:\"{libDir}\" "); // Add WinSDK lib paths foreach (var libPath in winSdk.LibPaths) { linkerFlags.Append($"/LIBPATH:\"{Path.Combine(libPath, archDir)}\" "); } linkerFlags.Append($"\"{Path.Combine(export.NetHostPath, "libnethost.lib")}\" Advapi32.lib "); linkerFlags.Append($"/IGNORE:4099 "); // libnethost.lib doesn't ship PDBs so linker warnings occur. // Define artifact names var outputPath = Path.Combine(export.OutputPath, export.OutputName); var impLibPath = Path.ChangeExtension(outputPath, ".lib"); linkerFlags.Append($"/IMPLIB:\"{impLibPath}\" /OUT:\"{outputPath}\" "); command = Path.Combine(binDir, "cl.exe"); commandArguments = $"{compilerFlags} /link {linkerFlags}"; }