# Copyright 2023 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/zip.gni")
import("//chrome/updater/branding.gni")
import("//components/crx_file/crx3.gni")
if (is_win) {
executable("test_meta_installer") {
testonly = true
sources = [
"main.cc",
"test_installer.rc",
]
deps = [
"//base",
"//build/win:default_exe_manifest",
"//chrome/updater:constants_test",
"//chrome/updater/win/installer:lib",
]
}
copy("test_installer") {
testonly = true
sources = [
"$root_build_dir/test_meta_installer.exe",
"//chrome/tools/build/win/resedit.py",
"create_test_installer_gn_wrapper.py",
"embed_install_scripts.py",
]
deps = [ ":test_meta_installer" ]
outputs = [ "$root_build_dir/test_installer/{{source_file_part}}" ]
}
template("test_app_installer") {
testonly = true
app_name = "test_" + target_name
setup_name = "Test" + target_name + "Setup"
script =
"$root_build_dir/test_installer/create_test_installer_gn_wrapper.py"
output_installer = "$root_build_dir/test_installer/" + setup_name + ".exe"
outputs = [ output_installer ]
action(app_name + "_installer") {
inputs = [
script,
invoker.setup_script,
]
args = [
"--installer",
rebase_path("$root_build_dir/test_installer/test_meta_installer.exe",
root_build_dir),
"--output",
rebase_path(output_installer, root_build_dir),
"--script",
rebase_path(invoker.setup_script),
]
deps = [ ":test_installer" ]
}
}
if (host_os == "win" && !is_debug) {
test_app_installer("app1") {
setup_script = "test_app1_setup.py"
}
test_app_installer("app2") {
setup_script = "test_app2_setup.cmd"
}
} else {
copy("test_app2_installer") {
sources =
[ "//chrome/updater/test/data/test_installer/Testapp2Setup.exe" ]
outputs = [ "$root_build_dir/test_installer/{{source_file_part}}" ]
}
}
template("test_app_installer_crx") {
testonly = true
app_name = "test_" + target_name
inputs = [ "$root_build_dir/test_installer/" + invoker.setup_name + ".exe" ]
deps = [ ":" + app_name + "_installer" ]
crx3(app_name + "_installer_crx") {
base_dir = "$root_build_dir/test_installer"
key = "//chrome/updater/test/data/selfupdate_test_key.der"
output = "$root_build_dir/test_installer/" + invoker.setup_name + ".crx3"
}
}
test_app_installer_crx("app2") {
setup_name = "Testapp2Setup"
}
template("test_msi_installer") {
testonly = true
appid = "{c28fcf72-bcf2-45c5-8def-31a74ac02012}"
msi_base_name = "TestSystemMsiInstaller"
version = invoker.version
relative_path = appid + "." + version + "/" + msi_base_name + ".msi"
output_dir = "$root_build_dir/test_installer/"
output_installer = output_dir + relative_path
checked_in_msi = "//chrome/updater/test/data/" +
updater_company_short_name + "MSI/" + relative_path
action("test_msi_installer" + target_name) {
script = "create_test_msi_installer.py"
test_installer_wxs_xml = "test_installer.wxs.xml"
inputs = [
script,
test_installer_wxs_xml,
]
outputs = [ output_installer ]
args = [
"--candle_path",
rebase_path("//third_party/wix/candle.exe", root_build_dir),
"--light_path",
rebase_path("//third_party/wix/light.exe", root_build_dir),
"--product_name",
"Test System MSI Installer",
"--product_version",
version,
"--appid",
appid,
"--msi_base_name",
msi_base_name,
"--msi_template_path",
rebase_path(test_installer_wxs_xml),
"--company_name",
updater_company_short_name,
"--company_full_name",
updater_company_full_name,
"--checked_in_msi",
rebase_path(checked_in_msi, root_build_dir),
"--output_dir",
rebase_path(output_dir, root_build_dir),
]
}
}
test_msi_installer("1.0.0.0") {
version = "1.0.0.0"
}
test_msi_installer("2.0.0.0") {
version = "2.0.0.0"
}
copy("copy_test_msi_installer2.0.0.0") {
testonly = true
sources = get_target_outputs(":test_msi_installer2.0.0.0")
deps = [ ":test_msi_installer2.0.0.0" ]
outputs = [ "$root_build_dir/test_installer/{{source_file_part}}" ]
}
crx3("test_msi_installer_crx") {
testonly = true
base_dir = "$root_build_dir/test_installer"
key = "//chrome/updater/test/data/selfupdate_test_key.der"
inputs = get_target_outputs(":copy_test_msi_installer2.0.0.0")
output = "$root_build_dir/test_installer/TestSystemMsiInstaller.msi.crx3"
deps = [ ":copy_test_msi_installer2.0.0.0" ]
}
group("app_installers") {
testonly = true
data_deps = [
":test_app2_installer",
":test_app2_installer_crx",
":test_installer",
":test_msi_installer1.0.0.0",
":test_msi_installer_crx",
]
}
} else {
copy("test_installer") {
testonly = true
sources = [ "test_app_setup.sh" ]
outputs = [ "$root_build_dir/test_installer/{{source_file_part}}" ]
}
template("test_app_installer") {
testonly = true
app_name = target_name
script_target = "test_script_" + app_name
copy(script_target) {
sources = [ invoker.script ]
outputs =
[ "$target_gen_dir/" + app_name + "/zip_contents/" + invoker.script ]
}
install_target = "install_script_" + app_name
action(install_target) {
script = "generate_install_script.py"
inputs = [ script ]
outputs = [ "$target_gen_dir/" + app_name + "/zip_contents/.install" ]
args = [
"--command",
invoker.script,
"--app",
invoker.app,
"--company",
updater_company_short_name,
"--version",
invoker.version,
"--output",
rebase_path(outputs[0]),
]
}
zip("test_installer_zip_" + app_name) {
inputs = get_target_outputs(":" + script_target) +
get_target_outputs(":" + install_target)
base_dir = "$target_gen_dir/" + app_name + "/zip_contents/"
output = "$target_gen_dir/" + app_name + "/crx_contents/test_installer_" +
app_name + ".zip"
deps = [
":" + script_target,
":" + install_target,
]
}
crx3("test_installer_" + app_name) {
base_dir = "$target_gen_dir/" + app_name + "/crx_contents/"
key = "//chrome/updater/test/data/selfupdate_test_key.der"
inputs = get_target_outputs(":test_installer_zip_" + app_name)
output =
"$root_build_dir/test_installer/test_installer_" + app_name + ".crx3"
deps = [ ":test_installer_zip_" + app_name ]
}
}
test_app_installer("test1_v1") {
app = "test1"
version = "1.0.0.0"
script = "test_app_setup.sh"
}
test_app_installer("test1_v2") {
app = "test1"
version = "2.0.0.0"
script = "test_app_setup.sh"
}
test_app_installer("test2_v1") {
app = "test2"
version = "100.0.0.0"
script = "test_app_setup.sh"
}
test_app_installer("test2_v2") {
app = "test2"
version = "101.0.0.0"
script = "test_app_setup.sh"
}
test_app_installer("test3_v1") {
app = "test3"
version = "1.0"
script = "test_app_setup.sh"
}
test_app_installer("test3_v2") {
app = "test3"
version = "1.1"
script = "test_app_setup.sh"
}
group("app_installers") {
testonly = true
data_deps = [
":test_installer",
":test_installer_test1_v1",
":test_installer_test1_v2",
":test_installer_test2_v1",
":test_installer_test2_v2",
":test_installer_test3_v1",
":test_installer_test3_v2",
]
}
}