Merge branch 'stable-3.3' into stable-3.4
* stable-3.3:
fix: cannot build 'gerrit-3.2' on MacOS
Load fonts directly from Gerrit instead of 3rd party domains
Change-Id: I9d299ee3176544418662d959072ea47143be60b9
diff --git a/BUILD b/BUILD
index 08741ba..057d3d2 100644
--- a/BUILD
+++ b/BUILD
@@ -26,6 +26,21 @@
outs = ["gitiles-servlet-resources.jar"],
cmd = " && ".join([
"unzip -qd $$TMP $(location @gitiles-servlet//jar) \"com/google/gitiles/static/*\"",
+ "cd $$TMP/com/google/gitiles/static",
+ # To avoid loading 3rd party resources, we adapt gitiles' CSS to
+ # load fonts from Gerrit directly:
+ # 1. Strip out Google font CSS imports to tmp file as in-place replace is OSX no-go
+ "sed -e '\\%^@import .//fonts\\.googleapis\\.com/%d' base.css > $$TMP/base.css.tmp",
+ # move tmp file back to base.css
+ "mv $$TMP/base.css.tmp base.css",
+ # 2. Add Gerrit's fonts CSS
+ "sed -e 's%^\\(.*Common styles and definitions.*\\)$$%" +
+ "\\1\\n\\n@import \"../../../styles/fonts.css\";%' base.css > $$TMP/base.css.tmp",
+ "mv $$TMP/base.css.tmp base.css",
+ # 3. Use Gerrit's Roboto Mono for Source Code Pro
+ "sed -e 's/Source Code Pro/Roboto Mono/g' base.css > $$TMP/base.css.tmp",
+ "mv $$TMP/base.css.tmp base.css",
+ # Switching from `static` to `+static` (see comment in plugin definiton)
"cd $$TMP/com/google/gitiles",
"mv static +static",
"zip -qr $$ROOT/$@ .",