Format .bzl files with Bazel Buildifier

Change-Id: I3ab30565e5ac110a18cbe3d34f76307801c30373
This commit is contained in:
David Pursehouse 2016-12-11 19:00:10 +09:00
parent a052e52971
commit 2d08500516
18 changed files with 510 additions and 491 deletions

View File

@ -1,8 +1,8 @@
load('//tools/bzl:junit.bzl', 'junit_tests') load("//tools/bzl:junit.bzl", "junit_tests")
BOUNCYCASTLE = [ BOUNCYCASTLE = [
'//lib/bouncycastle:bcpkix-without-neverlink', "//lib/bouncycastle:bcpkix-without-neverlink",
'//lib/bouncycastle:bcpg-without-neverlink', "//lib/bouncycastle:bcpg-without-neverlink",
] ]
def acceptance_tests( def acceptance_tests(

View File

@ -1,88 +1,88 @@
load('//tools/bzl:genrule2.bzl', 'genrule2') load("//tools/bzl:genrule2.bzl", "genrule2")
CM_CSS = [ CM_CSS = [
'lib/codemirror.css', "lib/codemirror.css",
'addon/dialog/dialog.css', "addon/dialog/dialog.css",
'addon/merge/merge.css', "addon/merge/merge.css",
'addon/scroll/simplescrollbars.css', "addon/scroll/simplescrollbars.css",
'addon/search/matchesonscrollbar.css', "addon/search/matchesonscrollbar.css",
'addon/lint/lint.css', "addon/lint/lint.css",
] ]
CM_JS = [ CM_JS = [
'lib/codemirror.js', "lib/codemirror.js",
'mode/meta.js', "mode/meta.js",
'keymap/emacs.js', "keymap/emacs.js",
'keymap/sublime.js', "keymap/sublime.js",
'keymap/vim.js', "keymap/vim.js",
] ]
CM_ADDONS = [ CM_ADDONS = [
'dialog/dialog.js', "dialog/dialog.js",
'edit/closebrackets.js', "edit/closebrackets.js",
'edit/matchbrackets.js', "edit/matchbrackets.js",
'edit/trailingspace.js', "edit/trailingspace.js",
'scroll/annotatescrollbar.js', "scroll/annotatescrollbar.js",
'scroll/simplescrollbars.js', "scroll/simplescrollbars.js",
'search/jump-to-line.js', "search/jump-to-line.js",
'search/matchesonscrollbar.js', "search/matchesonscrollbar.js",
'search/searchcursor.js', "search/searchcursor.js",
'search/search.js', "search/search.js",
'selection/mark-selection.js', "selection/mark-selection.js",
'mode/multiplex.js', "mode/multiplex.js",
'mode/overlay.js', "mode/overlay.js",
'mode/simple.js', "mode/simple.js",
'lint/lint.js', "lint/lint.js",
] ]
# Available themes must be enumerated here, # Available themes must be enumerated here,
# in gerrit-extension-api/src/main/java/com/google/gerrit/extensions/common/Theme.java, # in gerrit-extension-api/src/main/java/com/google/gerrit/extensions/common/Theme.java,
# in gerrit-gwtui/src/main/java/net/codemirror/theme/Themes.java # in gerrit-gwtui/src/main/java/net/codemirror/theme/Themes.java
CM_THEMES = [ CM_THEMES = [
'3024-day', "3024-day",
'3024-night', "3024-night",
'abcdef', "abcdef",
'ambiance', "ambiance",
'base16-dark', "base16-dark",
'base16-light', "base16-light",
'bespin', "bespin",
'blackboard', "blackboard",
'cobalt', "cobalt",
'colorforth', "colorforth",
'dracula', "dracula",
'eclipse', "eclipse",
'elegant', "elegant",
'erlang-dark', "erlang-dark",
'hopscotch', "hopscotch",
'icecoder', "icecoder",
'isotope', "isotope",
'lesser-dark', "lesser-dark",
'liquibyte', "liquibyte",
'material', "material",
'mbo', "mbo",
'mdn-like', "mdn-like",
'midnight', "midnight",
'monokai', "monokai",
'neat', "neat",
'neo', "neo",
'night', "night",
'paraiso-dark', "paraiso-dark",
'paraiso-light', "paraiso-light",
'pastel-on-dark', "pastel-on-dark",
'railscasts', "railscasts",
'rubyblue', "rubyblue",
'seti', "seti",
'solarized', "solarized",
'the-matrix', "the-matrix",
'tomorrow-night-bright', "tomorrow-night-bright",
'tomorrow-night-eighties', "tomorrow-night-eighties",
'ttcn', "ttcn",
'twilight', "twilight",
'vibrant-ink', "vibrant-ink",
'xq-dark', "xq-dark",
'xq-light', "xq-light",
'yeti', "yeti",
'zenburn', "zenburn",
] ]
# Available modes must be enumerated here, # Available modes must be enumerated here,
@ -90,137 +90,142 @@ CM_THEMES = [
# gerrit-gwtui/src/main/java/net/codemirror/mode/ModeInfo.java, # gerrit-gwtui/src/main/java/net/codemirror/mode/ModeInfo.java,
# and in CodeMirror's own mode/meta.js script. # and in CodeMirror's own mode/meta.js script.
CM_MODES = [ CM_MODES = [
'apl', "apl",
'asciiarmor', "asciiarmor",
'asn.1', "asn.1",
'asterisk', "asterisk",
'brainfuck', "brainfuck",
'clike', "clike",
'clojure', "clojure",
'cmake', "cmake",
'cobol', "cobol",
'coffeescript', "coffeescript",
'commonlisp', "commonlisp",
'crystal', "crystal",
'css', "css",
'cypher', "cypher",
'd', "d",
'dart', "dart",
'diff', "diff",
'django', "django",
'dockerfile', "dockerfile",
'dtd', "dtd",
'dylan', "dylan",
'ebnf', "ebnf",
'ecl', "ecl",
'eiffel', "eiffel",
'elm', "elm",
'erlang', "erlang",
'factor', "factor",
'fcl', "fcl",
'forth', "forth",
'fortran', "fortran",
'gas', "gas",
'gfm', "gfm",
'gherkin', "gherkin",
'go', "go",
'groovy', "groovy",
'haml', "haml",
'handlebars', "handlebars",
'haskell-literate', "haskell-literate",
'haskell', "haskell",
'haxe', "haxe",
'htmlembedded', "htmlembedded",
'htmlmixed', "htmlmixed",
'http', "http",
'idl', "idl",
'javascript', "javascript",
'jinja2', "jinja2",
'jsx', "jsx",
'julia', "julia",
'livescript', "livescript",
'lua', "lua",
'markdown', "markdown",
'mathematica', "mathematica",
'mbox', "mbox",
'mirc', "mirc",
'mllike', "mllike",
'modelica', "modelica",
'mscgen', "mscgen",
'mumps', "mumps",
'nginx', "nginx",
'nsis', "nsis",
'ntriples', "ntriples",
'octave', "octave",
'oz', "oz",
'pascal', "pascal",
'pegjs', "pegjs",
'perl', "perl",
'php', "php",
'pig', "pig",
'powershell', "powershell",
'properties', "properties",
'protobuf', "protobuf",
'pug', "pug",
'puppet', "puppet",
'python', "python",
'q', "q",
'r', "r",
'rpm', "rpm",
'rst', "rst",
'ruby', "ruby",
'rust', "rust",
'sas', "sas",
'sass', "sass",
'scheme', "scheme",
'shell', "shell",
'sieve', "sieve",
'slim', "slim",
'smalltalk', "smalltalk",
'smarty', "smarty",
'solr', "solr",
'soy', "soy",
'sparql', "sparql",
'spreadsheet', "spreadsheet",
'sql', "sql",
'stex', "stex",
'stylus', "stylus",
'swift', "swift",
'tcl', "tcl",
'textile', "textile",
'tiddlywiki', "tiddlywiki",
'tiki', "tiki",
'toml', "toml",
'tornado', "tornado",
'troff', "troff",
'ttcn-cfg', "ttcn-cfg",
'ttcn', "ttcn",
'turtle', "turtle",
'twig', "twig",
'vb', "vb",
'vbscript', "vbscript",
'velocity', "velocity",
'verilog', "verilog",
'vhdl', "vhdl",
'vue', "vue",
'webidl', "webidl",
'xml', "xml",
'xquery', "xquery",
'yacas', "yacas",
'yaml-frontmatter', "yaml-frontmatter",
'yaml', "yaml",
'z80', "z80",
] ]
VERSION = '5.19.0' VERSION = "5.19.0"
TOP = 'META-INF/resources/webjars/codemirror/%s' % VERSION
TOP_MINIFIED = 'META-INF/resources/webjars/codemirror-minified/%s' % VERSION
LICENSE = '//lib:LICENSE-codemirror-original'
LICENSE_MINIFIED = '//lib:LICENSE-codemirror-minified'
DIFF_MATCH_PATCH_VERSION = '20121119-1' TOP = "META-INF/resources/webjars/codemirror/%s" % VERSION
DIFF_MATCH_PATCH_TOP = ('META-INF/resources/webjars/google-diff-match-patch/%s'
% DIFF_MATCH_PATCH_VERSION) TOP_MINIFIED = "META-INF/resources/webjars/codemirror-minified/%s" % VERSION
LICENSE = "//lib:LICENSE-codemirror-original"
LICENSE_MINIFIED = "//lib:LICENSE-codemirror-minified"
DIFF_MATCH_PATCH_VERSION = "20121119-1"
DIFF_MATCH_PATCH_TOP = ("META-INF/resources/webjars/google-diff-match-patch/%s" %
DIFF_MATCH_PATCH_VERSION)
def pkg_cm(): def pkg_cm():
for archive, suffix, top, license in [ for archive, suffix, top, license in [

View File

@ -1,3 +1,5 @@
GUAVA_VERSION = '20.0' GUAVA_VERSION = "20.0"
GUAVA_BIN_SHA1 = '89507701249388e1ed5ddcf8c41f4ce1be7831ef'
GUAVA_DOC_URL = 'https://google.github.io/guava/releases/' + GUAVA_VERSION + '/api/docs/' GUAVA_BIN_SHA1 = "89507701249388e1ed5ddcf8c41f4ce1be7831ef"
GUAVA_DOC_URL = "https://google.github.io/guava/releases/" + GUAVA_VERSION + "/api/docs/"

View File

@ -1,4 +1,6 @@
JGIT_VERS = '4.5.0.201609210915-r.115-g81f9c1843' JGIT_VERS = "4.5.0.201609210915-r.115-g81f9c1843"
DOC_VERS = '4.5.0.201609210915-r'
DOC_VERS = "4.5.0.201609210915-r"
#DOC_VERS = JGIT_VERS # Set to VERS unless using a snapshot #DOC_VERS = JGIT_VERS # Set to VERS unless using a snapshot
JGIT_DOC_URL="http://download.eclipse.org/jgit/site/" + DOC_VERS + "/apidocs" JGIT_DOC_URL = "http://download.eclipse.org/jgit/site/" + DOC_VERS + "/apidocs"

View File

@ -5,6 +5,7 @@
# #
load("//tools/bzl:js.bzl", "bower_archive") load("//tools/bzl:js.bzl", "bower_archive")
def load_bower_archives(): def load_bower_archives():
bower_archive( bower_archive(
name = "accessibility-developer-tools", name = "accessibility-developer-tools",

View File

@ -5,6 +5,7 @@
# #
load("//tools/bzl:js.bzl", "bower_component") load("//tools/bzl:js.bzl", "bower_component")
def define_bower_components(): def define_bower_components():
bower_component( bower_component(
name = "accessibility-developer-tools", name = "accessibility-developer-tools",

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
load('//tools/bzl:genrule2.bzl', 'genrule2') load("//tools/bzl:genrule2.bzl", "genrule2")
def prolog_cafe_library( def prolog_cafe_library(
name, name,

View File

@ -17,7 +17,6 @@ def documentation_attributes():
"revnumber=%s", "revnumber=%s",
] ]
def release_notes_attributes(): def release_notes_attributes():
return [ return [
'toc', 'toc',
@ -33,7 +32,6 @@ def release_notes_attributes():
'linkcss=true', 'linkcss=true',
] ]
def _replace_macros_impl(ctx): def _replace_macros_impl(ctx):
cmd = [ cmd = [
ctx.file._exe.path, ctx.file._exe.path,
@ -53,23 +51,22 @@ def _replace_macros_impl(ctx):
) )
_replace_macros = rule( _replace_macros = rule(
implementation = _replace_macros_impl, attrs = {
attrs = { "_exe": attr.label(
"_exe": attr.label( default = Label("//Documentation:replace_macros.py"),
default = Label("//Documentation:replace_macros.py"), allow_single_file = True,
allow_single_file = True, ),
), "src": attr.label(
"src": attr.label( mandatory = True,
mandatory = True, allow_single_file = [".txt"],
allow_single_file = [".txt"], ),
), "suffix": attr.string(mandatory = True),
"suffix": attr.string(mandatory = True), "searchbox": attr.bool(default = True),
"searchbox": attr.bool(default = True), "out": attr.output(mandatory = True),
"out": attr.output(mandatory = True), },
}, implementation = _replace_macros_impl,
) )
def _generate_asciidoc_args(ctx): def _generate_asciidoc_args(ctx):
args = [] args = []
if ctx.attr.backend: if ctx.attr.backend:
@ -88,7 +85,6 @@ def _generate_asciidoc_args(ctx):
args.append(src.path) args.append(src.path)
return args return args
def _invoke_replace_macros(name, src, suffix, searchbox): def _invoke_replace_macros(name, src, suffix, searchbox):
fn = src fn = src
if fn.startswith(":"): if fn.startswith(":"):
@ -104,7 +100,6 @@ def _invoke_replace_macros(name, src, suffix, searchbox):
return ":" + fn + suffix, fn.replace(".txt", ".html") return ":" + fn + suffix, fn.replace(".txt", ".html")
def _asciidoc_impl(ctx): def _asciidoc_impl(ctx):
args = [ args = [
"--bazel", "--bazel",
@ -121,30 +116,32 @@ def _asciidoc_impl(ctx):
) )
_asciidoc_attrs = { _asciidoc_attrs = {
"_exe": attr.label( "_exe": attr.label(
default = Label("//lib/asciidoctor:asciidoc"), default = Label("//lib/asciidoctor:asciidoc"),
cfg = "host", cfg = "host",
allow_files = True, allow_files = True,
executable = True, executable = True,
), ),
"srcs": attr.label_list(mandatory = True, allow_files = True), "srcs": attr.label_list(
"version": attr.label( mandatory = True,
default = Label("//:version.txt"), allow_files = True,
allow_single_file = True, ),
), "version": attr.label(
"suffix": attr.string(mandatory = True), default = Label("//:version.txt"),
"backend": attr.string(), allow_single_file = True,
"attributes": attr.string_list(), ),
"suffix": attr.string(mandatory = True),
"backend": attr.string(),
"attributes": attr.string_list(),
} }
_asciidoc = rule( _asciidoc = rule(
implementation = _asciidoc_impl, attrs = _asciidoc_attrs + {
attrs = _asciidoc_attrs + { "outs": attr.output_list(mandatory = True),
"outs": attr.output_list(mandatory = True), },
}, implementation = _asciidoc_impl,
) )
def _genasciidoc_htmlonly( def _genasciidoc_htmlonly(
name, name,
srcs = [], srcs = [],
@ -176,7 +173,6 @@ def _genasciidoc_htmlonly(
**kwargs **kwargs
) )
def genasciidoc( def genasciidoc(
name, name,
srcs = [], srcs = [],
@ -207,7 +203,6 @@ def genasciidoc(
**kwargs **kwargs
) )
def _asciidoc_html_zip_impl(ctx): def _asciidoc_html_zip_impl(ctx):
args = [ args = [
"--mktmp", "--mktmp",
@ -225,14 +220,13 @@ def _asciidoc_html_zip_impl(ctx):
) )
_asciidoc_html_zip = rule( _asciidoc_html_zip = rule(
implementation = _asciidoc_html_zip_impl, attrs = _asciidoc_attrs,
attrs = _asciidoc_attrs, outputs = {
outputs = { "out": "%{name}.zip",
"out": "%{name}.zip", },
} implementation = _asciidoc_html_zip_impl,
) )
def _genasciidoc_htmlonly_zip( def _genasciidoc_htmlonly_zip(
name, name,
srcs = [], srcs = [],
@ -255,7 +249,6 @@ def _genasciidoc_htmlonly_zip(
attributes = attributes, attributes = attributes,
) )
def _asciidoc_zip_impl(ctx): def _asciidoc_zip_impl(ctx):
tmpdir = ctx.outputs.out.path + "_tmpdir" tmpdir = ctx.outputs.out.path + "_tmpdir"
cmd = [ cmd = [
@ -284,21 +277,23 @@ def _asciidoc_zip_impl(ctx):
) )
_asciidoc_zip = rule( _asciidoc_zip = rule(
implementation = _asciidoc_zip_impl, attrs = {
attrs = { "src": attr.label(
"src": attr.label( mandatory = True,
mandatory = True, allow_single_file = [".zip"],
allow_single_file = [".zip"], ),
), "resources": attr.label_list(
"resources": attr.label_list(mandatory = True, allow_files = True), mandatory = True,
"directory": attr.string(mandatory = True), allow_files = True,
}, ),
outputs = { "directory": attr.string(mandatory = True),
"out": "%{name}.zip", },
} outputs = {
"out": "%{name}.zip",
},
implementation = _asciidoc_zip_impl,
) )
def genasciidoc_zip( def genasciidoc_zip(
name, name,
srcs = [], srcs = [],

View File

@ -1,4 +1,3 @@
def _classpath_collector(ctx): def _classpath_collector(ctx):
all = set() all = set()
for d in ctx.attr.deps: for d in ctx.attr.deps:
@ -13,10 +12,11 @@ def _classpath_collector(ctx):
content="\n".join(sorted(as_strs))) content="\n".join(sorted(as_strs)))
classpath_collector = rule( classpath_collector = rule(
implementation = _classpath_collector,
attrs = { attrs = {
"deps": attr.label_list(), "deps": attr.label_list(),
}, },
outputs={ outputs = {
"runtime": "%{name}.runtime_classpath" "runtime": "%{name}.runtime_classpath",
}) },
implementation = _classpath_collector,
)

View File

@ -14,74 +14,78 @@
# Port of Buck native gwt_binary() rule. See discussion in context of # Port of Buck native gwt_binary() rule. See discussion in context of
# https://github.com/facebook/buck/issues/109 # https://github.com/facebook/buck/issues/109
load('//tools/bzl:genrule2.bzl', 'genrule2') load("//tools/bzl:genrule2.bzl", "genrule2")
load('//tools/bzl:java.bzl', 'java_library2') load("//tools/bzl:java.bzl", "java_library2")
jar_filetype = FileType(['.jar']) jar_filetype = FileType([".jar"])
BROWSERS = [ BROWSERS = [
'chrome', "chrome",
'firefox', "firefox",
'gecko1_8', "gecko1_8",
'safari', "safari",
'msie', 'ie8', 'ie9', 'ie10', "msie",
'edge', "ie8",
"ie9",
"ie10",
"edge",
] ]
ALIASES = { ALIASES = {
'chrome': 'safari', "chrome": "safari",
'firefox': 'gecko1_8', "firefox": "gecko1_8",
'msie': 'ie10', "msie": "ie10",
'edge': 'gecko1_8', "edge": "gecko1_8",
} }
MODULE = 'com.google.gerrit.GerritGwtUI' MODULE = "com.google.gerrit.GerritGwtUI"
GWT_COMPILER = "com.google.gwt.dev.Compiler" GWT_COMPILER = "com.google.gwt.dev.Compiler"
GWT_JVM_ARGS = ['-Xmx512m'] GWT_JVM_ARGS = ["-Xmx512m"]
GWT_COMPILER_ARGS = [ GWT_COMPILER_ARGS = [
'-XdisableClassMetadata', "-XdisableClassMetadata",
] ]
GWT_COMPILER_ARGS_RELEASE_MODE = GWT_COMPILER_ARGS + [ GWT_COMPILER_ARGS_RELEASE_MODE = GWT_COMPILER_ARGS + [
'-XdisableCastChecking', "-XdisableCastChecking",
] ]
PLUGIN_DEPS_NEVERLINK = [ PLUGIN_DEPS_NEVERLINK = [
'//gerrit-plugin-api:lib-neverlink', "//gerrit-plugin-api:lib-neverlink",
] ]
GWT_PLUGIN_DEPS_NEVERLINK = [ GWT_PLUGIN_DEPS_NEVERLINK = [
'//gerrit-plugin-gwtui:gwtui-api-lib-neverlink', "//gerrit-plugin-gwtui:gwtui-api-lib-neverlink",
'//lib/gwt:user-neverlink', "//lib/gwt:user-neverlink",
] ]
GWT_PLUGIN_DEPS = [ GWT_PLUGIN_DEPS = [
'//gerrit-plugin-gwtui:gwtui-api-lib', "//gerrit-plugin-gwtui:gwtui-api-lib",
] ]
GWT_TRANSITIVE_DEPS = [ GWT_TRANSITIVE_DEPS = [
'//lib/gwt:ant', "//lib/gwt:ant",
'//lib/gwt:colt', "//lib/gwt:colt",
'//lib/gwt:javax-validation', "//lib/gwt:javax-validation",
'//lib/gwt:javax-validation_src', "//lib/gwt:javax-validation_src",
'//lib/gwt:jsinterop-annotations', "//lib/gwt:jsinterop-annotations",
'//lib/gwt:jsinterop-annotations_src', "//lib/gwt:jsinterop-annotations_src",
'//lib/gwt:tapestry', "//lib/gwt:tapestry",
'//lib/gwt:w3c-css-sac', "//lib/gwt:w3c-css-sac",
'//lib/ow2:ow2-asm', "//lib/ow2:ow2-asm",
'//lib/ow2:ow2-asm-analysis', "//lib/ow2:ow2-asm-analysis",
'//lib/ow2:ow2-asm-commons', "//lib/ow2:ow2-asm-commons",
'//lib/ow2:ow2-asm-tree', "//lib/ow2:ow2-asm-tree",
'//lib/ow2:ow2-asm-util', "//lib/ow2:ow2-asm-util",
] ]
DEPS = GWT_TRANSITIVE_DEPS + [ DEPS = GWT_TRANSITIVE_DEPS + [
'//gerrit-gwtexpui:CSS', "//gerrit-gwtexpui:CSS",
'//lib:gwtjsonrpc', "//lib:gwtjsonrpc",
'//lib/gwt:dev', "//lib/gwt:dev",
'@jgit//jar:src', "@jgit//jar:src",
] ]
USER_AGENT_XML = """<module rename-to='gerrit_ui'> USER_AGENT_XML = """<module rename-to='gerrit_ui'>
@ -202,27 +206,29 @@ def _get_transitive_closure(ctx):
return deps return deps
gwt_binary = rule( gwt_binary = rule(
implementation = _gwt_binary_impl, attrs = {
attrs = { "user_agent": attr.string(),
"user_agent": attr.string(), "style": attr.string(default = "OBF"),
"style": attr.string(default = "OBF"), "optimize": attr.string(default = "9"),
"optimize": attr.string(default = "9"), "deps": attr.label_list(allow_files = jar_filetype),
"deps": attr.label_list(allow_files=jar_filetype), "module": attr.string_list(default = [MODULE]),
"module": attr.string_list(default = [MODULE]), "module_deps": attr.label_list(allow_files = jar_filetype),
"module_deps": attr.label_list(allow_files=jar_filetype), "compiler_args": attr.string_list(),
"compiler_args": attr.string_list(), "jvm_args": attr.string_list(),
"jvm_args": attr.string_list(), "_jdk": attr.label(
"_jdk": attr.label( default = Label("//tools/defaults:jdk"),
default=Label("//tools/defaults:jdk")), ),
"_zip": attr.label( "_zip": attr.label(
default=Label("@bazel_tools//tools/zip:zipper"), default = Label("@bazel_tools//tools/zip:zipper"),
cfg = "host", cfg = "host",
executable=True, executable = True,
single_file=True), single_file = True,
}, ),
outputs = { },
"output": "%{name}.zip", outputs = {
}, "output": "%{name}.zip",
},
implementation = _gwt_binary_impl,
) )
def gwt_genrule(suffix = ""): def gwt_genrule(suffix = ""):

View File

@ -59,18 +59,20 @@ def _impl(ctx):
java_doc = rule( java_doc = rule(
attrs = { attrs = {
"libs": attr.label_list(allow_files = False), "libs": attr.label_list(allow_files = False),
"pkgs": attr.string_list(), "pkgs": attr.string_list(),
"title": attr.string(), "title": attr.string(),
"external_docs": attr.string_list(), "external_docs": attr.string_list(),
"_javadoc": attr.label( "_javadoc": attr.label(
default = Label("@local_jdk//:bin/javadoc"), default = Label("@local_jdk//:bin/javadoc"),
single_file = True, single_file = True,
allow_files = True), allow_files = True,
"_jdk": attr.label( ),
default = Label("@local_jdk//:jdk-default"), "_jdk": attr.label(
allow_files = True), default = Label("@local_jdk//:jdk-default"),
allow_files = True,
),
}, },
outputs = {"zip": "%{name}.zip"},
implementation = _impl, implementation = _impl,
outputs = {"zip" : "%{name}.zip"},
) )

View File

@ -1,23 +1,22 @@
NPMJS = "NPMJS" NPMJS = "NPMJS"
GERRIT = "GERRIT:" GERRIT = "GERRIT:"
NPM_VERSIONS = { NPM_VERSIONS = {
"bower": '1.7.9', "bower": "1.7.9",
'crisper': '2.0.2', "crisper": "2.0.2",
'vulcanize': '1.14.8', "vulcanize": "1.14.8",
} }
NPM_SHA1S = { NPM_SHA1S = {
"bower": 'b7296c2393e0d75edaa6ca39648132dd255812b0', "bower": "b7296c2393e0d75edaa6ca39648132dd255812b0",
"crisper": '7183c58cea33632fb036c91cefd1b43e390d22a2', "crisper": "7183c58cea33632fb036c91cefd1b43e390d22a2",
'vulcanize': '679107f251c19ab7539529b1e3fdd40829e6fc63', "vulcanize": "679107f251c19ab7539529b1e3fdd40829e6fc63",
} }
def _npm_tarball(name): def _npm_tarball(name):
return "%s@%s.npm_binary.tgz" % (name, NPM_VERSIONS[name]) return "%s@%s.npm_binary.tgz" % (name, NPM_VERSIONS[name])
def _npm_binary_impl(ctx): def _npm_binary_impl(ctx):
"""rule to download a NPM archive.""" """rule to download a NPM archive."""
name = ctx.name name = ctx.name
@ -47,14 +46,14 @@ def _npm_binary_impl(ctx):
ctx.file("BUILD", "package(default_visibility=['//visibility:public'])\nfilegroup(name='tarball', srcs=['%s'])" % base, False) ctx.file("BUILD", "package(default_visibility=['//visibility:public'])\nfilegroup(name='tarball', srcs=['%s'])" % base, False)
npm_binary = repository_rule( npm_binary = repository_rule(
implementation=_npm_binary_impl, attrs = {
local=True, # Label resolves within repo of the .bzl file.
attrs={ "_download_script": attr.label(default = Label("//tools:download_file.py")),
# Label resolves within repo of the .bzl file. "repository": attr.string(default = NPMJS),
"_download_script": attr.label(default=Label("//tools:download_file.py")), },
"repository": attr.string(default=NPMJS), local = True,
}) implementation = _npm_binary_impl,
)
# for use in repo rules. # for use in repo rules.
def _run_npm_binary_str(ctx, tarball, args): def _run_npm_binary_str(ctx, tarball, args):
@ -64,7 +63,6 @@ def _run_npm_binary_str(ctx, tarball, args):
ctx.path(ctx.attr._run_npm), ctx.path(ctx.attr._run_npm),
ctx.path(tarball)] + args) ctx.path(tarball)] + args)
def _bower_archive(ctx): def _bower_archive(ctx):
"""Download a bower package.""" """Download a bower package."""
download_name = '%s__download_bower.zip' % ctx.name download_name = '%s__download_bower.zip' % ctx.name
@ -106,26 +104,24 @@ def _bower_archive(ctx):
"filegroup(name = 'version_json', srcs = ['%s'], visibility=['//visibility:public'])" % version_name, "filegroup(name = 'version_json', srcs = ['%s'], visibility=['//visibility:public'])" % version_name,
]), False) ]), False)
def _bash(ctx, cmd): def _bash(ctx, cmd):
cmd_list = ["/bin/bash", "-c", cmd] cmd_list = ["/bin/bash", "-c", cmd]
out = ctx.execute(cmd_list) out = ctx.execute(cmd_list)
if out.return_code: if out.return_code:
fail("failed %s: %s" % (" ".join(cmd_list), out.stderr)) fail("failed %s: %s" % (" ".join(cmd_list), out.stderr))
bower_archive = repository_rule(
bower_archive=repository_rule( _bower_archive,
_bower_archive, attrs = {
attrs={ "_bower_archive": attr.label(default = Label("@bower//:%s" % _npm_tarball("bower"))),
"_bower_archive": attr.label(default=Label("@bower//:%s" % _npm_tarball("bower"))), "_run_npm": attr.label(default = Label("//tools/js:run_npm_binary.py")),
"_run_npm": attr.label(default=Label("//tools/js:run_npm_binary.py")), "_download_bower": attr.label(default = Label("//tools/js:download_bower.py")),
"_download_bower": attr.label(default=Label("//tools/js:download_bower.py")), "sha1": attr.string(mandatory = True),
"sha1": attr.string(mandatory=True), "version": attr.string(mandatory = True),
"version": attr.string(mandatory=True), "package": attr.string(mandatory = True),
"package": attr.string(mandatory=True), "semver": attr.string(),
"semver": attr.string(), },
}) )
def _bower_component_impl(ctx): def _bower_component_impl(ctx):
transitive_zipfiles = set([ctx.file.zipfile]) transitive_zipfiles = set([ctx.file.zipfile])
@ -149,15 +145,13 @@ def _bower_component_impl(ctx):
transitive_licenses=transitive_licenses, transitive_licenses=transitive_licenses,
) )
_common_attrs = { _common_attrs = {
"deps": attr.label_list(providers=[ "deps": attr.label_list(providers = [
"transitive_zipfiles", "transitive_zipfiles",
"transitive_versions", "transitive_versions",
"transitive_licenses", "transitive_licenses",
]) ]),
} }
def _js_component(ctx): def _js_component(ctx):
dir = ctx.outputs.zip.path + ".dir" dir = ctx.outputs.zip.path + ".dir"
@ -188,31 +182,28 @@ def _js_component(ctx):
transitive_versions=set([]), transitive_versions=set([]),
transitive_licenses=licenses) transitive_licenses=licenses)
js_component = rule( js_component = rule(
_js_component, _js_component,
attrs=_common_attrs + { attrs = _common_attrs + {
"srcs": attr.label_list(allow_files=[".js"]), "srcs": attr.label_list(allow_files = [".js"]),
"license": attr.label(allow_single_file=True), "license": attr.label(allow_single_file = True),
}, },
outputs={ outputs = {
"zip": "%{name}.zip", "zip": "%{name}.zip",
} },
) )
_bower_component = rule( _bower_component = rule(
_bower_component_impl, _bower_component_impl,
attrs=_common_attrs + { attrs = _common_attrs + {
"zipfile": attr.label(allow_single_file=[".zip"]), "zipfile": attr.label(allow_single_file = [".zip"]),
"license": attr.label(allow_single_file=True), "license": attr.label(allow_single_file = True),
"version_json": attr.label(allow_files=[".json"]), "version_json": attr.label(allow_files = [".json"]),
# If set, define by hand, and don't regenerate this entry in bower2bazel.
"seed": attr.bool(default=False)
})
# If set, define by hand, and don't regenerate this entry in bower2bazel.
"seed": attr.bool(default = False),
},
)
# TODO(hanwen): make license mandatory. # TODO(hanwen): make license mandatory.
def bower_component(name, license=None, **kwargs): def bower_component(name, license=None, **kwargs):
@ -226,7 +217,6 @@ def bower_component(name, license=None, **kwargs):
version_json="@%s//:version_json" % name, version_json="@%s//:version_json" % name,
**kwargs) **kwargs)
def _bower_component_bundle_impl(ctx): def _bower_component_bundle_impl(ctx):
"""A bunch of bower components zipped up.""" """A bunch of bower components zipped up."""
zips = set([]) zips = set([])
@ -270,14 +260,13 @@ def _bower_component_bundle_impl(ctx):
transitive_versions=versions, transitive_versions=versions,
transitive_licenses=licenses) transitive_licenses=licenses)
bower_component_bundle = rule( bower_component_bundle = rule(
_bower_component_bundle_impl, _bower_component_bundle_impl,
attrs=_common_attrs, attrs = _common_attrs,
outputs={ outputs = {
"zip": "%{name}.zip", "zip": "%{name}.zip",
"version_json": "%{name}-versions.json", "version_json": "%{name}-versions.json",
} },
) )
def _vulcanize_impl(ctx): def _vulcanize_impl(ctx):
@ -345,33 +334,39 @@ def _vulcanize_impl(ctx):
command = hermetic_npm_command, command = hermetic_npm_command,
**node_tweaks) **node_tweaks)
_vulcanize_rule = rule( _vulcanize_rule = rule(
_vulcanize_impl, _vulcanize_impl,
attrs = { attrs = {
"deps": attr.label_list(providers=["transitive_zipfiles"]), "deps": attr.label_list(providers = ["transitive_zipfiles"]),
"app": attr.label(mandatory=True, allow_single_file=True), "app": attr.label(
"srcs": attr.label_list(allow_files=[".js", ".html", ".txt", ".css", ".ico"]), mandatory = True,
allow_single_file = True,
"pkg": attr.string(mandatory=True), ),
"_run_npm": attr.label( "srcs": attr.label_list(allow_files = [
default=Label("//tools/js:run_npm_binary.py"), ".js",
allow_single_file=True ".html",
), ".txt",
"_vulcanize_archive": attr.label( ".css",
default=Label("@vulcanize//:%s" % _npm_tarball("vulcanize")), ".ico",
allow_single_file=True ]),
), "pkg": attr.string(mandatory = True),
"_crisper_archive": attr.label( "_run_npm": attr.label(
default=Label("@crisper//:%s" % _npm_tarball("crisper")), default = Label("//tools/js:run_npm_binary.py"),
allow_single_file=True allow_single_file = True,
), ),
}, "_vulcanize_archive": attr.label(
outputs = { default = Label("@vulcanize//:%s" % _npm_tarball("vulcanize")),
"html": "%{name}.html", allow_single_file = True,
"js": "%{name}.js", ),
} "_crisper_archive": attr.label(
default = Label("@crisper//:%s" % _npm_tarball("crisper")),
allow_single_file = True,
),
},
outputs = {
"html": "%{name}.html",
"js": "%{name}.js",
},
) )
def vulcanize(*args, **kwargs): def vulcanize(*args, **kwargs):

View File

@ -1,4 +1,3 @@
def normalize_target_name(target): def normalize_target_name(target):
return target.replace("//", "").replace("/", "__").replace(":", "___") return target.replace("//", "").replace("/", "__").replace(":", "___")

View File

@ -1,7 +1,10 @@
GERRIT = 'GERRIT:' GERRIT = "GERRIT:"
GERRIT_API = 'GERRIT_API:'
MAVEN_CENTRAL = 'MAVEN_CENTRAL:' GERRIT_API = "GERRIT_API:"
MAVEN_LOCAL = 'MAVEN_LOCAL:'
MAVEN_CENTRAL = "MAVEN_CENTRAL:"
MAVEN_LOCAL = "MAVEN_LOCAL:"
def _maven_release(ctx, parts): def _maven_release(ctx, parts):
"""induce jar and url name from maven coordinates.""" """induce jar and url name from maven coordinates."""
@ -116,16 +119,17 @@ def _maven_jar_impl(ctx):
_generate_build_file(ctx, binjar, srcjar) _generate_build_file(ctx, binjar, srcjar)
maven_jar=repository_rule( maven_jar = repository_rule(
implementation=_maven_jar_impl, attrs = {
local=True, "artifact": attr.string(mandatory = True),
attrs={ "sha1": attr.string(mandatory = True),
"artifact": attr.string(mandatory=True), "src_sha1": attr.string(),
"sha1": attr.string(mandatory=True), "_download_script": attr.label(default = Label("//tools:download_file.py")),
"src_sha1": attr.string(), "repository": attr.string(default = MAVEN_CENTRAL),
"_download_script": attr.label(default=Label("//tools:download_file.py")), "attach_source": attr.bool(default = True),
"repository": attr.string(default=MAVEN_CENTRAL), "unsign": attr.bool(default = False),
"attach_source": attr.bool(default=True), "exclude": attr.string_list(),
"unsign": attr.bool(default=False), },
"exclude": attr.string_list(), local = True,
}) implementation = _maven_jar_impl,
)

View File

@ -14,18 +14,18 @@
# War packaging. # War packaging.
jar_filetype = FileType(['.jar']) jar_filetype = FileType([".jar"])
LIBS = [ LIBS = [
'//gerrit-war:init', "//gerrit-war:init",
'//gerrit-war:log4j-config', "//gerrit-war:log4j-config",
'//gerrit-war:version', "//gerrit-war:version",
'//lib:postgresql', "//lib:postgresql",
'//lib/log:impl_log4j', "//lib/log:impl_log4j",
] ]
PGMLIBS = [ PGMLIBS = [
'//gerrit-pgm:pgm' "//gerrit-pgm:pgm",
] ]
def _add_context(in_file, output): def _add_context(in_file, output):
@ -122,13 +122,13 @@ def _war_impl(ctx):
# libs: go to the WEB-INF/lib directory # libs: go to the WEB-INF/lib directory
# pgmlibs: go to the WEB-INF/pgm-lib directory # pgmlibs: go to the WEB-INF/pgm-lib directory
_pkg_war = rule( _pkg_war = rule(
attrs = { attrs = {
'context': attr.label_list(allow_files = True), "context": attr.label_list(allow_files = True),
'libs': attr.label_list(allow_files = jar_filetype), "libs": attr.label_list(allow_files = jar_filetype),
'pgmlibs': attr.label_list(allow_files = False), "pgmlibs": attr.label_list(allow_files = False),
}, },
implementation = _war_impl, outputs = {"war": "%{name}.war"},
outputs = {'war' : '%{name}.war'}, implementation = _war_impl,
) )
def pkg_war(name, ui = 'ui_optdbg', context = [], doc = False, **kwargs): def pkg_war(name, ui = 'ui_optdbg', context = [], doc = False, **kwargs):

View File

@ -1,8 +1,14 @@
load('//tools/bzl:genrule2.bzl', 'genrule2') load("//tools/bzl:genrule2.bzl", "genrule2")
load('//tools/bzl:gwt.bzl', 'GWT_PLUGIN_DEPS', load(
'GWT_PLUGIN_DEPS_NEVERLINK', 'GWT_TRANSITIVE_DEPS', "//tools/bzl:gwt.bzl",
'GWT_COMPILER_ARGS', 'PLUGIN_DEPS_NEVERLINK', "GWT_PLUGIN_DEPS",
'GWT_JVM_ARGS', 'gwt_binary') "GWT_PLUGIN_DEPS_NEVERLINK",
"GWT_TRANSITIVE_DEPS",
"GWT_COMPILER_ARGS",
"PLUGIN_DEPS_NEVERLINK",
"GWT_JVM_ARGS",
"gwt_binary",
)
def gerrit_plugin( def gerrit_plugin(
name, name,

View File

@ -1,12 +1,12 @@
CORE_PLUGINS = [ CORE_PLUGINS = [
'commit-message-length-validator', "commit-message-length-validator",
'download-commands', "download-commands",
'hooks', "hooks",
'replication', "replication",
'reviewnotes', "reviewnotes",
'singleusergroup', "singleusergroup",
] ]
CUSTOM_PLUGINS = [ CUSTOM_PLUGINS = [
'cookbook-plugin', "cookbook-plugin",
] ]

View File

@ -12,15 +12,16 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
sh_bang_template = (' && '.join([ sh_bang_template = (" && ".join([
"echo '#!/bin/bash -e' > $@", "echo '#!/bin/bash -e' > $@",
'echo "# this script should run from the root of your workspace." >> $@', "echo \"# this script should run from the root of your workspace.\" >> $@",
'echo "" >> $@', "echo \"\" >> $@",
"echo 'if [[ \"$$VERBOSE\" ]]; then set -x ; fi' >> $@", "echo 'if [[ \"$$VERBOSE\" ]]; then set -x ; fi' >> $@",
'echo "" >> $@', "echo \"\" >> $@",
'echo %s >> $@', "echo %s >> $@",
'echo "" >> $@', "echo \"\" >> $@",
'echo %s >> $@'])) "echo %s >> $@",
]))
def maven_package( def maven_package(
version, version,