Skip to content

Commit

Permalink
[GN] Migrate //components/update_client.
Browse files Browse the repository at this point in the history
The two test targets build but aren't yet able to be run (but that's the
case for all tests with evergreen on GN currently).

Some changes are also made to starboard/loader_app to resolve some
dependency check issues.

b/211447902

Change-Id: Ibd6865e793441ba2471706160a295aa3533b5035
  • Loading branch information
hlwarriner committed Jan 5, 2022
1 parent 4a4bc33 commit a2f47c2
Show file tree
Hide file tree
Showing 6 changed files with 296 additions and 21 deletions.
8 changes: 8 additions & 0 deletions cobalt/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ group("gn_all") {
"//cobalt/websocket:websocket_test",
"//cobalt/xhr:xhr_test",
]

if (sb_is_evergreen) {
deps += [
"//components/update_client:cobalt_slot_management_test",
"//components/update_client:update_client_test",
]
}
}

group("default") {
Expand All @@ -48,6 +55,7 @@ group("default") {
"//components/client_update_protocol",
"//components/crx_file",
"//components/prefs",
"//components/update_client",
"//third_party/llvm-project/compiler-rt:compiler_rt",
"//third_party/llvm-project/libcxx:cxx",
"//third_party/llvm-project/libcxxabi:cxxabi",
Expand Down
7 changes: 4 additions & 3 deletions cobalt/browser/browser_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@
#if defined(ENABLE_DEBUGGER)
#include "cobalt/browser/debug_console.h"
#include "cobalt/browser/lifecycle_console_commands.h"
#include "cobalt/debug/backend/debug_dispatcher.h"
#include "cobalt/debug/backend/debug_dispatcher.h" // nogncheck
#include "cobalt/debug/backend/debugger_state.h"
#include "cobalt/debug/console/command_manager.h"
#include "cobalt/debug/debug_client.h"
#endif // ENABLE_DEBUGGER
#include "cobalt/debug/debug_client.h" // nogncheck
#endif // ENABLE_DEBUGGER

#if SB_IS(EVERGREEN)
#include "cobalt/updater/updater_module.h"
Expand Down Expand Up @@ -234,6 +234,7 @@ class BrowserModule {
SbTimeMonotonic timestamp);
// Pass the deeplink timestamp from Starboard.
void SetDeepLinkTimestamp(SbTimeMonotonic timestamp);

private:
#if SB_HAS(CORE_DUMP_HANDLER_SUPPORT)
static void CoreDumpHandler(void* browser_module_as_void);
Expand Down
250 changes: 250 additions & 0 deletions components/update_client/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
# Copyright 2021 The Cobalt Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

config("update_client_config") {
defines = [
"LIBXML_READER_ENABLED",
"LIBXML_WRITER_ENABLED",
]
}

static_library("update_client") {
sources = [
"action_runner.cc",
"action_runner.h",
"activity_data_service.h",
"cobalt_slot_management.cc",
"cobalt_slot_management.h",
"command_line_config_policy.cc",
"command_line_config_policy.h",
"component.cc",
"component.h",
"component_patcher.cc",
"component_patcher.h",
"component_patcher_operation.cc",
"component_patcher_operation.h",
"component_unpacker.cc",
"component_unpacker.h",
"configurator.h",
"crx_downloader.cc",
"crx_downloader.h",
"crx_update_item.h",
"network.cc",
"network.h",
"patcher.h",
"persisted_data.cc",
"persisted_data.h",
"ping_manager.cc",
"ping_manager.h",
"protocol_definition.cc",
"protocol_definition.h",
"protocol_handler.cc",
"protocol_handler.h",
"protocol_parser.cc",
"protocol_parser.h",
"protocol_parser_json.cc",
"protocol_parser_json.h",
"protocol_serializer.cc",
"protocol_serializer.h",
"protocol_serializer_json.cc",
"protocol_serializer_json.h",
"request_sender.cc",
"request_sender.h",
"task.h",
"task_send_uninstall_ping.cc",
"task_send_uninstall_ping.h",
"task_traits.h",
"task_update.cc",
"task_update.h",
"unzipper.h",
"update_checker.cc",
"update_checker.h",
"update_client.cc",
"update_client.h",
"update_client_errors.h",
"update_client_internal.h",
"update_engine.cc",
"update_engine.h",
"update_query_params.cc",
"update_query_params.h",
"update_query_params_delegate.cc",
"update_query_params_delegate.h",
"updater_state.cc",
"updater_state.h",
"url_fetcher_downloader.cc",
"url_fetcher_downloader.h",
"utils.cc",
"utils.h",
]

configs += [ ":update_client_config" ]

deps = [
"//components/client_update_protocol",
"//components/crx_file",
"//components/prefs",
"//crypto",
"//net",
"//starboard/loader_app:app_key_files",
"//starboard/loader_app:drain_file",
"//third_party/libxml",
"//url",
]
}

static_library("test_support") {
testonly = true

sources = [
"net/network_cobalt.h",
"net/network_impl_cobalt.cc",
"net/network_impl_cobalt.h",
"net/url_request_post_interceptor.cc",
"net/url_request_post_interceptor.h",
"patch/patch_impl_cobalt.cc",
"patch/patch_impl_cobalt.h",
"test_configurator.cc",
"test_configurator.h",
"unzip/unzip_impl_cobalt.cc",
"unzip/unzip_impl_cobalt.h",
]

deps = [
":update_client",
"//base",
"//cobalt/base",
"//cobalt/debug:console_command_manager",
"//cobalt/loader",
"//cobalt/network",
"//components/prefs",
"//net",
"//net:test_support",
"//testing/gmock",
"//testing/gtest",
"//third_party/zlib:zip",
"//url",
]
}

copy("update_client_test_files") {
sources = [
"//components/test/data/update_client/ChromeRecovery.crx3",
"//components/test/data/update_client/binary_bsdiff_patch.bin",
"//components/test/data/update_client/binary_courgette_patch.bin",
"//components/test/data/update_client/binary_input.bin",
"//components/test/data/update_client/binary_output.bin",
"//components/test/data/update_client/ihfokbkgjpifnbbojhneepfflplebdkc/ihfokbkgjpifnbbojhneepfflplebdkc.pem",
"//components/test/data/update_client/ihfokbkgjpifnbbojhneepfflplebdkc/ihfokbkgjpifnbbojhneepfflplebdkc_1/a_changing_binary_file",
"//components/test/data/update_client/ihfokbkgjpifnbbojhneepfflplebdkc/ihfokbkgjpifnbbojhneepfflplebdkc_1/a_changing_text_file",
"//components/test/data/update_client/ihfokbkgjpifnbbojhneepfflplebdkc/ihfokbkgjpifnbbojhneepfflplebdkc_1/a_static_text_file",
"//components/test/data/update_client/ihfokbkgjpifnbbojhneepfflplebdkc/ihfokbkgjpifnbbojhneepfflplebdkc_1/manifest.json",
"//components/test/data/update_client/ihfokbkgjpifnbbojhneepfflplebdkc/ihfokbkgjpifnbbojhneepfflplebdkc_1to2/commands.json",
"//components/test/data/update_client/ihfokbkgjpifnbbojhneepfflplebdkc/ihfokbkgjpifnbbojhneepfflplebdkc_1to2/f0",
"//components/test/data/update_client/ihfokbkgjpifnbbojhneepfflplebdkc/ihfokbkgjpifnbbojhneepfflplebdkc_1to2/f1",
"//components/test/data/update_client/ihfokbkgjpifnbbojhneepfflplebdkc/ihfokbkgjpifnbbojhneepfflplebdkc_1to2/f2",
"//components/test/data/update_client/ihfokbkgjpifnbbojhneepfflplebdkc/ihfokbkgjpifnbbojhneepfflplebdkc_1to2_bad/commands.json",
"//components/test/data/update_client/ihfokbkgjpifnbbojhneepfflplebdkc/ihfokbkgjpifnbbojhneepfflplebdkc_1to2_bad/f1",
"//components/test/data/update_client/ihfokbkgjpifnbbojhneepfflplebdkc/ihfokbkgjpifnbbojhneepfflplebdkc_1to2_bad/f2",
"//components/test/data/update_client/ihfokbkgjpifnbbojhneepfflplebdkc/ihfokbkgjpifnbbojhneepfflplebdkc_1to2_bad/f3",
"//components/test/data/update_client/ihfokbkgjpifnbbojhneepfflplebdkc/ihfokbkgjpifnbbojhneepfflplebdkc_2/a_changing_binary_file",
"//components/test/data/update_client/ihfokbkgjpifnbbojhneepfflplebdkc/ihfokbkgjpifnbbojhneepfflplebdkc_2/a_changing_text_file",
"//components/test/data/update_client/ihfokbkgjpifnbbojhneepfflplebdkc/ihfokbkgjpifnbbojhneepfflplebdkc_2/a_static_text_file",
"//components/test/data/update_client/ihfokbkgjpifnbbojhneepfflplebdkc/ihfokbkgjpifnbbojhneepfflplebdkc_2/manifest.json",
"//components/test/data/update_client/ihfokbkgjpifnbbojhneepfflplebdkc_1.crx",
"//components/test/data/update_client/ihfokbkgjpifnbbojhneepfflplebdkc_1to2.crx",
"//components/test/data/update_client/ihfokbkgjpifnbbojhneepfflplebdkc_1to2_bad.crx",
"//components/test/data/update_client/ihfokbkgjpifnbbojhneepfflplebdkc_2.crx",
"//components/test/data/update_client/jebgalgnebhfojomionfpkfelancnnkf.crx",
"//components/test/data/update_client/jebgalgnebhfojomionfpkfelancnnkf.pem",
"//components/test/data/update_client/jebgalgnebhfojomionfpkfelancnnkf/component1.dll",
"//components/test/data/update_client/jebgalgnebhfojomionfpkfelancnnkf/manifest.json",
"//components/test/data/update_client/runaction_test_win.crx3",
"//components/test/data/update_client/updatecheck_reply_1.json",
"//components/test/data/update_client/updatecheck_reply_4.json",
"//components/test/data/update_client/updatecheck_reply_noupdate.json",
"//components/test/data/update_client/updatecheck_reply_parse_error.json",
"//components/test/data/update_client/updatecheck_reply_unknownapp.json",
]

outputs = [ "$sb_static_contents_output_data_dir/test/{{source_root_relative_dir}}/{{source_file_part}}" ]
}

target(gtest_target_type, "update_client_test") {
testonly = true

sources = [
"//cobalt/updater/utils.cc",
"component_unpacker_unittest.cc",

# TODO: enable the tests commented out
"crx_downloader_unittest.cc",
"persisted_data_unittest.cc",
"ping_manager_unittest.cc",
"protocol_parser_json_unittest.cc",

# "protocol_serializer_json_unittest.cc",
"protocol_serializer_unittest.cc",
"request_sender_unittest.cc",
"update_checker_unittest.cc",

# "update_client_unittest.cc",
"update_query_params_unittest.cc",
"updater_state_unittest.cc",
"utils_unittest.cc",
]

deps = [
":test_support",
":update_client",
":update_client_test_files",
"//cobalt/base",
"//cobalt/test:run_all_unittests",
"//components/crx_file",
"//components/prefs",
"//components/prefs:test_support",
"//crypto",
"//net",
"//net:test_support",
"//testing/gmock",
"//testing/gtest",
"//url",
]
}

target(gtest_target_type, "cobalt_slot_management_test") {
testonly = true

sources = [
"//cobalt/updater/utils.cc",
"//starboard/common/test_main.cc",
"//starboard/loader_app/system_get_extension_shim.cc",
"cobalt_slot_management_test.cc",
]

deps = [
":update_client",
"//cobalt/base",
"//components/crx_file",
"//components/prefs",
"//components/prefs:test_support",
"//crypto",
"//net:test_support",
"//starboard/loader_app",
"//starboard/loader_app:app_key_files",
"//starboard/loader_app:drain_file",
"//starboard/loader_app:installation_manager",
"//testing/gmock",
"//testing/gtest",
]
}
49 changes: 32 additions & 17 deletions starboard/loader_app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ group("common_loader_app_dependencies") {
":installation_manager",
":slot_management",
"//starboard",
"//starboard/elf_loader:evergreen_info",
"//starboard/elf_loader:sabi_string",
]

if (sb_is_evergreen_compatible) {
public_deps += [ "//third_party/crashpad/wrapper" ]
} else {
public_deps += [ "//third_party/crashpad/wrapper:wrapper_stub" ]
}
}

target(final_executable_type, "loader_app") {
Expand All @@ -43,23 +50,25 @@ target(final_executable_type, "loader_app") {
}
}

target(final_executable_type, "loader_app_sys") {
if (target_cpu == "x86" || target_cpu == "x64" || target_cpu == "arm" ||
target_cpu == "arm64") {
sources = _common_loader_app_sources

starboard_syms_path =
rebase_path("//starboard/starboard.syms", root_build_dir)
ldflags = [
"-Wl,--dynamic-list=$starboard_syms_path",
"-ldl",
]
deps = [
":common_loader_app_dependencies",
"//cobalt/content/fonts:copy_font_data",
"//starboard/elf_loader:elf_loader_sys",
]
deps += cobalt_platform_dependencies
if (sb_is_evergreen_compatible) {
target(final_executable_type, "loader_app_sys") {
if (target_cpu == "x86" || target_cpu == "x64" || target_cpu == "arm" ||
target_cpu == "arm64") {
sources = _common_loader_app_sources

starboard_syms_path =
rebase_path("//starboard/starboard.syms", root_build_dir)
ldflags = [
"-Wl,--dynamic-list=$starboard_syms_path",
"-ldl",
]
deps = [
":common_loader_app_dependencies",
"//cobalt/content/fonts:copy_font_data",
"//starboard/elf_loader:elf_loader_sys",
]
deps += cobalt_platform_dependencies
}
}
}

Expand Down Expand Up @@ -192,6 +201,12 @@ static_library("slot_management") {
"//starboard/elf_loader",
"//starboard/elf_loader:sabi_string",
]

if (sb_is_evergreen_compatible) {
deps += [ "//third_party/crashpad/wrapper" ]
} else {
deps += [ "//third_party/crashpad/wrapper:wrapper_stub" ]
}
}

target(gtest_target_type, "slot_management_test") {
Expand Down
2 changes: 1 addition & 1 deletion starboard/loader_app/installation_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "starboard/file.h"
#include "starboard/loader_app/installation_store.pb.h"
#if !SB_IS(EVERGREEN_COMPATIBLE_LITE)
#include "starboard/loader_app/pending_restart.h"
#include "starboard/loader_app/pending_restart.h" // nogncheck
#endif // !SB_IS(EVERGREEN_COMPATIBLE_LITE)
#include "starboard/once.h"
#include "starboard/string.h"
Expand Down
1 change: 1 addition & 0 deletions third_party/libxml/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ static_library("libxml") {
"//cobalt/base",
"//cobalt/dom_parser",
"//cobalt/renderer/rasterizer/skia/skia",
"//components/update_client",
]
}
if (is_ios) {
Expand Down

0 comments on commit a2f47c2

Please sign in to comment.