This version fixes this bug [1] that allows us to eliminate these ugly shell backticks and switch again to escaped macro like invocations: \$(dirname $OUT) [1] https://github.com/facebook/buck/issues/212 Change-Id: Ie43b3ff6dfc89c4d840f2ff75c64ac0a5c6346b6
		
			
				
	
	
		
			83 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			83 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
# Copyright (C) 2013 The Android Open Source Project
 | 
						|
#
 | 
						|
# Licensed under the Apache License, Version 2.0 (the "License");
 | 
						|
# you may not use this file except in compliance with the License.
 | 
						|
# You may obtain a copy of the License at
 | 
						|
#
 | 
						|
# http://www.apache.org/licenses/LICENSE-2.0
 | 
						|
#
 | 
						|
# Unless required by applicable law or agreed to in writing, software
 | 
						|
# distributed under the License is distributed on an "AS IS" BASIS,
 | 
						|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
						|
# See the License for the specific language governing permissions and
 | 
						|
# limitations under the License.
 | 
						|
 | 
						|
BROWSERS = [
 | 
						|
  'chrome',
 | 
						|
  'firefox',
 | 
						|
  'gecko1_8',
 | 
						|
  'safari',
 | 
						|
  'msie', 'ie6', 'ie8', 'ie9',
 | 
						|
]
 | 
						|
ALIASES = {
 | 
						|
  'chrome': 'safari',
 | 
						|
  'firefox': 'gecko1_8',
 | 
						|
  'msie': 'ie9',
 | 
						|
}
 | 
						|
MODULE = 'com.google.gerrit.GerritGwtUI'
 | 
						|
 | 
						|
def gwt_user_agent_permutations(
 | 
						|
    name,
 | 
						|
    module_name,
 | 
						|
    modules,
 | 
						|
    style = 'PRETTY',
 | 
						|
    optimize = 0,
 | 
						|
    draft_compile = True,
 | 
						|
    module_deps = [],
 | 
						|
    deps = [],
 | 
						|
    browsers = BROWSERS,
 | 
						|
    visibility = []):
 | 
						|
  from multiprocessing import cpu_count
 | 
						|
  for ua in browsers:
 | 
						|
    impl = ua
 | 
						|
    if ua in ALIASES:
 | 
						|
      impl = ALIASES[ua]
 | 
						|
    xml = ''.join([
 | 
						|
      "<module rename-to='%s'>" % module_name,
 | 
						|
      "<inherits name='%s'/>" % modules[0],
 | 
						|
      "<set-property name='user.agent' value='%s'/>" % impl,
 | 
						|
      "<set-property name='locale' value='default'/>",
 | 
						|
      "</module>",
 | 
						|
    ])
 | 
						|
    gwt = '%s_%s.gwt.xml' % (modules[0].replace('.', '/'), ua)
 | 
						|
    gwt_name = '%s_%s' % (name, ua)
 | 
						|
    jar = '%s.gwtxml.jar' % (gwt_name)
 | 
						|
 | 
						|
    genrule(
 | 
						|
      name = '%s_gwtxml_gen' % gwt_name,
 | 
						|
      cmd = 'cd $TMP;' +
 | 
						|
        ('mkdir -p \$(dirname %s);' % gwt) +
 | 
						|
        ('echo "%s">%s;' % (xml, gwt)) +
 | 
						|
        'zip -qr $OUT .',
 | 
						|
      out = jar,
 | 
						|
    )
 | 
						|
    prebuilt_jar(
 | 
						|
      name = '%s_gwtxml_lib' % gwt_name,
 | 
						|
      binary_jar = ':%s_gwtxml_gen' % gwt_name,
 | 
						|
      gwt_jar = ':%s_gwtxml_gen' % gwt_name,
 | 
						|
    )
 | 
						|
    gwt_binary(
 | 
						|
      name = gwt_name,
 | 
						|
      modules = [modules[0] + '_' + ua],
 | 
						|
      style = style,
 | 
						|
      optimize = optimize,
 | 
						|
      draft_compile = draft_compile,
 | 
						|
      module_deps = module_deps + [':%s_gwtxml_lib' % gwt_name],
 | 
						|
      deps = deps,
 | 
						|
      local_workers = cpu_count(),
 | 
						|
      strict = True,
 | 
						|
      experimental_args = GWT_COMPILER_ARGS,
 | 
						|
      vm_args = GWT_JVM_ARGS,
 | 
						|
      visibility = visibility,
 | 
						|
    )
 |