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 <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
This commit is contained in:
Scott Graham 2017-11-29 11:04:47 -08:00 committed by Commit Bot
parent ef3ce94fbf
commit 3f5c939c84
5 changed files with 147 additions and 21 deletions

View File

@ -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",
]
}
}

25
build/BUILD.gn Normal file
View File

@ -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" ]
}
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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",
]
}
}