Skip to content

Commit

Permalink
Refactor grit -D flags into a gyp variable so we don't
Browse files Browse the repository at this point in the history
have to repeat the logic for it in a bunch of different places.

I had to add another level of variables{} so I could use use_titlecase_in_grd_files in a condition.  I also removed some quotes around default values since that seems to be the more common way to express boolean values.

BUG=68028

Review URL: http://codereview.chromium.org/6070011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70757 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
tony@chromium.org committed Jan 7, 2011
1 parent 674731c commit bb6aba3
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 105 deletions.
19 changes: 4 additions & 15 deletions app/app.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,9 @@
'>!@(<(apply_locales_cmd) \'<(grit_out_dir)/<(RULE_INPUT_ROOT)/<(RULE_INPUT_ROOT)_ZZLOCALE.pak\' <(locales))',
],
'action': ['<@(grit_cmd)', '-i', '<(RULE_INPUT_PATH)',
'build', '-o', '<(grit_out_dir)/<(RULE_INPUT_ROOT)'],
'build', '-o', '<(grit_out_dir)/<(RULE_INPUT_ROOT)',
'<@(grit_defines)'],
'message': 'Generating resources from <(RULE_INPUT_PATH)',
'conditions': [
['use_titlecase_in_grd_files==1', {
'action': ['-D', 'use_titlecase'],
}],
['chromeos==1', {
'action': ['-D', 'chromeos'],
}],
],
},
],
'sources': [
Expand Down Expand Up @@ -150,12 +143,8 @@
],
'action': ['<@(grit_cmd)',
'-i', '<(input_path)', 'build',
'-o', '<(grit_out_dir)/app_resources'],
'conditions': [
['toolkit_views==1', {
'action': ['-D', 'toolkit_views'],
}],
],
'-o', '<(grit_out_dir)/app_resources',
'<@(grit_defines)' ],
'message': 'Generating resources from <(input_path)',
},
],
Expand Down
70 changes: 48 additions & 22 deletions build/common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@
# we need to have 'chromeos' already set).
'variables': {
'variables': {
# Whether we're building a ChromeOS build.
'chromeos%': '0',
'variables': {
# Whether we're building a ChromeOS build.
'chromeos%': 0,

# Disable touch support by default.
'touchui%': 0,
# Disable touch support by default.
'touchui%': 0,
},
# Copy conditionally-set variables out one scope.
'chromeos%': '<(chromeos)',
'touchui%': '<(touchui)',

# To do a shared build on linux we need to be able to choose between
# type static_library and shared_library. We default to doing a static
Expand All @@ -42,6 +47,14 @@
}, { # OS!="linux"
'host_arch%': 'ia32',
}],

# Set default value of toolkit_views on for Windows, Chrome OS
# and the touch UI.
['OS=="win" or chromeos==1 or touchui==1', {
'toolkit_views%': 1,
}, {
'toolkit_views%': 0,
}],
],
},

Expand All @@ -50,6 +63,7 @@
'touchui%': '<(touchui)',
'host_arch%': '<(host_arch)',
'library%': '<(library)',
'toolkit_views%': '<(toolkit_views)',

# Override branding to select the desired branding flavor.
'branding%': 'Chromium',
Expand Down Expand Up @@ -102,15 +116,10 @@
# it can be overriden by the GYP command line or by ~/.gyp/include.gypi.
'component%': '<(library)',

'conditions': [
# Set default value of toolkit_views on for Windows, Chrome OS
# and the touch UI.
['OS=="win" or chromeos==1 or touchui==1', {
'toolkit_views%': 1,
}, {
'toolkit_views%': 0,
}],
# Set to select the Title Case versions of strings in GRD files.
'use_titlecase_in_grd_files%': 0,

'conditions': [
# A flag to enable or disable our compile-time dependency
# on gnome-keyring. If that dependency is disabled, no gnome-keyring
# support will be available. This option is useful
Expand All @@ -129,6 +138,11 @@
'linux_fpic%': 1,
}],

['toolkit_views==0 or OS=="mac"', {
# GTK+ and Mac wants Title Case strings
'use_titlecase_in_grd_files%': 1,
}],

# Enable some hacks to support Flapper only on Chrome OS.
['chromeos==1', {
'enable_flapper_hacks%': 1,
Expand Down Expand Up @@ -158,6 +172,7 @@
'disable_sse2%': '<(disable_sse2)',
'library%': '<(library)',
'component%': '<(component)',
'use_titlecase_in_grd_files%': '<(use_titlecase_in_grd_files)',

# The release channel that this build targets. This is used to restrict
# channel-specific build options, like which installer packages to create.
Expand Down Expand Up @@ -277,9 +292,6 @@
# Set to 1 to link against libgnome-keyring instead of using dlopen().
'linux_link_gnome_keyring%': 0,

# Set to select the Title Case versions of strings in GRD files.
'use_titlecase_in_grd_files%': 0,

# Used to disable Native Client at compile time, for platforms where it
# isn't supported
'disable_nacl%': 0,
Expand Down Expand Up @@ -319,7 +331,7 @@
# This allows to use libcros from the current system, ie. /usr/lib/
# The cros_api will be pulled in as a static library, and all headers
# from the system include dirs.
'system_libcros%': '0',
'system_libcros%': 0,

# Remoting compilation is enabled by default. Set to 0 to disable.
'remoting%': 1,
Expand All @@ -335,6 +347,8 @@
'vi', 'zh-CN', 'zh-TW',
],

'grit_defines': [],

# Use Harfbuzz-NG instead of Harfbuzz.
# Under development: http://crbug.com/68551
'use_harfbuzz_ng%': 0,
Expand All @@ -355,15 +369,10 @@
['(branding=="Chrome" and buildtype=="Official")', {
'linux_dump_symbols%': 1,
}],
['toolkit_views==0', {
# GTK wants Title Case strings
'use_titlecase_in_grd_files%': 1,
}],
],
}], # OS=="linux" or OS=="freebsd" or OS=="openbsd"

['OS=="mac"', {
# Mac wants Title Case strings
'use_titlecase_in_grd_files%': 1,
'conditions': [
# mac_product_name is set to the name of the .app bundle as it should
# appear on disk. This duplicates data from
Expand All @@ -388,6 +397,7 @@
}],
],
}], # OS=="mac"

# Whether to use multiple cores to compile with visual studio. This is
# optional because it sometimes causes corruption on VS 2005.
# It is on by default on VS 2008 and off on VS 2005.
Expand All @@ -414,18 +424,34 @@
'NACL_WIN64',
],
}],

['OS=="mac" or (OS=="linux" and chromeos==0 and target_arch!="arm")', {
'use_cups%': 1,
}, {
'use_cups%': 0,
}],

# Set the relative path from this file to the GYP file of the JPEG
# library used by Chromium.
['use_libjpeg_turbo==1', {
'libjpeg_gyp_path': '../third_party/libjpeg_turbo/libjpeg.gyp',
}, {
'libjpeg_gyp_path': '../third_party/libjpeg/libjpeg.gyp',
}], # use_libjpeg_turbo==1

# Setup -D flags passed into grit.
['chromeos==1', {
'grit_defines': ['-D', 'chromeos'],
}],
['toolkit_views==1', {
'grit_defines': ['-D', 'toolkit_views'],
}],
['touchui==1', {
'grit_defines': ['-D', 'touchui'],
}],
['use_titlecase_in_grd_files==1', {
'grit_defines': ['-D', 'use_titlecase'],
}],
],
},
'target_defaults': {
Expand Down
60 changes: 8 additions & 52 deletions chrome/chrome.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,7 @@
'build', '-o', '<(grit_out_dir)',
'-D', '<(chrome_build)',
'-E', '<(branded_env)',
],
'conditions': [
['chromeos==1', {
'action': ['-D', 'chromeos'],
}],
['toolkit_views==1', {
'action': ['-D', 'toolkit_views'],
}],
['use_titlecase_in_grd_files==1', {
'action': ['-D', 'use_titlecase'],
}],
'<@(grit_defines)',
],
'message': 'Generating resources from <(RULE_INPUT_PATH)',
},
Expand Down Expand Up @@ -289,15 +279,8 @@
'action': ['<@(grit_cmd)', '-i',
'<(RULE_INPUT_PATH)',
'build', '-o', '<(grit_out_dir)',
'-D', '<(chrome_build)'],
'conditions': [
['chromeos==1', {
'action': ['-D', 'chromeos'],
}],
['use_titlecase_in_grd_files==1', {
'action': ['-D', 'use_titlecase'],
}],
],
'-D', '<(chrome_build)',
'<@(grit_defines)' ],
'message': 'Generating resources from <(RULE_INPUT_PATH)',
},
],
Expand Down Expand Up @@ -345,18 +328,8 @@
'<@(grit_cmd)',
'-i', '<(input_path)', 'build',
'-o', '<(grit_out_dir)',
'-D', '<(chrome_build)'
],
'conditions': [
['chromeos==1', {
'action': ['-D', 'chromeos'],
}],
['toolkit_views==1', {
'action': ['-D', 'toolkit_views'],
}],
['use_titlecase_in_grd_files==1', {
'action': ['-D', 'use_titlecase'],
}],
'-D', '<(chrome_build)',
'<@(grit_defines)',
],
'message': 'Generating resources from <(input_path)',
},
Expand Down Expand Up @@ -403,15 +376,8 @@
'<@(grit_cmd)',
'-i', '<(input_path)', 'build',
'-o', '<(grit_out_dir)',
'-D', '<(chrome_build)'
],
'conditions': [
['chromeos==1', {
'action': ['-D', 'chromeos'],
}],
['use_titlecase_in_grd_files==1', {
'action': ['-D', 'use_titlecase'],
}],
'-D', '<(chrome_build)',
'<@(grit_defines)',
],
'message': 'Generating resources from <(input_path)',
},
Expand Down Expand Up @@ -475,17 +441,7 @@
'build', '-o', '<(grit_out_dir)',
'-D', '<(chrome_build)',
'-E', '<(branded_env)',
],
'conditions': [
['chromeos==1', {
'action': ['-D', 'chromeos'],
}],
['use_titlecase_in_grd_files==1', {
'action': ['-D', 'use_titlecase'],
}],
['touchui==1', {
'action': ['-D', 'touchui'],
}],
'<@(grit_defines)',
],
'message': 'Generating resources from <(RULE_INPUT_PATH)',
},
Expand Down
8 changes: 2 additions & 6 deletions chrome/default_plugin/default_plugin.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,8 @@
],
'action': ['<@(grit_cmd)',
'-i', '<(input_path)', 'build',
'-o', '<(grit_out_dir)/default_plugin_resources'],
'conditions': [
['toolkit_views==1', {
'action': ['-D', 'toolkit_views'],
}],
],
'-o', '<(grit_out_dir)/default_plugin_resources',
'<@(grit_defines)'],
'message': 'Generating resources from <(input_path)',
},
],
Expand Down
6 changes: 1 addition & 5 deletions gfx/gfx.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,7 @@
'<@(grit_cmd)',
'-i', '<(input_path)', 'build',
'-o', '<(grit_out_dir)',
],
'conditions': [
['use_titlecase_in_grd_files==1', {
'action': ['-D', 'use_titlecase'],
}],
'<@(grit_defines)',
],
'message': 'Generating resources from <(input_path)',
},
Expand Down
3 changes: 2 additions & 1 deletion net/net.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,8 @@
'action':
['<@(grit_cmd)',
'-i', '<(RULE_INPUT_PATH)', 'build',
'-o', '<(SHARED_INTERMEDIATE_DIR)/net'],
'-o', '<(SHARED_INTERMEDIATE_DIR)/net',
'<@(grit_defines)'],
'message': 'Generating resources from <(RULE_INPUT_PATH)',
},
],
Expand Down
9 changes: 6 additions & 3 deletions webkit/glue/webkit_glue.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
],
'action': ['<@(grit_cmd)',
'-i', '<(input_path)', 'build',
'-o', '<(grit_out_dir)'],
'-o', '<(grit_out_dir)',
'<@(grit_defines)'],
'message': 'Generating resources from <(input_path)',
},
{
Expand All @@ -53,7 +54,8 @@
],
'action': ['<@(grit_cmd)',
'-i', '<(input_path)', 'build',
'-o', '<(grit_out_dir)'],
'-o', '<(grit_out_dir)',
'<@(grit_defines)'],
'message': 'Generating resources from <(input_path)',
},
],
Expand Down Expand Up @@ -89,7 +91,8 @@
],
'action': ['<@(grit_cmd)',
'-i', '<(input_path)', 'build',
'-o', '<(grit_out_dir)'],
'-o', '<(grit_out_dir)',
'<@(grit_defines)'],
'message': 'Generating resources from <(input_path)',
},
],
Expand Down
5 changes: 4 additions & 1 deletion webkit/tools/test_shell/test_shell.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,10 @@
'<(out_dir)/grit/test_shell_resources.h',
'<(out_dir)/test_shell_resources.pak',
],
'action': ['python', '<(grit_path)', '-i', '<(input_path)', 'build', '-o', '<(out_dir)'],
'action': ['python', '<(grit_path)',
'-i', '<(input_path)',
'build', '-o', '<(out_dir)',
'<@(grit_defines)'],
'message': 'Generating resources from <(input_path)',
},
],
Expand Down

0 comments on commit bb6aba3

Please sign in to comment.