Clean up some genrule() script code

The XJC genrule in particular was dirtying /tmp which I believe may have
been causing problems for Donuts.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=129451600
This commit is contained in:
Justine Tunney 2016-08-05 09:49:56 -07:00
parent e1d02d1ea5
commit 3f4121b98c
3 changed files with 25 additions and 17 deletions

View file

@ -15,6 +15,7 @@ sh_binary(
"//third_party/java/jaxb:jaxb-xjc",
"//java/google/registry/xml:xml_schema_files",
],
visibility = ["//visibility:private"],
)
genrule(
@ -25,23 +26,29 @@ genrule(
],
outs = xjc_generated_files,
cmd = " && ".join([
"XJC=$$PWD/$(location //third_party/java/jaxb:jaxb-xjc)",
"OUT=$$PWD/$(GENDIR)/java",
"REP=$$(pwd)",
"XJC=$$REP/$(location //third_party/java/jaxb:jaxb-xjc)",
"OUT=$$REP/$(GENDIR)/java",
"TMP=$$(mktemp -d $${TMPDIR:-/tmp}/jaxb.XXXXXXXXXX)",
"mkdir -p $$OUT",
"cp $(SRCS) /tmp",
"cd /tmp",
"cp $(SRCS) $$TMP",
"cd $$TMP",
"$$XJC -npa -quiet -extension -d $$OUT -b *.xjb *.xsd",
"find $$OUT -name '*.java' | xargs sed -i 's/" +
"public class/" +
"@SuppressWarnings({\"unchecked\",\"serial\",\"cast\"}) " +
"public class/'",
("find $$OUT -name '*.java' | xargs sed -i 's/" +
"public class/" +
"@SuppressWarnings({\"unchecked\",\"serial\",\"cast\"}) " +
"public class/'"),
"cd $$REP",
"rm -rf $$TMP",
]),
tools = ["//third_party/java/jaxb:jaxb-xjc"],
visibility = ["//visibility:private"],
)
sh_binary(
name = "make_pkginfo",
srcs = ["make_pkginfo.sh"],
visibility = ["//visibility:private"],
)
genrule(
@ -53,6 +60,7 @@ genrule(
":jaxb_srcs",
":make_pkginfo",
],
visibility = ["//visibility:private"],
)
java_library(

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# Copyright 2016 The Domain Registry Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# Copyright 2016 The Domain Registry Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@ -14,18 +14,18 @@
# limitations under the License.
[[ $# != 2 ]] && { echo "usage: $0 template outdir" >&2; exit 1; }
[[ $# != 2 ]] && { echo "usage: $0 TEMPLATE OUTDIR" >&2; exit 1; }
template=$1
outdir=$2
template="$1"
outdir="$2"
create() {
package=$1
namespace=$2
cat $template \
| sed -e s,@PACKAGE@,$package,g \
-e s,@NAMESPACE@,$namespace,g \
> $outdir/$package/package-info.java
sed -e "s,@PACKAGE@,${package},g" \
-e "s,@NAMESPACE@,${namespace},g" \
< "${template}" \
> "${outdir}/${package}/package-info.java"
}
create contact urn:ietf:params:xml:ns:contact-1.0