Add NMake.

This commit is contained in:
Mikaël Capelle
2023-07-02 14:03:38 +02:00
parent cc5e49ba5c
commit f0fdead031
6 changed files with 137 additions and 0 deletions
+1
View File
@@ -62,6 +62,7 @@ cmake = cmake.exe
perl = perl.exe
devenv = devenv.exe
msbuild = msbuild.exe
nmake = nmake.exe
nuget = nuget.exe
vswhere = vswhere.exe
nasm = nasm.exe
+82
View File
@@ -0,0 +1,82 @@
#include "pch.h"
#include "tools.h"
#include "../core/conf.h"
#include "../core/process.h"
namespace mob
{
nmake::nmake()
: basic_process_runner("nmake"), arch_(arch::def)
{
}
fs::path nmake::binary()
{
return conf().tool().get("nmake");
}
nmake& nmake::path(const fs::path& p)
{
cwd_ = p;
return *this;
}
nmake& nmake::target(const std::string& s)
{
target_ = s;
return *this;
}
nmake& nmake::def(const std::string& s)
{
def_.push_back(s);
return *this;
}
nmake& nmake::architecture(arch a)
{
arch_ = a;
return *this;
}
int nmake::result() const
{
return exit_code();
}
void nmake::do_run()
{
process p;
p
.binary(binary())
.cwd(cwd_)
.stderr_filter([](process::filter& f)
{
// initial log line, can't get rid of it, /L or /NOLOGO don't seem
// to work
if (f.line.find("Microsoft (R) Macro Assembler (x64)") != std::string::npos)
f.lv = context::level::trace;
if (f.line.find("Copyright (C) Microsoft Corporation.") != std::string::npos)
f.lv = context::level::trace;
})
.arg("/C", process::log_quiet) // silent
.arg("/S", process::log_quiet) // silent
.arg("/L", process::log_quiet) // silent, nmake likes to spew crap
.arg("/D", process::log_dump) // verbose stuff
.arg("/P", process::log_dump) // verbose stuff
.arg("/W", process::log_dump) // verbose stuff
.arg("/K"); // don't stop on errors
for (auto&& def : def_)
p.arg(def);
p
.arg(target_)
.env(env::vs(arch_));
execute_and_join(p);
}
} // namespace
+50
View File
@@ -458,6 +458,56 @@ private:
void do_patch(const fs::path& patch_file);
};
// tool that runs `nmake`
//
class nmake : public basic_process_runner
{
public:
// path to the job binary
//
static fs::path binary();
nmake();
// path in which to invoke nmake
//
nmake& path(const fs::path& p);
// makefile target
//
nmake& target(const std::string& s);
// adds a macro definition as "NAME=value"
//
nmake& def(const std::string& s);
// sets the architecture used to run nmake, used to get the appropriate
// VS environment variables, defaults to arch::def
//
nmake& architecture(arch a);
// nmake's exit code
//
int result() const;
protected:
// runs nmake
//
void do_run() override;
private:
// set in path()
fs::path cwd_;
// set in def(), just plain arguments
std::vector<std::string> def_;
// set in target(), another plain argument
std::string target_;
// set in architecture()
arch arch_;
};
// tool that runs `jom`, an alternative to `nmake` that supports parallel
// builds, bundled with mob in third-party/bin
+1
View File
@@ -116,6 +116,7 @@
<ClCompile Include="..\src\tools\git.cpp" />
<ClCompile Include="..\src\tools\jom.cpp" />
<ClCompile Include="..\src\tools\msbuild.cpp" />
<ClCompile Include="..\src\tools\nmake.cpp" />
<ClCompile Include="..\src\tools\patcher.cpp" />
<ClCompile Include="..\src\tools\process_runner.cpp" />
<ClCompile Include="..\src\tools\python.cpp" />
+3
View File
@@ -204,6 +204,9 @@
<ClCompile Include="..\src\tasks\pybind11.cpp">
<Filter>src\tasks</Filter>
</ClCompile>
<ClCompile Include="..\src\tools\nmake.cpp">
<Filter>src\tools</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\pch.h">
View File