blob: 8b858cdda9fc855f41217fc22bdb56a03e29e2ff [file] [log] [blame]
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -07001# Copyright (C) 2013 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
Shawn Pearce50479112013-07-29 17:30:50 -070015# These definitions support building a runnable version of Gerrit.
16
David Ostrovskyd8af0922014-05-30 12:42:32 +020017DOCS_HTML = '//Documentation:html'
Yuxuan 'fishy' Wangec4b06a2013-10-14 12:39:30 -070018DOCS_LIB = '//Documentation:index_lib'
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070019LIBS = [
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070020 '//gerrit-war:log4j-config',
Shawn Pearce1e6c3632013-07-29 13:26:47 -070021 '//gerrit-war:init',
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070022 '//lib:postgresql',
23 '//lib/log:impl_log4j',
24]
25PGMLIBS = ['//gerrit-pgm:pgm']
26
27def scan_plugins():
28 import os
29 deps = []
30 for n in os.listdir('plugins'):
31 if os.path.exists(os.path.join('plugins', n, 'BUCK')):
Shawn Pearce33499722014-05-02 13:22:49 -070032 deps.append('//plugins/%s:%s__plugin' % (n, n))
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070033 return deps
34
35def war(
36 name,
37 libs = [],
38 pgmlibs = [],
39 context = [],
Yuxuan 'fishy' Wangec4b06a2013-10-14 12:39:30 -070040 visibility = [],
41 docs = False
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070042 ):
Shawn Pearce55583ac2013-10-17 20:29:05 -070043 cmd = ['$(exe //tools:pack_war)', '-o', '$OUT', '--tmp', '$TMP']
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070044 for l in libs:
45 cmd.extend(['--lib', l])
46 for l in pgmlibs:
47 cmd.extend(['--pgmlib', l])
48
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070049 dep = []
Yuxuan 'fishy' Wangec4b06a2013-10-14 12:39:30 -070050 if docs:
David Ostrovskyd8af0922014-05-30 12:42:32 +020051 cmd.append('$(location %s)' % DOCS_HTML)
David Ostrovskyd8af0922014-05-30 12:42:32 +020052 dep.append(DOCS_LIB)
Yuxuan 'fishy' Wangec4b06a2013-10-14 12:39:30 -070053 cmd.extend(['--lib', DOCS_LIB])
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070054 if context:
Shawn Pearce06e069c2014-05-13 15:57:36 -070055 for t in context:
Shawn Pearce06e069c2014-05-13 15:57:36 -070056 cmd.append('$(location %s)' % t)
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070057
58 genrule(
59 name = name,
60 cmd = ' '.join(cmd),
David Ostrovsky5dacc8b2014-06-10 03:01:28 +020061 deps = libs + pgmlibs + dep,
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070062 out = name + '.war',
63 visibility = visibility,
64 )
65
Jonathan Niederf24b7f92014-05-01 12:44:01 -070066def gerrit_war(name, ui = 'ui_optdbg', context = [], docs = False, visibility = []):
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070067 war(
68 name = name,
Shawn Pearce1e6c3632013-07-29 13:26:47 -070069 libs = LIBS + ['//gerrit-war:version'],
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070070 pgmlibs = PGMLIBS,
71 context = [
Shawn Pearce06e069c2014-05-13 15:57:36 -070072 '//gerrit-main:main_bin',
73 '//gerrit-war:webapp_assets',
74 '//gerrit-gwtui:' + ui,
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070075 ] + context,
Yuxuan 'fishy' Wangec4b06a2013-10-14 12:39:30 -070076 docs = docs,
Dariusz Luksza3ffc86a2014-04-30 13:01:19 +020077 visibility = visibility,
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070078 )