Commit 9573ca90 authored by tapted's avatar tapted Committed by Commit bot

Simplify test locales in Mac's ui_unittests Framework (take 2)

Mac creates a mini-framework in `ui_unittests Framework` so that ui
tests can get a resource bundle without depending on the Chrome
framework.

The way it generated locale information was causing build flakes since
two instances of repack_locales.py could be writing to
out/../gen/repack. Tests always use en-US, so instead just repack the
strings made for ui_test.pak to en.lproj/locale.pak and roll it into the
mini-framework bundle.

Note we can't simply copy ui_test.pak because Mac system libraries will
annoy valgrind with leaks when they encounter unexpected things in it.

BUG=410468, 413034

Review URL: https://codereview.chromium.org/565063002

Cr-Commit-Position: refs/heads/master@{#294774}
parent 6026661e
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
{ {
'product_name': 'ui_unittests Framework', 'product_name': 'ui_unittests Framework',
'variables': { 'variables': {
'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/ui',
# There is no executable in the mock framework, and so nothing to strip. # There is no executable in the mock framework, and so nothing to strip.
'mac_strip': 0, 'mac_strip': 0,
}, },
...@@ -25,7 +23,9 @@ ...@@ -25,7 +23,9 @@
'mac_bundle_resources': [ 'mac_bundle_resources': [
'test/framework-Info.plist', 'test/framework-Info.plist',
'<(PRODUCT_DIR)/ui_test.pak', '<(PRODUCT_DIR)/ui_test.pak',
'<!@pymod_do_main(repack_locales -o -p <(OS) -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(SHARED_INTERMEDIATE_DIR) <(locales))',
# Just include the English-US locale made by ui_resources.gyp:ui_test_pak.
'<(PRODUCT_DIR)/ui/en.lproj/locale.pak',
], ],
'mac_bundle_resources!': [ 'mac_bundle_resources!': [
'test/framework-Info.plist', 'test/framework-Info.plist',
......
...@@ -52,16 +52,14 @@ if (!is_mac) { ...@@ -52,16 +52,14 @@ if (!is_mac) {
} }
} }
# On iOS the output needs to additionally be copied to another location, so # On iOS and Mac the string resources need to go into a locale subfolder, which
# we have this intermediate step. # introduces an extra dependency.
# #
# GYP version: ui/resources/ui_resources.gyp:ui_test_pak # GYP version: ui/resources/ui_resources.gyp:ui_test_pak
# (copy_ui_test_pak action) # (copy_ui_test_pak action)
if (is_ios) { if (is_ios || is_mac) {
copy("ui_test_pak") { group("ui_test_pak") {
sources = [ "$root_out_dir/ui_test.pak" ] deps = [ ":repack_ui_test_pak", ":repack_ui_test_mac_locale_pack" ]
outputs = [ "$root_out_dir/ui/en.lproj/locale.pak" ]
deps = [ ":repack_ui_test_pak" ]
} }
} else { } else {
group("ui_test_pak") { group("ui_test_pak") {
...@@ -92,3 +90,22 @@ repack("repack_ui_test_pak") { ...@@ -92,3 +90,22 @@ repack("repack_ui_test_pak") {
deps += [ ":copy_ui_resources_100_percent" ] deps += [ ":copy_ui_resources_100_percent" ]
} }
} }
# Repack just the strings for the framework locales on Mac and iOS. This
# emulates repack_locales.py, but just for en-US. Note ui_test.pak is not simply
# copied, because it causes leaks from allocations within system libraries when
# trying to load non-string resources. http://crbug.com/413034.
repack("repack_ui_test_mac_locale_pack") {
visibility = [ ":ui_test_pak" ]
sources = [
"$root_gen_dir/ui/strings/app_locale_settings_en-US.pak",
"$root_gen_dir/ui/strings/ui_strings_en-US.pak",
]
output = "$root_out_dir/ui/en.lproj/locale.pak"
deps = [
"//ui/strings",
]
}
...@@ -74,24 +74,24 @@ ...@@ -74,24 +74,24 @@
}, },
], ],
}], }],
['OS == "ios"', { ['OS == "ios" or OS == "mac"', {
'actions': [ 'actions': [
{ {
# GN version: //ui/resources:copy_ui_test_pak # GN version: //ui/resources:repack_ui_test_mac_locale_pack
'action_name': 'copy_ui_test_pak', # Repack just the strings for the framework locales on Mac and
'message': 'Copying ui_test.pak into locale.pak', # iOS. This emulates repack_locales.py, but just for en-US. Note
'inputs': [ # ui_test.pak is not simply copied, because it causes leaks from
'<(PRODUCT_DIR)/ui_test.pak', # allocations within system libraries when trying to load non-
], # string resources. http://crbug.com/413034.
'outputs': [ 'action_name': 'repack_ui_test_mac_locale_pack',
'<(PRODUCT_DIR)/ui/en.lproj/locale.pak', 'variables': {
], 'pak_inputs': [
'action': [ '<(SHARED_INTERMEDIATE_DIR)/ui/strings/app_locale_settings_en-US.pak',
'python', '<(SHARED_INTERMEDIATE_DIR)/ui/strings/ui_strings_en-US.pak',
'../../build/cp.py',
'<@(_inputs)',
'<@(_outputs)'
], ],
'pak_output': '<(PRODUCT_DIR)/ui/en.lproj/locale.pak',
},
'includes': [ '../../build/repack_action.gypi' ],
}, },
], ],
}], }],
......
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