Skip to content

Commit

Permalink
Move declare_executable to phase file (bazelbuild#919)
Browse files Browse the repository at this point in the history
  • Loading branch information
borkaehw authored and Andre Rocha committed Jul 6, 2020
1 parent b174bfb commit 501e769
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
7 changes: 5 additions & 2 deletions scala/private/phases/phase_declare_executable.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
#
load(
"@io_bazel_rules_scala//scala/private:rule_impls.bzl",
"declare_executable",
"is_windows",
)

def phase_declare_executable(ctx, p):
return declare_executable(ctx)
if (is_windows(ctx)):
return ctx.actions.declare_file("%s.exe" % ctx.label.name)
else:
return ctx.actions.declare_file(ctx.label.name)
10 changes: 2 additions & 8 deletions scala/private/rule_impls.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ def _jar_path_based_on_java_bin(ctx):
return jar_path

def write_executable(ctx, executable, rjars, main_class, jvm_flags, wrapper, use_jacoco):
if (_is_windows(ctx)):
if (is_windows(ctx)):
return write_executable_windows(ctx, executable, rjars, main_class, jvm_flags, wrapper, use_jacoco)
else:
return write_executable_non_windows(ctx, executable, rjars, main_class, jvm_flags, wrapper, use_jacoco)
Expand Down Expand Up @@ -737,12 +737,6 @@ def write_executable_non_windows(ctx, executable, rjars, main_class, jvm_flags,
)
return []

def declare_executable(ctx):
if (_is_windows(ctx)):
return ctx.actions.declare_file("%s.exe" % ctx.label.name)
else:
return ctx.actions.declare_file(ctx.label.name)

def _collect_runtime_jars(dep_targets):
runtime_jars = []

Expand Down Expand Up @@ -890,5 +884,5 @@ def _jacoco_offline_instrument(ctx, input_jar):
def _jacoco_offline_instrument_format_each(in_out_pair):
return (["%s=%s" % (in_out_pair[0].path, in_out_pair[1].path)])

def _is_windows(ctx):
def is_windows(ctx):
return ctx.configuration.host_path_separator == ";"

0 comments on commit 501e769

Please sign in to comment.