Skip to content

Commit

Permalink
Windows: java launcher no longer calls cmd.exe
Browse files Browse the repository at this point in the history
See bazelbuild#2190

Closes bazelbuild#5005.

Change-Id: If665af264a23be0219c75ae087dd25db74d5e386
PiperOrigin-RevId: 192575414
  • Loading branch information
laszlocsomor authored and Copybara-Service committed Apr 12, 2018
1 parent 0c9f2d4 commit e02a00f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
14 changes: 4 additions & 10 deletions src/tools/launcher/java_launcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,20 +185,14 @@ string JavaBinaryLauncher::CreateClasspathJar(const string& classpath) {
jar_manifest_file.close();

// Create the command for generating classpath jar.
// We pass the command to cmd.exe to use redirection for suppressing output.
string manifest_jar_path = binary_base_path + rand_id + "-classpath.jar";
string jar_bin = this->Rlocation(this->GetLaunchInfoByKey(JAR_BIN_PATH));
vector<string> arguments;
arguments.push_back("/c");
arguments.push_back("cvfm");
arguments.push_back(manifest_jar_path);
arguments.push_back(jar_manifest_file_path);

ostringstream jar_command;
jar_command << jar_bin << " cvfm ";
jar_command << manifest_jar_path << " ";
jar_command << jar_manifest_file_path << " ";
jar_command << "> nul";
arguments.push_back(jar_command.str());

if (this->LaunchProcess("cmd.exe", arguments) != 0) {
if (this->LaunchProcess(jar_bin, arguments, /* suppressOutput */ true) != 0) {
die("Couldn't create classpath jar: %s", manifest_jar_path.c_str());
}

Expand Down
9 changes: 6 additions & 3 deletions src/tools/launcher/launcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ bool BinaryLauncherBase::PrintLauncherCommandLine(
return has_print_cmd_flag;
}

ExitCode BinaryLauncherBase::LaunchProcess(
const string& executable, const vector<string>& arguments) const {
ExitCode BinaryLauncherBase::LaunchProcess(const string& executable,
const vector<string>& arguments,
bool suppressOutput) const {
if (PrintLauncherCommandLine(executable, arguments)) {
return 0;
}
Expand All @@ -194,7 +195,9 @@ ExitCode BinaryLauncherBase::LaunchProcess(
/* lpProcessAttributes */ NULL,
/* lpThreadAttributes */ NULL,
/* bInheritHandles */ FALSE,
/* dwCreationFlags */ 0,
/* dwCreationFlags */
suppressOutput ? CREATE_NO_WINDOW // no console window => no output
: 0,
/* lpEnvironment */ NULL,
/* lpCurrentDirectory */ NULL,
/* lpStartupInfo */ &startupInfo,
Expand Down
3 changes: 2 additions & 1 deletion src/tools/launcher/launcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ class BinaryLauncherBase {
// it doesn't include the exectuable itself.
// The arguments are expected to be quoted if having spaces.
ExitCode LaunchProcess(const std::string& executable,
const std::vector<std::string>& arguments) const;
const std::vector<std::string>& arguments,
bool suppressOutput = false) const;

// A launch function to be implemented for a specific language.
virtual ExitCode Launch() = 0;
Expand Down

0 comments on commit e02a00f

Please sign in to comment.