Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 1 | # 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 Pearce | 5047911 | 2013-07-29 17:30:50 -0700 | [diff] [blame] | 15 | # These definitions support building a runnable version of Gerrit. |
| 16 | |
David Ostrovsky | d8af092 | 2014-05-30 12:42:32 +0200 | [diff] [blame] | 17 | DOCS_HTML = '//Documentation:html' |
Yuxuan 'fishy' Wang | ec4b06a | 2013-10-14 12:39:30 -0700 | [diff] [blame] | 18 | DOCS_LIB = '//Documentation:index_lib' |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 19 | LIBS = [ |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 20 | '//gerrit-war:log4j-config', |
Shawn Pearce | 1e6c363 | 2013-07-29 13:26:47 -0700 | [diff] [blame] | 21 | '//gerrit-war:init', |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 22 | '//lib:postgresql', |
| 23 | '//lib/log:impl_log4j', |
| 24 | ] |
| 25 | PGMLIBS = ['//gerrit-pgm:pgm'] |
| 26 | |
| 27 | def 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 Pearce | 3349972 | 2014-05-02 13:22:49 -0700 | [diff] [blame] | 32 | deps.append('//plugins/%s:%s__plugin' % (n, n)) |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 33 | return deps |
| 34 | |
| 35 | def war( |
| 36 | name, |
| 37 | libs = [], |
| 38 | pgmlibs = [], |
| 39 | context = [], |
Yuxuan 'fishy' Wang | ec4b06a | 2013-10-14 12:39:30 -0700 | [diff] [blame] | 40 | visibility = [], |
| 41 | docs = False |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 42 | ): |
Shawn Pearce | 55583ac | 2013-10-17 20:29:05 -0700 | [diff] [blame] | 43 | cmd = ['$(exe //tools:pack_war)', '-o', '$OUT', '--tmp', '$TMP'] |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 44 | for l in libs: |
| 45 | cmd.extend(['--lib', l]) |
| 46 | for l in pgmlibs: |
| 47 | cmd.extend(['--pgmlib', l]) |
| 48 | |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 49 | dep = [] |
Yuxuan 'fishy' Wang | ec4b06a | 2013-10-14 12:39:30 -0700 | [diff] [blame] | 50 | if docs: |
David Ostrovsky | d8af092 | 2014-05-30 12:42:32 +0200 | [diff] [blame] | 51 | cmd.append('$(location %s)' % DOCS_HTML) |
David Ostrovsky | d8af092 | 2014-05-30 12:42:32 +0200 | [diff] [blame] | 52 | dep.append(DOCS_LIB) |
Yuxuan 'fishy' Wang | ec4b06a | 2013-10-14 12:39:30 -0700 | [diff] [blame] | 53 | cmd.extend(['--lib', DOCS_LIB]) |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 54 | if context: |
Shawn Pearce | 06e069c | 2014-05-13 15:57:36 -0700 | [diff] [blame] | 55 | for t in context: |
Shawn Pearce | 06e069c | 2014-05-13 15:57:36 -0700 | [diff] [blame] | 56 | cmd.append('$(location %s)' % t) |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 57 | |
| 58 | genrule( |
| 59 | name = name, |
| 60 | cmd = ' '.join(cmd), |
David Ostrovsky | 5dacc8b | 2014-06-10 03:01:28 +0200 | [diff] [blame] | 61 | deps = libs + pgmlibs + dep, |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 62 | out = name + '.war', |
| 63 | visibility = visibility, |
| 64 | ) |
| 65 | |
Jonathan Nieder | f24b7f9 | 2014-05-01 12:44:01 -0700 | [diff] [blame] | 66 | def gerrit_war(name, ui = 'ui_optdbg', context = [], docs = False, visibility = []): |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 67 | war( |
| 68 | name = name, |
Shawn Pearce | 1e6c363 | 2013-07-29 13:26:47 -0700 | [diff] [blame] | 69 | libs = LIBS + ['//gerrit-war:version'], |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 70 | pgmlibs = PGMLIBS, |
| 71 | context = [ |
Shawn Pearce | 06e069c | 2014-05-13 15:57:36 -0700 | [diff] [blame] | 72 | '//gerrit-main:main_bin', |
| 73 | '//gerrit-war:webapp_assets', |
| 74 | '//gerrit-gwtui:' + ui, |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 75 | ] + context, |
Yuxuan 'fishy' Wang | ec4b06a | 2013-10-14 12:39:30 -0700 | [diff] [blame] | 76 | docs = docs, |
Dariusz Luksza | 3ffc86a | 2014-04-30 13:01:19 +0200 | [diff] [blame] | 77 | visibility = visibility, |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 78 | ) |