Skip to content

Commit

Permalink
Fix building without sandboxing
Browse files Browse the repository at this point in the history
Since 466c32c any changes you made
while testing rules_foreign_cc, or changes to those rules, would not
invalidate the CMakeCache.txt and lead to build issues. It wasn't the
case before that because new temp dirs were used each time.
  • Loading branch information
keith committed Aug 20, 2021
1 parent be72696 commit f8c5e10
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions foreign_cc/built_tools/private/built_tools_framework.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ def built_tool_rule_impl(ctx, script_lines, out_dir, mnemonic):
"export EXT_BUILD_ROOT=##pwd##",
"export INSTALLDIR=$$EXT_BUILD_ROOT$$/{}".format(out_dir.path),
"export BUILD_TMPDIR=$$INSTALLDIR$$.build_tmpdir",
"##rm_rf## $$INSTALLDIR$$",
"##rm_rf## $$BUILD_TMPDIR$$",
"##mkdirs## $$INSTALLDIR$$",
"##mkdirs## $$BUILD_TMPDIR$$",
"##copy_dir_contents_to_dir## ./{} $$BUILD_TMPDIR$$".format(root),
"cd $$BUILD_TMPDIR$$",
Expand Down
2 changes: 2 additions & 0 deletions foreign_cc/private/framework.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ def cc_external_rule_impl(ctx, attrs):
"##script_prelude##",
] + env_prelude + [
"##path## $$EXT_BUILD_ROOT$$",
"##rm_rf## $$BUILD_TMPDIR$$",
"##rm_rf## $$EXT_BUILD_DEPS$$",
"##mkdirs## $$INSTALLDIR$$",
"##mkdirs## $$BUILD_TMPDIR$$",
"##mkdirs## $$EXT_BUILD_DEPS$$",
Expand Down
4 changes: 4 additions & 0 deletions foreign_cc/private/framework/toolchains/commands.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ PLATFORM_COMMANDS = {
"Replace the target symlink with resolved file it points to if `file` is a symlink"
),
),
"rm_rf": _command_info(
arguments = [_argument_info(name = "path", data_type = type(""), doc = "Path to directory")],
doc = "Recursively removes the given path",
),
"script_extension": _command_info(
arguments = [],
doc = "Return the extension for the current set of commands (`.sh` for bash, `.ps1` for powershell)",
Expand Down
3 changes: 3 additions & 0 deletions foreign_cc/private/framework/toolchains/linux_commands.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def disable_tracing():
def mkdirs(path):
return "mkdir -p " + path

def rm_rf(path):
return "rm -rf " + path

def if_else(condition, if_text, else_text):
return """
if [ {condition} ]; then
Expand Down
3 changes: 3 additions & 0 deletions foreign_cc/private/framework/toolchains/macos_commands.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def disable_tracing():
def mkdirs(path):
return "mkdir -p " + path

def rm_rf(path):
return "rm -rf " + path

def if_else(condition, if_text, else_text):
return """\
if [ {condition} ]; then
Expand Down
3 changes: 3 additions & 0 deletions foreign_cc/private/framework/toolchains/windows_commands.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def disable_tracing():
def mkdirs(path):
return "mkdir -p " + path

def rm_rf(path):
return "rm -rf " + path

def if_else(condition, if_text, else_text):
return """\
if [ {condition} ]; then
Expand Down

0 comments on commit f8c5e10

Please sign in to comment.