Skip to content

Commit

Permalink
Move commands struct into plaform commands files
Browse files Browse the repository at this point in the history
  • Loading branch information
jsharpe committed Feb 20, 2022
1 parent 2a80197 commit 97247cf
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 7 deletions.
8 changes: 1 addition & 7 deletions foreign_cc/private/framework/toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ toolchain(
_DEFS_BZL_CONTENT = """\
load(
"{commands_src}",
{symbols}
)
commands = struct(
{commands}
"commands"
)
def _foreign_cc_framework_toolchain_impl(ctx):
Expand All @@ -53,8 +49,6 @@ def _framework_toolchain_repository_impl(repository_ctx):

repository_ctx.file("defs.bzl", _DEFS_BZL_CONTENT.format(
commands_src = repository_ctx.attr.commands_src,
symbols = "\n ".join(["\"{}\",".format(symbol) for symbol in PLATFORM_COMMANDS.keys()]),
commands = "\n ".join(["{cmd} = {cmd},".format(cmd = symbol) for symbol in PLATFORM_COMMANDS.keys()]),
))

repository_ctx.file("BUILD.bazel", _BUILD_FILE_CONTENT.format(
Expand Down
35 changes: 35 additions & 0 deletions foreign_cc/private/framework/toolchains/freebsd_commands.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,38 @@ if [[ -L "{file}" ]]; then
rm "{file}" && cp -a "${{target}}" "{file}"
fi
""".format(file = file)

commands = struct(
assert_script_errors = assert_script_errors,
cat = cat,
children_to_path = children_to_path,
cleanup_function = cleanup_function,
copy_dir_contents_to_dir = copy_dir_contents_to_dir,
define_absolute_paths = define_absolute_paths,
define_function = define_function,
define_sandbox_paths = define_sandbox_paths,
disable_tracing = disable_tracing,
echo = echo,
enable_tracing = enable_tracing,
env = env,
export_var = export_var,
if_else = if_else,
increment_pkg_config_path = increment_pkg_config_path,
local_var = local_var,
mkdirs = mkdirs,
path = path,
pwd = pwd,
redirect_out_err = redirect_out_err,
replace_absolute_paths = replace_absolute_paths,
replace_in_files = replace_in_files,
replace_sandbox_paths = replace_sandbox_paths,
replace_symlink = replace_symlink,
rm_rf = rm_rf,
script_extension = script_extension,
script_prelude = script_prelude,
shebang = shebang,
symlink_contents_to_dir = symlink_contents_to_dir,
symlink_to_dir = symlink_to_dir,
touch = touch,
use_var = use_var,
)
35 changes: 35 additions & 0 deletions foreign_cc/private/framework/toolchains/linux_commands.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,38 @@ if [[ -L "{file}" ]]; then
rm "{file}" && cp -a "${{target}}" "{file}"
fi
""".format(file = file)

commands = struct(
assert_script_errors = assert_script_errors,
cat = cat,
children_to_path = children_to_path,
cleanup_function = cleanup_function,
copy_dir_contents_to_dir = copy_dir_contents_to_dir,
define_absolute_paths = define_absolute_paths,
define_function = define_function,
define_sandbox_paths = define_sandbox_paths,
disable_tracing = disable_tracing,
echo = echo,
enable_tracing = enable_tracing,
env = env,
export_var = export_var,
if_else = if_else,
increment_pkg_config_path = increment_pkg_config_path,
local_var = local_var,
mkdirs = mkdirs,
path = path,
pwd = pwd,
redirect_out_err = redirect_out_err,
replace_absolute_paths = replace_absolute_paths,
replace_in_files = replace_in_files,
replace_sandbox_paths = replace_sandbox_paths,
replace_symlink = replace_symlink,
rm_rf = rm_rf,
script_extension = script_extension,
script_prelude = script_prelude,
shebang = shebang,
symlink_contents_to_dir = symlink_contents_to_dir,
symlink_to_dir = symlink_to_dir,
touch = touch,
use_var = use_var,
)
35 changes: 35 additions & 0 deletions foreign_cc/private/framework/toolchains/macos_commands.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,38 @@ if [[ -L "{file}" ]]; then
rm "{file}" && cp -a "${{target}}" "{file}"
fi
""".format(file = file)

commands = struct(
assert_script_errors = assert_script_errors,
cat = cat,
children_to_path = children_to_path,
cleanup_function = cleanup_function,
copy_dir_contents_to_dir = copy_dir_contents_to_dir,
define_absolute_paths = define_absolute_paths,
define_function = define_function,
define_sandbox_paths = define_sandbox_paths,
disable_tracing = disable_tracing,
echo = echo,
enable_tracing = enable_tracing,
env = env,
export_var = export_var,
if_else = if_else,
increment_pkg_config_path = increment_pkg_config_path,
local_var = local_var,
mkdirs = mkdirs,
path = path,
pwd = pwd,
redirect_out_err = redirect_out_err,
replace_absolute_paths = replace_absolute_paths,
replace_in_files = replace_in_files,
replace_sandbox_paths = replace_sandbox_paths,
replace_symlink = replace_symlink,
rm_rf = rm_rf,
script_extension = script_extension,
script_prelude = script_prelude,
shebang = shebang,
symlink_contents_to_dir = symlink_contents_to_dir,
symlink_to_dir = symlink_to_dir,
touch = touch,
use_var = use_var,
)
35 changes: 35 additions & 0 deletions foreign_cc/private/framework/toolchains/windows_commands.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,38 @@ if [[ -L "{file}" ]]; then
rm "{file}" && cp -a "${{target}}" "{file}"
fi
""".format(file = file)

commands = struct(
assert_script_errors = assert_script_errors,
cat = cat,
children_to_path = children_to_path,
cleanup_function = cleanup_function,
copy_dir_contents_to_dir = copy_dir_contents_to_dir,
define_absolute_paths = define_absolute_paths,
define_function = define_function,
define_sandbox_paths = define_sandbox_paths,
disable_tracing = disable_tracing,
echo = echo,
enable_tracing = enable_tracing,
env = env,
export_var = export_var,
if_else = if_else,
increment_pkg_config_path = increment_pkg_config_path,
local_var = local_var,
mkdirs = mkdirs,
path = path,
pwd = pwd,
redirect_out_err = redirect_out_err,
replace_absolute_paths = replace_absolute_paths,
replace_in_files = replace_in_files,
replace_sandbox_paths = replace_sandbox_paths,
replace_symlink = replace_symlink,
rm_rf = rm_rf,
script_extension = script_extension,
script_prelude = script_prelude,
shebang = shebang,
symlink_contents_to_dir = symlink_contents_to_dir,
symlink_to_dir = symlink_to_dir,
touch = touch,
use_var = use_var,
)

0 comments on commit 97247cf

Please sign in to comment.