mirror of
https://github.com/darlinghq/xcbuild.git
synced 2025-02-22 09:22:34 +00:00
Move subprocess launcher into process library.
This commit is contained in:
parent
48ad1729dd
commit
e0ac563145
@ -13,7 +13,7 @@
|
||||
#include <libutil/Filesystem.h>
|
||||
#include <libutil/FSUtil.h>
|
||||
#include <process/Context.h>
|
||||
#include <libutil/Subprocess.h>
|
||||
#include <process/Subprocess.h>
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
@ -21,7 +21,6 @@ using builtin::copy::Driver;
|
||||
using builtin::copy::Options;
|
||||
using libutil::Filesystem;
|
||||
using libutil::FSUtil;
|
||||
using libutil::Subprocess;
|
||||
|
||||
Driver::
|
||||
Driver()
|
||||
@ -51,13 +50,13 @@ CopyPath(
|
||||
return false;
|
||||
}
|
||||
|
||||
Subprocess cp;
|
||||
process::Subprocess cp;
|
||||
if (!cp.execute(filesystem, "/bin/cp", { "-R", inputPath, outputPath }, environmentVariables, workingDirectory) || cp.exitcode() != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Should preserve permissions but make writable. */
|
||||
Subprocess chmod;
|
||||
process::Subprocess chmod;
|
||||
if (!chmod.execute(filesystem, "/bin/chmod", { "-R", "+w", outputPath }, environmentVariables, workingDirectory) || chmod.exitcode() != 0) {
|
||||
return false;
|
||||
}
|
||||
|
@ -14,8 +14,6 @@ add_library(util SHARED
|
||||
Sources/MemoryFilesystem.cpp
|
||||
Sources/Options.cpp
|
||||
#
|
||||
Sources/Subprocess.cpp
|
||||
#
|
||||
Sources/Escape.cpp
|
||||
Sources/Wildcard.cpp
|
||||
#
|
||||
|
@ -11,6 +11,7 @@ add_library(process SHARED
|
||||
Sources/Context.cpp
|
||||
Sources/DefaultContext.cpp
|
||||
Sources/MemoryContext.cpp
|
||||
Sources/Subprocess.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(process PUBLIC ext util)
|
||||
|
@ -7,16 +7,16 @@
|
||||
of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#ifndef __libutil_Subprocess_h
|
||||
#define __libutil_Subprocess_h
|
||||
#ifndef __process_Subprocess_h
|
||||
#define __process_Subprocess_h
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace libutil {
|
||||
namespace libutil { class Filesystem; }
|
||||
|
||||
class Filesystem;
|
||||
namespace process {
|
||||
|
||||
class Subprocess {
|
||||
private:
|
||||
@ -30,7 +30,7 @@ public:
|
||||
{ return _exitcode; }
|
||||
|
||||
public:
|
||||
bool execute(Filesystem *filesystem,
|
||||
bool execute(libutil::Filesystem *filesystem,
|
||||
std::string const &path,
|
||||
std::vector<std::string> const &arguments,
|
||||
std::unordered_map<std::string, std::string> const &environment,
|
||||
@ -42,4 +42,4 @@ public:
|
||||
|
||||
}
|
||||
|
||||
#endif // !__libutil_Subprocess_h
|
||||
#endif // !__process_Subprocess_h
|
@ -7,7 +7,7 @@
|
||||
of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#include <libutil/Subprocess.h>
|
||||
#include <process/Subprocess.h>
|
||||
#include <libutil/Filesystem.h>
|
||||
|
||||
#include <sstream>
|
||||
@ -15,7 +15,8 @@
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
using libutil::Subprocess;
|
||||
using process::Subprocess;
|
||||
using libutil::Filesystem;
|
||||
|
||||
Subprocess::Subprocess() :
|
||||
_exitcode(0)
|
@ -18,7 +18,7 @@
|
||||
#include <libutil/Escape.h>
|
||||
#include <libutil/Filesystem.h>
|
||||
#include <libutil/FSUtil.h>
|
||||
#include <libutil/Subprocess.h>
|
||||
#include <process/Subprocess.h>
|
||||
#include <process/Context.h>
|
||||
#include <libutil/md5.h>
|
||||
|
||||
@ -33,7 +33,6 @@ using xcexecution::Parameters;
|
||||
using libutil::Escape;
|
||||
using libutil::Filesystem;
|
||||
using libutil::FSUtil;
|
||||
using libutil::Subprocess;
|
||||
|
||||
NinjaExecutor::
|
||||
NinjaExecutor(std::shared_ptr<xcformatter::Formatter> const &formatter, bool dryRun, bool generate) :
|
||||
@ -416,7 +415,7 @@ build(
|
||||
/*
|
||||
* Run Ninja and return if it failed. Ninja itself does the build.
|
||||
*/
|
||||
Subprocess ninja;
|
||||
process::Subprocess ninja;
|
||||
if (!ninja.execute(filesystem, *executable, arguments, environmentVariables, intermediatesDirectory) || ninja.exitcode() != 0) {
|
||||
return false;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include <libutil/FSUtil.h>
|
||||
#include <process/Context.h>
|
||||
#include <process/MemoryContext.h>
|
||||
#include <libutil/Subprocess.h>
|
||||
#include <process/Subprocess.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@ -25,7 +25,6 @@
|
||||
using xcexecution::SimpleExecutor;
|
||||
using libutil::Filesystem;
|
||||
using libutil::FSUtil;
|
||||
using libutil::Subprocess;
|
||||
|
||||
SimpleExecutor::
|
||||
SimpleExecutor(std::shared_ptr<xcformatter::Formatter> const &formatter, bool dryRun, builtin::Registry const &builtins) :
|
||||
@ -264,7 +263,7 @@ performInvocations(
|
||||
}
|
||||
} else {
|
||||
/* External tool, run the tool externally. */
|
||||
Subprocess process;
|
||||
process::Subprocess process;
|
||||
if (!process.execute(filesystem, invocation.executable().path(), invocation.arguments(), invocation.environment(), invocation.workingDirectory()) || process.exitcode() != 0) {
|
||||
xcformatter::Formatter::Print(_formatter->finishInvocation(invocation, invocation.executable().displayName(), createProductStructure));
|
||||
return std::make_pair(false, std::vector<pbxbuild::Tool::Invocation>({ invocation }));
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include <libutil/Filesystem.h>
|
||||
#include <libutil/FSUtil.h>
|
||||
#include <libutil/Options.h>
|
||||
#include <libutil/Subprocess.h>
|
||||
#include <process/Subprocess.h>
|
||||
#include <process/Context.h>
|
||||
#include <process/DefaultContext.h>
|
||||
#include <pbxsetting/Type.h>
|
||||
@ -23,7 +23,6 @@
|
||||
using libutil::DefaultFilesystem;
|
||||
using libutil::Filesystem;
|
||||
using libutil::FSUtil;
|
||||
using libutil::Subprocess;
|
||||
|
||||
class Options {
|
||||
private:
|
||||
@ -437,7 +436,7 @@ static int Run(Filesystem *filesystem, process::Context const *processContext)
|
||||
if (verbose) {
|
||||
printf("verbose: executing tool: %s\n", executable->c_str());
|
||||
}
|
||||
Subprocess process;
|
||||
process::Subprocess process;
|
||||
if (!process.execute(filesystem, *executable, options.args(), environment, processContext->currentDirectory())) {
|
||||
fprintf(stderr, "error: unable to execute tool '%s'\n", options.tool()->c_str());
|
||||
return -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user