Browse Source

Merge pull request #168 from programmerTim/develop

Serpent compilation working on Windows (with valid python installation).
cl-refactor
Gav Wood 11 years ago
parent
commit
ec272e8cf4
  1. 39
      alethzero/MainWin.cpp
  2. 2
      boost/process/detail/win32_ops.hpp

39
alethzero/MainWin.cpp

@ -116,28 +116,43 @@ string findSerpent()
bytes compileSerpent(string const& _code)
{
static const string exec = findSerpent();
if (exec.empty())
static const string serpent = findSerpent();
if (serpent.empty())
return bytes();
#ifdef _WIN32
vector<string> args = vector<string>({"python", serpent, "-b", "compile"});
string exec = "";
#else
vector<string> args = vector<string>({"serpent_cli.py", "-b", "compile"});
string exec = serpent;
#endif
context ctx;
ctx.environment = self::get_environment();
ctx.stdin_behavior = capture_stream();
ctx.stdout_behavior = capture_stream();
child c = launch(exec, args, ctx);
postream& os = c.get_stdin();
pistream& is = c.get_stdout();
try
{
child c = launch(exec, args, ctx);
postream& os = c.get_stdin();
pistream& is = c.get_stdout();
os << _code << "\n";
os.close();
os << _code << "\n";
os.close();
string hex;
int i;
while ((i = is.get()) != -1 && i != '\n')
hex.push_back(i);
string hex;
int i;
while ((i = is.get()) != -1 && i != '\r' && i != '\n')
hex.push_back(i);
return fromHex(hex);
return fromHex(hex);
}
catch (boost::system::system_error&)
{
cwarn << "Serpent compiler failed to launch.";
return bytes();
}
}
Main::Main(QWidget *parent) :

2
boost/process/detail/win32_ops.hpp

@ -342,7 +342,7 @@ inline PROCESS_INFORMATION win32_start(const Executable &exe, const Arguments &a
boost::shared_array<char> envstrs = environment_to_win32_strings(env);
if (!::CreateProcessA(executable.get(), cmdline.get(), NULL, NULL, TRUE, 0, envstrs.get(), workdir.get(), si.get(), &pi))
if (!::CreateProcessA(executable.get()[0] ? executable.get() : NULL, cmdline.get(), NULL, NULL, TRUE, CREATE_NO_WINDOW, envstrs.get(), workdir.get(), si.get(), &pi))
boost::throw_exception(boost::system::system_error(boost::system::error_code(::GetLastError(), boost::system::get_system_category()), "boost::process::detail::win32_start: CreateProcess failed"));
return pi;

Loading…
Cancel
Save