Vulcanize PolyGerrit in Buck build
Change-Id: Ie9baded31746a307bb257b69deeef41665821e9d
This commit is contained in:
parent
a5004ead38
commit
be81e1f4b5
@ -6,7 +6,7 @@ include_defs('//tools/git.defs')
|
||||
DOC_DIR = 'Documentation'
|
||||
|
||||
JSUI_JAVA_DEPS = ['//gerrit-gwtui:ui_module']
|
||||
JSUI_NON_JAVA_DEPS = ['//polygerrit-ui:polygerrit_components']
|
||||
JSUI_NON_JAVA_DEPS = ['//polygerrit-ui/app:polygerrit_ui']
|
||||
MAIN_JAVA_DEPS = ['//gerrit-pgm:pgm']
|
||||
SRCS = glob(['*.txt'], excludes = ['licenses.txt'])
|
||||
|
||||
|
@ -53,12 +53,6 @@ def parse_graph():
|
||||
for target, attrs in obj.iteritems():
|
||||
for dep in attrs['buck.direct_dependencies']:
|
||||
|
||||
# bower is only used by the build process; skip it in those cases, even if
|
||||
# --partial is not passed.
|
||||
if ((target == '//tools/js:download_bower'
|
||||
or target.startswith('//lib/js:')
|
||||
and dep == '//lib/js:bower')):
|
||||
continue
|
||||
if target in KNOWN_PROVIDED_DEPS:
|
||||
continue
|
||||
|
||||
|
33
lib/js.defs
33
lib/js.defs
@ -15,6 +15,9 @@
|
||||
NPMJS = 'NPMJS'
|
||||
GERRIT = 'GERRIT'
|
||||
|
||||
# NOTE: npm_binary rules do not get their licenses checked by gen_licenses.py,
|
||||
# as we would have to cut too many edges. DO NOT include these binaries in
|
||||
# build outputs. Using them in the build _process_ is ok.
|
||||
def npm_binary(
|
||||
name,
|
||||
version,
|
||||
@ -38,7 +41,6 @@ def npm_binary(
|
||||
name = name,
|
||||
cmd = ' '.join(cmd),
|
||||
out = dest,
|
||||
license = 'DO_NOT_DISTRIBUTE',
|
||||
visibility = visibility,
|
||||
)
|
||||
|
||||
@ -86,3 +88,32 @@ def bower_components(
|
||||
out = '%s.bower_components.zip' % name,
|
||||
visibility = visibility,
|
||||
)
|
||||
|
||||
|
||||
VULCANIZE_FLAGS = [
|
||||
'--inline-scripts',
|
||||
'--inline-css',
|
||||
'--strip-comments',
|
||||
]
|
||||
|
||||
def vulcanize(
|
||||
name,
|
||||
app,
|
||||
srcs,
|
||||
components,
|
||||
extra_flags = [],
|
||||
visibility = ['PUBLIC']):
|
||||
genrule(
|
||||
name = name,
|
||||
cmd = ' '.join([
|
||||
'unzip', '-qd', '$SRCDIR',
|
||||
] + ['$(location %s)' % c for c in components] + [
|
||||
'&&', run_npm_binary('//lib/js:vulcanize')
|
||||
] + VULCANIZE_FLAGS + extra_flags + [
|
||||
'--out-html', '$OUT',
|
||||
'$SRCDIR/%s' % app,
|
||||
]),
|
||||
srcs = srcs,
|
||||
out = '%s.html' % name,
|
||||
visibility = visibility,
|
||||
)
|
||||
|
@ -21,6 +21,13 @@ npm_binary(
|
||||
sha1 = '59d457122a161e42cc1625bbab8179c214b7ac11',
|
||||
)
|
||||
|
||||
npm_binary(
|
||||
name = 'vulcanize',
|
||||
version = '1.14.0',
|
||||
sha1 = '91eac280d031b5bbcafb5f86bb6ed30515fa2564',
|
||||
repository = GERRIT,
|
||||
)
|
||||
|
||||
# bower_components are listed without transitive dependencies; the whole
|
||||
# flattened dependency tree needs to be included in
|
||||
# //polygerrit-ui:polygerrit_components.
|
||||
|
44
polygerrit-ui/app/BUCK
Normal file
44
polygerrit-ui/app/BUCK
Normal file
@ -0,0 +1,44 @@
|
||||
include_defs('//lib/js.defs')
|
||||
|
||||
WEBJS = 'bower_components/webcomponentsjs/webcomponents-lite.js'
|
||||
|
||||
# TODO(dborowitz): Putting these rules in this package avoids having to handle
|
||||
# the app/ prefix like we would have to if this were in the parent directory.
|
||||
# The only reason for the app subdirectory in the first place was convenience
|
||||
# when witing server.go; when that goes away, we can just move all the files and
|
||||
# these rules up one directory.
|
||||
genrule(
|
||||
name = 'polygerrit_ui',
|
||||
cmd = ' && '.join([
|
||||
'mkdir $TMP/polygerrit_ui',
|
||||
'cd $TMP/polygerrit_ui',
|
||||
'cp $(location :processed_index) index.html',
|
||||
'mkdir -p {elements,bower_components/webcomponentsjs}',
|
||||
'cp $(location :polygerrit) elements/gr-app.vulcanized.html',
|
||||
'cp -rp $SRCDIR/* .',
|
||||
'unzip -p $(location //polygerrit-ui:polygerrit_components) %s>%s' % (WEBJS, WEBJS),
|
||||
'cd $TMP',
|
||||
'zip -9qr $OUT .',
|
||||
]),
|
||||
srcs = glob([
|
||||
'favicon.ico',
|
||||
'styles/**/*.css'
|
||||
]),
|
||||
out = 'polygerrit_ui.zip',
|
||||
visibility = ['PUBLIC'],
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = 'processed_index',
|
||||
cmd = 'sed "s/gr-app.html/gr-app.vulcanized.html/g" $SRCS >$OUT',
|
||||
srcs = ['index.html'],
|
||||
out = 'index_processed.html',
|
||||
)
|
||||
|
||||
vulcanize(
|
||||
name = 'polygerrit',
|
||||
app = 'elements/gr-app.html',
|
||||
srcs = glob(['**'], excludes = ['index.html']),
|
||||
components = ['//polygerrit-ui:polygerrit_components'],
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user