Commit 763498c0 authored by newt@chromium.org's avatar newt@chromium.org

Allow "cross-compiling" with GRIT

This adds an explicit "platform" option to repack_locales.py, so
resources for one platform (e.g. Android) can be compiled on another
(e.g. Linux).

BUG=136951


Review URL: https://chromiumcodereview.appspot.com/10830085

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149488 0039d316-1c4b-4281-b951-d872f2087c98
parent 4f5d5446
......@@ -603,7 +603,7 @@
'shell/cocoa/nibs/MainMenu.xib',
'shell/cocoa/nibs/RootWindow.xib',
'<(SHARED_INTERMEDIATE_DIR)/repack/chrome.pak',
'<!@pymod_do_main(repack_locales -o -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(SHARED_INTERMEDIATE_DIR) <(locales))',
'<!@pymod_do_main(repack_locales -o -p <(OS) -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(SHARED_INTERMEDIATE_DIR) <(locales))',
],
'mac_bundle_resources!': [
'shell/cocoa/app-Info.plist',
......
......@@ -292,7 +292,7 @@
'<(SHARED_INTERMEDIATE_DIR)/repack/resources.pak',
'<(grit_out_dir)/theme_resources_100_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_resources_100_percent.pak',
'<!@pymod_do_main(repack_locales -o -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(SHARED_INTERMEDIATE_DIR) <(locales))',
'<!@pymod_do_main(repack_locales -o -p <(OS) -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(SHARED_INTERMEDIATE_DIR) <(locales))',
# Note: pseudo_locales are generated via the packed_resources
# dependency but not copied to the final target. See
# common.gypi for more info.
......
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
......@@ -14,10 +14,10 @@
},
'inputs': [
'tools/build/repack_locales.py',
'<!@pymod_do_main(repack_locales -i <(branding_flag) -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(INTERMEDIATE_DIR) <(locales))'
'<!@pymod_do_main(repack_locales -i -p <(OS) <(branding_flag) -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(INTERMEDIATE_DIR) <(locales))'
],
'outputs': [
'<!@pymod_do_main(repack_locales -o -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(SHARED_INTERMEDIATE_DIR) <(locales))'
'<!@pymod_do_main(repack_locales -o -p <(OS) -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(SHARED_INTERMEDIATE_DIR) <(locales))'
],
'action': [
'<@(repack_locales_cmd)',
......
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
......@@ -14,12 +14,12 @@
},
'inputs': [
'tools/build/repack_locales.py',
'<!@pymod_do_main(repack_locales -i <(branding_flag) -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(INTERMEDIATE_DIR) <(pseudo_locales))'
'<!@pymod_do_main(repack_locales -i -p <(OS) <(branding_flag) -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(INTERMEDIATE_DIR) <(pseudo_locales))'
],
'conditions': [
['OS == "mac"', {
'outputs': [
'<!@pymod_do_main(repack_locales -o -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(SHARED_INTERMEDIATE_DIR) <(pseudo_locales))'
'<!@pymod_do_main(repack_locales -o -p <(OS) -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(SHARED_INTERMEDIATE_DIR) <(pseudo_locales))'
],
}, { # else 'OS != "mac"'
'outputs': [
......
......@@ -345,13 +345,13 @@
{
'destination': '<(PRODUCT_DIR)/locales',
'files': [
'<!@pymod_do_main(repack_locales -o -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(SHARED_INTERMEDIATE_DIR) <(locales))'
'<!@pymod_do_main(repack_locales -o -p <(OS) -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(SHARED_INTERMEDIATE_DIR) <(locales))'
],
},
{
'destination': '<(PRODUCT_DIR)/pseudo_locales',
'files': [
'<!@pymod_do_main(repack_locales -o -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(SHARED_INTERMEDIATE_DIR) <(pseudo_locales))'
'<!@pymod_do_main(repack_locales -o -p <(OS) -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(SHARED_INTERMEDIATE_DIR) <(pseudo_locales))'
],
},
],
......
......@@ -26,6 +26,8 @@ GRIT_DIR = None
SHARE_INT_DIR = None
INT_DIR = None
# The target platform. If it is not defined, sys.platform will be used.
OS = None
class Usage(Exception):
def __init__(self, msg):
......@@ -39,7 +41,7 @@ def calc_output(locale):
# reference it.
if locale == 'fake-bidi':
return '%s/%s.pak' % (INT_DIR, locale)
if sys.platform in ('darwin',):
if OS == 'mac':
# For Cocoa to find the locale at runtime, it needs to use '_' instead
# of '-' (http://crbug.com/20441). Also, 'en-US' should be represented
# simply as 'en' (http://crbug.com/19165, http://crbug.com/25578).
......@@ -131,8 +133,9 @@ def DoMain(argv):
global GRIT_DIR
global SHARE_INT_DIR
global INT_DIR
global OS
short_options = 'iog:s:x:b:h'
short_options = 'iog:s:x:b:hp:'
long_options = 'help'
print_inputs = False
......@@ -140,7 +143,8 @@ def DoMain(argv):
usage_msg = ''
helpstr = """\
Usage: %s [-h] [-i | -o] -g <DIR> -x <DIR> -s <DIR> -b <branding> <locale> [...]
Usage: %s [-h] [-i | -o] -g <DIR> -x <DIR> -s <DIR> -b <branding> [-p <os>]
<locale> [...]
-h, --help Print this help, then exit.
-i Print the expected input file list, then exit.
-o Print the expected output file list, then exit.
......@@ -148,6 +152,7 @@ Usage: %s [-h] [-i | -o] -g <DIR> -x <DIR> -s <DIR> -b <branding> <locale> [...
-x DIR Intermediate build files output directory.
-s DIR Shared intermediate build files output directory.
-b branding Branding type of this build.
-p os The target os. (e.g. mac, linux, win, etc.)
locale [...] One or more locales to repack.""" % (
os.path.basename(__file__))
......@@ -160,21 +165,33 @@ Usage: %s [-h] [-i | -o] -g <DIR> -x <DIR> -s <DIR> -b <branding> <locale> [...
usage_msg = 'Please specificy at least one locale to process.\n'
for o, a in opts:
if o in ('-i'):
if o == '-i':
print_inputs = True
elif o in ('-o'):
elif o == '-o':
print_outputs = True
elif o in ('-g'):
elif o == '-g':
GRIT_DIR = a
elif o in ('-s'):
elif o == '-s':
SHARE_INT_DIR = a
elif o in ('-x'):
elif o == '-x':
INT_DIR = a
elif o in ('-b'):
elif o == '-b':
BRANDING = a
elif o == '-p':
OS = a
elif o in ('-h', '--help'):
raise Usage(helpstr)
if not OS:
if sys.platform == 'darwin':
OS = 'mac'
elif sys.platform.startswith('linux'):
OS = 'linux'
elif sys.platform in ('cygwin', 'win32'):
OS = 'win'
else:
OS = sys.platform
if not (GRIT_DIR and INT_DIR and SHARE_INT_DIR):
usage_msg += 'Please specify all of "-g" and "-x" and "-s".\n'
if print_inputs and print_outputs:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment