ffe301570c
Add support for downloading npm binaries including dependencies and running them in buck genrules. In npm land, transitive dependencies are generally included in the package distribution, and there are a *lot* of them. Since we aren't redistributing these binaries and they're only part of the build process, we don't have to worry too much about licensing, only that they don't have anything totally crazy. We assume packages have a certain format and we can detect the binary to run from the genrule output filename. Actually running the binary is tricky as well, since we have to extract it first. But it might be large, so we don't want to extract it on every invocation; and naive extraction to a common location (in buck-out) is racy. So we need a custom extractor scheme using atomic rename to make this work. Download bower as an npm package and use it to download bower packages. Bower packages can come from a variety of sources, usually git repositories, so we can't simply use download_file. There is additional logic in bower to read bower.json and strip out unneeded files, so I didn't want to get into reimplementing that. The tricky thing about bower is convincing it to avoid transitive dependencies so we can let Buck handle parallelism and caching. To do this, we need to read the package information from the upstream bower repository, and explicitly ignore all listed dependencies when downloading. We combine the flattened list of bower packages in a single bower_components rule. It would be nice to have deps of each bower_component so we didn't need to flatten these, but Buck genrules don't have deps so this is a nonstarter. Considering we only expect to have a single bower_components for the whole project, hopefully this is not too onerous. This change just gets us the bower_components directory. We still have some work to do to use this from Gerrit. Plus even more work to replace the gulpfile and actually package this stuff together into a compiled JS app for the war distribution. Change-Id: Id277d2d812ffcc3bce87ff00b5894bacdffc038e
87 lines
1.8 KiB
Python
87 lines
1.8 KiB
Python
include_defs('//Documentation/asciidoc.defs')
|
|
include_defs('//Documentation/config.defs')
|
|
include_defs('//Documentation/license.defs')
|
|
include_defs('//tools/git.defs')
|
|
|
|
DOC_DIR = 'Documentation'
|
|
|
|
JSUI_JAVA_DEPS = ['//gerrit-gwtui:ui_module']
|
|
JSUI_NON_JAVA_DEPS = ['//polygerrit-ui:polygerrit_components']
|
|
MAIN_JAVA_DEPS = ['//gerrit-pgm:pgm']
|
|
SRCS = glob(['*.txt'], excludes = ['licenses.txt'])
|
|
|
|
|
|
genasciidoc(
|
|
name = 'html',
|
|
out = 'html.zip',
|
|
docdir = DOC_DIR,
|
|
srcs = SRCS + [':licenses.txt'],
|
|
attributes = documentation_attributes(git_describe()),
|
|
backend = 'html5',
|
|
visibility = ['PUBLIC'],
|
|
)
|
|
|
|
genasciidoc(
|
|
name = 'searchfree',
|
|
out = 'searchfree.zip',
|
|
docdir = DOC_DIR,
|
|
srcs = SRCS + [':licenses.txt'],
|
|
attributes = documentation_attributes(git_describe()),
|
|
backend = 'html5',
|
|
searchbox = False,
|
|
visibility = ['PUBLIC'],
|
|
)
|
|
|
|
genlicenses(
|
|
name = 'licenses.txt',
|
|
opts = ['--asciidoc'],
|
|
java_deps = JSUI_JAVA_DEPS + MAIN_JAVA_DEPS,
|
|
non_java_deps = JSUI_NON_JAVA_DEPS,
|
|
out = 'licenses.txt',
|
|
)
|
|
|
|
# Required by Google for gerrit-review.
|
|
genlicenses(
|
|
name = 'js_licenses.txt',
|
|
opts = ['--partial'],
|
|
java_deps = JSUI_JAVA_DEPS,
|
|
non_java_deps = JSUI_NON_JAVA_DEPS,
|
|
out = 'js_licenses.txt',
|
|
)
|
|
|
|
genrule(
|
|
name = 'doc.css',
|
|
srcs = ['doc.css.in'],
|
|
cmd = 'cp $SRCS $OUT',
|
|
out = 'doc.css',
|
|
)
|
|
|
|
python_binary(
|
|
name = 'gen_licenses',
|
|
main = 'gen_licenses.py',
|
|
)
|
|
|
|
python_binary(
|
|
name = 'replace_macros',
|
|
main = 'replace_macros.py',
|
|
)
|
|
|
|
genrule(
|
|
name = 'index',
|
|
cmd = '$(exe //lib/asciidoctor:doc_indexer) ' +
|
|
'-o $OUT ' +
|
|
'--prefix "%s/" ' % DOC_DIR +
|
|
'--in-ext ".txt" ' +
|
|
'--out-ext ".html" ' +
|
|
'$SRCS ' +
|
|
'$(location :licenses.txt)',
|
|
srcs = SRCS,
|
|
out = 'index.jar',
|
|
)
|
|
|
|
prebuilt_jar(
|
|
name = 'index_lib',
|
|
binary_jar = ':index',
|
|
visibility = ['PUBLIC'],
|
|
)
|