Bazel: Fix invocation of mktemp for OSX pre El Capitan

It seems that on OSX prior to 10.11.x (El Capitan) the mktemp command
doesn't work with only the -d option. The -t option is also required.

Add a fallback to use the -t option if the call with only -d fails.

See [1] for various discussion around this issue.

[1] http://unix.stackexchange.com/q/30091/130341

Bug: Issue 4826
Change-Id: Ie536e2ae071d4247a16f5c390198b8a590086d05
This commit is contained in:
David Pursehouse
2016-10-27 14:26:06 +09:00
parent d4418e9d8b
commit 2b64c44f1a
3 changed files with 3 additions and 3 deletions

View File

@@ -43,7 +43,7 @@ filegroup(
genrule(
name = "polygerrit_ui",
cmd = " && ".join([
"t=$$(mktemp -d)",
"t=$$(mktemp -d || mktemp -d -t bazel-tmp)",
"p=$$PWD",
"mkdir -p $$t/polygerrit_ui/{styles,fonts,bower_components/{highlightjs,webcomponentsjs},elements}",
"cp $(locations :gr-app) $$t/polygerrit_ui/elements/",

View File

@@ -20,7 +20,7 @@
def genrule2(out, cmd, **kwargs):
cmd = ' && '.join([
'ROOT=$$PWD',
'TMP=$$(mktemp -d)',
'TMP=$$(mktemp -d || mktemp -d -t bazel-tmp)',
'(' + cmd + ')',
])
native.genrule(

View File

@@ -87,7 +87,7 @@ def _bower_archive(ctx):
fail("failed %s: %s" % (" ".join(cmd), out.stderr))
_bash(ctx, " && " .join([
"TMP=$(mktemp -d )",
"TMP=$(mktemp -d || mkdir -d -t bazel-tmp)",
"cd $TMP",
"mkdir bower_components",
"cd bower_components",