Merge branch 'stable-3.4' into 'master'
* stable-3.4:
fix: cannot build 'gerrit-3.2' on MacOS
Load fonts directly from Gerrit instead of 3rd party domains
Change-Id: I44e5fab908d4d338727097503cd64378c6b607c8
diff --git a/BUILD b/BUILD
index 5ee6f0d..8966d6b 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/$@ .",