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 | |
| 15 | BROWSERS = [ |
| 16 | 'chrome', |
| 17 | 'firefox', |
| 18 | 'gecko1_8', |
| 19 | 'safari', |
| 20 | 'msie', 'ie6', 'ie8', 'ie9', |
| 21 | ] |
| 22 | ALIASES = { |
| 23 | 'chrome': 'safari', |
| 24 | 'firefox': 'gecko1_8', |
| 25 | 'msie': 'ie9', |
| 26 | } |
| 27 | MODULE = 'com.google.gerrit.GerritGwtUI' |
| 28 | |
| 29 | DEBUG_OPTS = [ |
| 30 | '-style', 'PRETTY', |
| 31 | '-optimize', '0', |
| 32 | ] |
| 33 | |
Shawn Pearce | 8f1c7fd | 2013-05-10 14:01:43 -0700 | [diff] [blame] | 34 | APP_DEPS = [':ui_module'] |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 35 | |
| 36 | def gwt_user_agent_permutations( |
| 37 | name, |
| 38 | module_name, |
| 39 | module_target, |
| 40 | compiler_opts = [], |
| 41 | deps = [], |
| 42 | browsers = [], |
| 43 | visibility = []): |
| 44 | for ua in browsers: |
| 45 | impl = ua |
| 46 | if ua in ALIASES: |
| 47 | impl = ALIASES[ua] |
| 48 | xml = ''.join([ |
| 49 | "<module rename-to='%s'>" % module_name, |
| 50 | "<inherits name='%s'/>" % module_target, |
| 51 | "<set-property name='user.agent' value='%s'/>" % impl, |
| 52 | "<set-property name='locale' value='default'/>", |
| 53 | "</module>", |
| 54 | ]) |
Shawn Pearce | 11d27c8 | 2013-07-24 08:09:31 -0700 | [diff] [blame] | 55 | gwt = '%s_%s.gwt.xml' % (module_target.replace('.', '/'), ua) |
| 56 | jar = '%s_%s.gwtxml.jar' % (name, ua) |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 57 | genrule( |
| 58 | name = '%s_%s_gwtxml_gen' % (name, ua), |
Shawn Pearce | 11d27c8 | 2013-07-24 08:09:31 -0700 | [diff] [blame] | 59 | cmd = 'cd $TMP;' + |
| 60 | ('mkdir -p $(dirname %s);' % gwt) + |
| 61 | ('echo "%s">%s;' % (xml, gwt)) + |
| 62 | 'zip -qr $OUT .', |
| 63 | out = jar, |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 64 | ) |
Shawn Pearce | 11d27c8 | 2013-07-24 08:09:31 -0700 | [diff] [blame] | 65 | prebuilt_jar( |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 66 | name = '%s_%s_gwtxml_lib' % (name, ua), |
Shawn Pearce | 11d27c8 | 2013-07-24 08:09:31 -0700 | [diff] [blame] | 67 | binary_jar = genfile(jar), |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 68 | deps = [':%s_%s_gwtxml_gen' % (name, ua)], |
| 69 | ) |
| 70 | gwt_application( |
| 71 | name = '%s_%s' % (name, ua), |
| 72 | module_target = module_target + '_' + ua, |
| 73 | compiler_opts = compiler_opts, |
| 74 | deps = deps + [':%s_%s_gwtxml_lib' % (name, ua)], |
| 75 | visibility = visibility, |
| 76 | ) |
| 77 | |