From 3f5c939c848aba2678324c5b31e6c0b2d77dfd04 Mon Sep 17 00:00:00 2001 From: Scott Graham Date: Wed, 29 Nov 2017 11:04:47 -0800 Subject: [PATCH] gn: Next step in getting compilation working - Correctly sets target_cpu and current_cpu so correct toolchain can be used on Fuchsia. - Introduces GN argument "crashpad_in_chromium" which defaults to false. Used to set CRASHPAD_IN_CHROMIUM define, determine which zlib path to use, and how to package the test targets into binaries (one big one in Chromium, separate in Crashpad). Bug: crashpad:79, crashpad:196 Change-Id: If6560dc064308ed6f8bf7c75cf74f684a3522e8b Reviewed-on: https://chromium-review.googlesource.com/797354 Reviewed-by: Mark Mentovai Reviewed-by: Robert Sesek Commit-Queue: Scott Graham --- BUILD.gn | 65 ++++++++++++++++++++++++++++------ build/BUILD.gn | 25 +++++++++++++ build/BUILDCONFIG.gn | 40 +++++++++++++++++---- build/crashpad_in_chromium.gni | 17 +++++++++ third_party/zlib/BUILD.gn | 21 ++++++++--- 5 files changed, 147 insertions(+), 21 deletions(-) create mode 100644 build/BUILD.gn create mode 100644 build/crashpad_in_chromium.gni diff --git a/BUILD.gn b/BUILD.gn index 88559c42..6ca07512 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -13,19 +13,64 @@ # limitations under the License. import("//testing/test.gni") +import("build/crashpad_in_chromium.gni") config("crashpad_config") { include_dirs = [ "." ] } -test("crashpad_tests") { - deps = [ - "client:client_test", - "handler:handler_test", - "minidump:minidump_test", - "snapshot:snapshot_test", - "test:gmock_main", - "test:test_test", - "util:util_test", - ] +if (crashpad_in_chromium) { + test("crashpad_tests") { + deps = [ + "client:client_test", + "handler:handler_test", + "minidump:minidump_test", + "snapshot:snapshot_test", + "test:gmock_main", + "test:test_test", + "util:util_test", + ] + } +} else { + test("crashpad_client_test") { + deps = [ + "client:client_test", + "test:gmock_main", + ] + } + + test("crashpad_handler_test") { + deps = [ + "handler:handler_test", + "test:gtest_main", + ] + } + + test("crashpad_minidump_test") { + deps = [ + "minidump:minidump_test", + "test:gtest_main", + ] + } + + test("crashpad_snapshot_test") { + deps = [ + "snapshot:snapshot_test", + "test:gtest_main", + ] + } + + test("crashpad_test_test") { + deps = [ + "test:gmock_main", + "test:test_test", + ] + } + + test("crashpad_util_test") { + deps = [ + "test:gmock_main", + "util:util_test", + ] + } } diff --git a/build/BUILD.gn b/build/BUILD.gn new file mode 100644 index 00000000..e60cd0c6 --- /dev/null +++ b/build/BUILD.gn @@ -0,0 +1,25 @@ +# Copyright 2017 The Crashpad 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. + +# When building in Chromium, these configs is used to set #defines that indicate +# whether code is being built standalone, or in Chromium, or potentially in some +# other configutation. + +import("crashpad_in_chromium.gni") + +config("crashpad_in_chromium") { + if (crashpad_in_chromium) { + defines = [ "CRASHPAD_IN_CHROMIUM" ] + } +} diff --git a/build/BUILDCONFIG.gn b/build/BUILDCONFIG.gn index d85494ba..840978fa 100644 --- a/build/BUILDCONFIG.gn +++ b/build/BUILDCONFIG.gn @@ -20,6 +20,14 @@ if (current_os == "") { current_os = target_os } +if (target_cpu == "") { + target_cpu = host_cpu +} + +if (current_cpu == "") { + current_cpu = target_cpu +} + declare_args() { is_debug = false is_clang = current_os == "mac" || current_os == "fuchsia" @@ -55,12 +63,30 @@ if (is_win) { "//third_party/mini_chromium/mini_chromium/build:gcc_like_toolchain") } -set_defaults("static_library") { - configs = [ - "//third_party/mini_chromium/mini_chromium/build:default", +_default_configs = [ + "//third_party/mini_chromium/mini_chromium/build:default", - # This (no-op) is added here so that build files that expect to be able to - # remove it can do so without causing an error. - "//build/config/compiler:chromium_code", - ] + # This (no-op) is added here so that build files that expect to be able to + # remove it can do so without causing an error. + "//build/config/compiler:chromium_code", +] + +set_defaults("source_set") { + configs = _default_configs +} + +set_defaults("static_library") { + configs = _default_configs +} + +set_defaults("executable") { + configs = _default_configs +} + +set_defaults("loadable_module") { + configs = _default_configs +} + +set_defaults("shared_library") { + configs = _default_configs } diff --git a/build/crashpad_in_chromium.gni b/build/crashpad_in_chromium.gni new file mode 100644 index 00000000..568c52e7 --- /dev/null +++ b/build/crashpad_in_chromium.gni @@ -0,0 +1,17 @@ +# Copyright 2017 The Crashpad 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. + +declare_args() { + crashpad_in_chromium = false +} diff --git a/third_party/zlib/BUILD.gn b/third_party/zlib/BUILD.gn index db158c7d..017dfff8 100644 --- a/third_party/zlib/BUILD.gn +++ b/third_party/zlib/BUILD.gn @@ -12,13 +12,26 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("../../build/crashpad_in_chromium.gni") + config("zlib_config") { - defines = [ "CRASHPAD_ZLIB_SOURCE_CHROMIUM" ] + if (crashpad_in_chromium) { + defines = [ "CRASHPAD_ZLIB_SOURCE_CHROMIUM" ] + } else { + defines = [ "CRASHPAD_ZLIB_SOURCE_EMBEDDED" ] + } } group("zlib") { public_configs = [ ":zlib_config" ] - public_deps = [ - "//third_party/zlib:zlib", - ] + + if (crashpad_in_chromium) { + public_deps = [ + "//third_party/zlib", + ] + } else { + public_deps = [ + "//third_party/zlib/zlib", + ] + } }