Buck: Align gerrit build interface to bucklets

Bucklets are reusable building blocks for buck driven build. Many
bucklets match Gerrit's own methods and were derived from them. To
enable buck driven build of gerrit plugins bucklets, are used. This
simplifies the implementation without need of code duplication. The
problem is however, that unlike maven driven build, in gerrit tree
build mode is supported for plugins.  Because of mismatch of buck
build interface between gerrit core and bucklets this currently can
not be done. This change synchronizes the interfaces between gerrit
and bucklets by exposing building blocks that are shared between gerrit
and bucklets in own files and linking them from bucklets directory.
That way bucklets can be (re-)used from both build modes: in gerrit
tree and standalone.

Change-Id: I8457b99936f009b4bc531f3b5633e4f19cb3b676
This commit is contained in:
David Ostrovsky
2014-07-19 22:43:36 +02:00
committed by David Ostrovsky
parent ec3b956e93
commit 188bd78785
9 changed files with 88 additions and 81 deletions

1
bucklets/java_doc.bucklet Symbolic link
View File

@@ -0,0 +1 @@
../tools/java_doc.defs

View File

@@ -0,0 +1 @@
../tools/java_sources.defs

1
bucklets/local_jar.bucklet Symbolic link
View File

@@ -0,0 +1 @@
../lib/local.defs

View File

@@ -0,0 +1 @@
../tools/maven/package.defs

33
lib/local.defs Normal file
View File

@@ -0,0 +1,33 @@
def local_jar(
name,
jar,
src = None,
deps = [],
visibility = ['PUBLIC']):
binjar = name + '.jar'
srcjar = name + '-src.jar'
genrule(
name = '%s__local_bin' % name,
cmd = 'ln -s %s $OUT' % jar,
out = binjar)
if src:
genrule(
name = '%s__local_src' % name,
cmd = 'ln -s %s $OUT' % src,
out = srcjar)
prebuilt_jar(
name = '%s_src' % name,
binary_jar = ':%s__local_src' % name,
visibility = visibility,
)
else:
srcjar = None
prebuilt_jar(
name = name,
deps = deps,
binary_jar = ':%s__local_bin' % name,
source_jar = ':%s__local_src' % name if srcjar else None,
visibility = visibility,
)

View File

@@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
include_defs('//lib/local.defs')
ATLASSIAN = 'ATLASSIAN:'
GERRIT = 'GERRIT:'
GERRIT_API = 'GERRIT_API:'
@@ -135,35 +137,3 @@ def maven_jar(
visibility = visibility,
)
def local_jar(
name,
jar,
src = None,
deps = [],
visibility = ['PUBLIC']):
binjar = name + '.jar'
srcjar = name + '-src.jar'
genrule(
name = '%s__local_bin' % name,
cmd = 'ln -s %s $OUT' % jar,
out = binjar)
if src:
genrule(
name = '%s__local_src' % name,
cmd = 'ln -s %s $OUT' % src,
out = srcjar)
prebuilt_jar(
name = '%s_src' % name,
binary_jar = ':%s__local_src' % name,
visibility = visibility,
)
else:
srcjar = None
prebuilt_jar(
name = name,
deps = deps,
binary_jar = ':%s__local_bin' % name,
source_jar = ':%s__local_src' % name if srcjar else None,
visibility = visibility,
)

View File

@@ -15,6 +15,8 @@
# Rule definitions loaded by default into every BUCK file.
include_defs('//tools/gwt-constants.defs')
include_defs('//tools/java_doc.defs')
include_defs('//tools/java_sources.defs')
import copy
def genantlr(
@@ -144,52 +146,3 @@ def gerrit_plugin(
] + static_jars,
visibility = visibility,
)
def java_sources(
name,
srcs,
visibility = []
):
java_library(
name = name,
resources = srcs,
visibility = visibility,
)
def java_doc(
name,
title,
pkg,
paths,
srcs = [],
deps = [],
visibility = [],
do_it_wrong = False,
):
if do_it_wrong:
sourcepath = paths
else:
sourcepath = ['$SRCDIR/' + n for n in paths]
genrule(
name = name,
cmd = ' '.join([
'while ! test -f .buckconfig; do cd ..; done;',
'javadoc',
'-quiet',
'-protected',
'-encoding UTF-8',
'-charset UTF-8',
'-notimestamp',
'-windowtitle "' + title + '"',
'-link http://docs.oracle.com/javase/7/docs/api',
'-subpackages ' + pkg,
'-sourcepath ',
':'.join(sourcepath),
' -classpath ',
':'.join(['$(location %s)' % n for n in deps]),
'-d $TMP',
]) + ';jar cf $OUT -C $TMP .',
srcs = srcs,
out = name + '.jar',
visibility = visibility,
)

37
tools/java_doc.defs Normal file
View File

@@ -0,0 +1,37 @@
def java_doc(
name,
title,
pkg,
paths,
srcs = [],
deps = [],
visibility = [],
do_it_wrong = False,
):
if do_it_wrong:
sourcepath = paths
else:
sourcepath = ['$SRCDIR/' + n for n in paths]
genrule(
name = name,
cmd = ' '.join([
'while ! test -f .buckconfig; do cd ..; done;',
'javadoc',
'-quiet',
'-protected',
'-encoding UTF-8',
'-charset UTF-8',
'-notimestamp',
'-windowtitle "' + title + '"',
'-link http://docs.oracle.com/javase/7/docs/api',
'-subpackages ' + pkg,
'-sourcepath ',
':'.join(sourcepath),
' -classpath ',
':'.join(['$(location %s)' % n for n in deps]),
'-d $TMP',
]) + ';jar cf $OUT -C $TMP .',
srcs = srcs,
out = name + '.jar',
visibility = visibility,
)

10
tools/java_sources.defs Normal file
View File

@@ -0,0 +1,10 @@
def java_sources(
name,
srcs,
visibility = []
):
java_library(
name = name,
resources = srcs,
visibility = visibility,
)