# Copyright 2014 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. import("//build/config/chrome_build.gni") import("//testing/test.gni") # This file deliberately has no default "util" target so dependants have to # specify with the ":with_no_strings" or ":with_rc_strings" variants. Random # code that ends up getting linked into chrome proper should depend on the # ":with_no_strings" variant. Other standalone apps will need to decide if they # need the resource strings or not. # # chrome/installer/util has generated strings on Windows. These appear as # Windows resources and are fairly large (~200KB). They are generated by the # ":generate_strings" target and compiled by the ":strings" target. # # Some code, like the Windows chrome.exe (the small bootstrap binary, not # all of chrome.dll) code uses installer_util functions without calling any # functions that use the strings. And historically in the GYP build the strings # resource had to be manually linked, so the strings never ended up being in # chrome.exe and everything was fine. # # Other code, like chrome.dll links to installer util, and hooks up a # TranslationDelegate which overrides the strings retrieved from the resources # with grit pak strings. # # In both of these cases, link to the ":with_no_strings" variant. However, this # is obviously a fragile and confusing situation. In the "I don't use strings at # all case", there is no definition of what works and doesn't work, and this may # also change over time. As an example at the time of this writing, chrome.exe # calls GoogleUpdateSettings::UpdateDidRunState. This function doesn't use any # strings, but lots of other functions in BrowserDistribution do use localized # strings. # # Ideally, this should be cleaved in two parts: the main "installer util" and # some kind of mini installer util that just contains the functions needed by # chrome.exe and any other clients that don't need the strings. It's likely # we would still need the variant with no strings for when chrome.dll replaces # all strings with its own versions. static_library("with_no_strings") { deps = [ "//base", "//chrome:strings", "//chrome/common:constants", "//components/variations", "//content/public/common:result_codes", ] # The constants target checks the Chrome distribution from this target. Both # targets have to be linked together in practice. allow_circular_includes_from = [ "//chrome/common:constants" ] if (is_win) { sources = [ "chrome_browser_operations.cc", "chrome_browser_operations.h", "delete_after_reboot_helper.cc", "delete_after_reboot_helper.h", "experiment.cc", "experiment.h", "experiment_labels.cc", "experiment_labels.h", "experiment_metrics.cc", "experiment_metrics.h", "experiment_storage.cc", "experiment_storage.h", "google_chrome_distribution.cc", "google_chrome_distribution.h", "html_dialog.h", "html_dialog_impl.cc", "logging_installer.cc", "logging_installer.h", "lzma_file_allocator.cc", "lzma_file_allocator.h", "lzma_util.cc", "lzma_util.h", "master_preferences.cc", "master_preferences.h", "product.cc", "product.h", "product_operations.h", "registry_entry.cc", "registry_entry.h", "scoped_token_privilege.cc", "scoped_token_privilege.h", "scoped_user_protocol_entry.cc", "scoped_user_protocol_entry.h", "self_cleaning_temp_dir.cc", "self_cleaning_temp_dir.h", "shell_util.cc", "shell_util.h", "uninstall_metrics.cc", "uninstall_metrics.h", ] deps += [ # Need to depend on the generated strings target since files here # depend on the generated header, but only depend on the ":strings" # target (which actually compiles and causes the generated code to be # linked) from the ":util" target. ":generate_strings", "//base/third_party/dynamic_annotations", "//chrome/install_static:install_static_util", "//components/base32", "//components/metrics", "//courgette:courgette_lib", "//crypto", "//rlz/buildflags", "//third_party/bspatch", "//third_party/crashpad/crashpad/client", "//third_party/icu", "//third_party/lzma_sdk", ] libs = [ "urlmon.lib", "wbemuuid.lib", "wtsapi32.lib", ] configs += [ "//build/config:precompiled_headers", # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. "//build/config/compiler:no_size_t_to_int_warning", ] sources += [ "advanced_firewall_manager_win.cc", "advanced_firewall_manager_win.h", "app_command.cc", "app_command.h", "app_commands.cc", "app_commands.h", "app_registration_data.h", "auto_launch_util.cc", "auto_launch_util.h", "beacons.cc", "beacons.h", "browser_distribution.cc", "browser_distribution.h", "callback_work_item.cc", "callback_work_item.h", "channel_info.cc", "channel_info.h", "conditional_work_item_list.cc", "conditional_work_item_list.h", "copy_tree_work_item.cc", "copy_tree_work_item.h", "create_dir_work_item.cc", "create_dir_work_item.h", "create_reg_key_work_item.cc", "create_reg_key_work_item.h", "delete_old_versions.cc", "delete_old_versions.h", "delete_reg_key_work_item.cc", "delete_reg_key_work_item.h", "delete_reg_value_work_item.cc", "delete_reg_value_work_item.h", "delete_tree_work_item.cc", "delete_tree_work_item.h", "duplicate_tree_detector.cc", "duplicate_tree_detector.h", "firewall_manager_win.cc", "firewall_manager_win.h", "google_update_constants.cc", "google_update_constants.h", "google_update_settings.cc", "google_update_settings.h", "google_update_util.cc", "google_update_util.h", "helper.cc", "helper.h", "install_util.cc", "install_util.h", "installation_state.cc", "installation_state.h", "l10n_string_util.cc", "l10n_string_util.h", "language_selector.cc", "language_selector.h", "master_preferences_constants.cc", "master_preferences_constants.h", "move_tree_work_item.cc", "move_tree_work_item.h", "non_updating_app_registration_data.cc", "non_updating_app_registration_data.h", "registry_key_backup.cc", "registry_key_backup.h", "self_reg_work_item.cc", "self_reg_work_item.h", "set_reg_value_work_item.cc", "set_reg_value_work_item.h", "updating_app_registration_data.cc", "updating_app_registration_data.h", "util_constants.cc", "util_constants.h", "wmi.cc", "wmi.h", "work_item.cc", "work_item.h", "work_item_list.cc", "work_item_list.h", ] } else { sources = [ "master_preferences.cc", "master_preferences.h", "master_preferences_constants.cc", "master_preferences_constants.h", ] } } # Use this version of installer_util to link to the generated strings in .rc # format. group("with_rc_strings") { public_deps = [ ":with_no_strings", ] if (is_win) { public_deps += [ ":strings" ] } } action("generate_strings") { visibility = [ ":strings", ":with_no_strings", ] script = "prebuild/create_string_rc.py" if (is_chrome_branded) { grdfile = "//chrome/app/google_chrome_strings.grd" } else { grdfile = "//chrome/app/chromium_strings.grd" } inputs = [ grdfile, ] outputs = [ "$target_gen_dir/installer_util_strings.h", "$target_gen_dir/installer_util_strings.rc", ] args = [ "-b", "$branding_path_component", "-i", rebase_path(grdfile, root_build_dir) + ":resources", "-n", "installer_util_strings", "-o", rebase_path(target_gen_dir, root_build_dir), ] } # Compile the generated .rc file. source_set("strings") { sources = get_target_outputs(":generate_strings") public_deps = [ ":generate_strings", ] } if (is_win) { source_set("test_support") { testonly = true sources = [ "fake_installation_state.h", "fake_product_state.h", ] deps = [ ":with_no_strings", "//base", ] } test("installer_util_unittests") { sources = [ "advanced_firewall_manager_win_unittest.cc", "beacons_unittest.cc", "callback_work_item_unittest.cc", "channel_info_unittest.cc", "conditional_work_item_list_unittest.cc", "copy_tree_work_item_unittest.cc", "create_dir_work_item_unittest.cc", "create_reg_key_work_item_unittest.cc", "delete_after_reboot_helper_unittest.cc", "delete_old_versions_unittest.cc", "delete_reg_key_work_item_unittest.cc", "delete_reg_value_work_item_unittest.cc", "delete_tree_work_item_unittest.cc", "duplicate_tree_detector_unittest.cc", "experiment_labels_unittest.cc", "experiment_storage_unittest.cc", "experiment_unittest.cc", "google_update_settings_unittest.cc", "install_util_unittest.cc", "installer_util_test_common.cc", "installer_util_test_common.h", "l10n_string_util_unittest.cc", "language_selector_unittest.cc", "logging_installer_unittest.cc", "lzma_file_allocator_unittest.cc", "lzma_util_unittest.cc", "master_preferences_unittest.cc", "move_tree_work_item_unittest.cc", "product_state_unittest.cc", "product_unittest.cc", "registry_key_backup_unittest.cc", "registry_test_data.cc", "registry_test_data.h", "run_all_unittests.cc", "scoped_token_privilege_unittest.cc", "scoped_user_protocol_entry_unittest.cc", "self_cleaning_temp_dir_unittest.cc", "set_reg_value_work_item_unittest.cc", "shell_util_unittest.cc", "test_app_registration_data.cc", "test_app_registration_data.h", "uninstall_metrics_unittest.cc", "wmi_unittest.cc", "work_item_list_unittest.cc", "work_item_mocks.cc", "work_item_mocks.h", "work_item_unittest.cc", ] deps = [ ":test_support", ":with_rc_strings", "//base", "//base:i18n", "//base/test:test_support", "//chrome:other_version", "//chrome/install_static:install_static_util", "//chrome/install_static/test:test_support", "//chrome/installer/setup:lib", "//chrome/installer/test:alternate_version_generator_lib", "//components/variations", "//rlz/buildflags", "//testing/gmock", "//testing/gtest", ] data = [ "//chrome/test/data/extensions/", "//chrome/test/data/installer/", ] } } # is_win