Create initial GN configuration for mini_chromium. This defines a basic GCC-like toolchain, defines some basic configs, and creates the //base target. Currently this only works on Mac. BUG=crashpad:79 Change-Id: I80de898dfa5d693d7e26ce34d9b0591707d4a899 Reviewed-on: https://chromium-review.googlesource.com/411408 Reviewed-by: Mark Mentovai <mark@chromium.org>
diff --git a/.gn b/.gn new file mode 100644 index 0000000..b75a9de --- /dev/null +++ b/.gn
@@ -0,0 +1,5 @@ +# Copyright 2016 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. + +buildconfig = "//build/BUILDCONFIG.gn"
diff --git a/BUILD.gn b/BUILD.gn new file mode 100644 index 0000000..3f86c64 --- /dev/null +++ b/BUILD.gn
@@ -0,0 +1,9 @@ +# Copyright 2016 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. + +group("mini_chromium") { + deps = [ + "//base", + ] +}
diff --git a/base/BUILD.gn b/base/BUILD.gn new file mode 100644 index 0000000..b7777c1 --- /dev/null +++ b/base/BUILD.gn
@@ -0,0 +1,113 @@ +# Copyright 2016 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. + +config("base_public_config") { + include_dirs = [ ".." ] +} + +static_library("base") { + sources = [ + "../build/build_config.h", + "atomicops.h", + "atomicops_internals_atomicword_compat.h", + "atomicops_internals_mac.h", + "atomicops_internals_portable.h", + "atomicops_internals_x86_msvc.h", + "auto_reset.h", + "bit_cast.h", + "compiler_specific.h", + "debug/alias.cc", + "debug/alias.h", + "files/file_path.cc", + "files/file_path.h", + "files/file_util.h", + "files/file_util_posix.cc", + "files/scoped_file.cc", + "files/scoped_file.h", + "format_macros.h", + "lazy_instance.cc", + "lazy_instance.h", + "logging.cc", + "logging.h", + "mac/close_nocancel.cc", + "mac/foundation_util.h", + "mac/foundation_util.mm", + "mac/mach_logging.cc", + "mac/mach_logging.h", + "mac/scoped_cftyperef.h", + "mac/scoped_ioobject.h", + "mac/scoped_launch_data.h", + "mac/scoped_mach_port.cc", + "mac/scoped_mach_port.h", + "mac/scoped_mach_vm.cc", + "mac/scoped_mach_vm.h", + "mac/scoped_nsautorelease_pool.h", + "mac/scoped_nsautorelease_pool.mm", + "mac/scoped_nsobject.h", + "mac/scoped_typeref.h", + "macros.h", + "memory/aligned_memory.cc", + "memory/aligned_memory.h", + "memory/ptr_util.h", + "memory/scoped_policy.h", + "numerics/safe_conversions.h", + "numerics/safe_conversions_impl.h", + "numerics/safe_math.h", + "numerics/safe_math_impl.h", + "posix/eintr_wrapper.h", + "posix/safe_strerror.cc", + "posix/safe_strerror.h", + "rand_util.cc", + "rand_util.h", + "scoped_clear_errno.h", + "scoped_generic.h", + "stl_util.h", + "strings/string16.cc", + "strings/string16.h", + "strings/string_number_conversions.cc", + "strings/string_number_conversions.h", + "strings/string_piece.h", + "strings/string_util.h", + "strings/string_util_posix.h", + "strings/string_util_win.cc", + "strings/string_util_win.h", + "strings/stringprintf.cc", + "strings/stringprintf.h", + "strings/sys_string_conversions.h", + "strings/sys_string_conversions_mac.mm", + "strings/utf_string_conversion_utils.cc", + "strings/utf_string_conversion_utils.h", + "strings/utf_string_conversions.cc", + "strings/utf_string_conversions.h", + "synchronization/condition_variable.h", + "synchronization/condition_variable_posix.cc", + "synchronization/lock.cc", + "synchronization/lock.h", + "synchronization/lock_impl.h", + "synchronization/lock_impl_posix.cc", + "synchronization/lock_impl_win.cc", + "sys_byteorder.h", + "template_util.h", + "third_party/icu/icu_utf.cc", + "third_party/icu/icu_utf.h", + "threading/thread_local_storage.cc", + "threading/thread_local_storage.h", + "threading/thread_local_storage_posix.cc", + "threading/thread_local_storage_win.cc", + ] + + if (is_mac) { + libs = [ + "ApplicationServices.framework", + "CoreFoundation.framework", + "Foundation.framework", + "IOKit.framework", + "Security.framework", + ] + } else if (is_win) { + libs = [ "advapi32.lib" ] + } + + public_configs = [ ":base_public_config" ] +}
diff --git a/build/BUILD.gn b/build/BUILD.gn new file mode 100644 index 0000000..26882b8 --- /dev/null +++ b/build/BUILD.gn
@@ -0,0 +1,133 @@ +# Copyright 2016 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. + +################################################################################ +# DEFAULT BUILD CONFIGURATION +################################################################################ + +config("debug") { +} + +config("release") { + defines = [ "NDEBUG" ] + + if (is_mac) { + cflags = [ "-O3" ] + ldflags = [ "-Wl,-dead_strip" ] + } +} + +config("default") { + if (is_mac) { + cflags = [ + "-Wall", + "-Wendif-labels", + "-Werror", + "-Wextra", + "-Wno-missing-field-initializers", + "-Wno-unused-parameter", + "-Wsign-compare", + "-fno-rtti", + "-fno-strict-aliasing", # See https://crbug.com/32204 + "-fobjc-call-cxx-cdtors", + "-fstack-protector-all", # Implies -fstack-protector + "-fvisibility-inlines-hidden", + "-fvisibility=hidden", + ] + + cflags_c = [ "-std=c99" ] + cflags_cc = [ "-std=c++11" ] + cflags_objc = cflags_c + cflags_objcc = cflags_cc + + if (is_clang) { + cflags += [ + "-Wexit-time-destructors", + "-Wheader-hygiene", + "-Wnewline-eof", + "-Wstring-conversion", + ] + } + } + + if (is_debug) { + configs = [ ":debug" ] + } else { + configs = [ ":release" ] + } +} + +################################################################################ +# TOOLCHAIN DEFINITIONS +################################################################################ + +toolchain("gcc_like_toolchain") { + if (is_clang) { + cc = "clang" + cxx = "clang++" + } else { + cc = "gcc" + cxx = "g++" + } + + tool("cc") { + depfile = "{{output}}.d" + command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" + depsformat = "gcc" + description = "CXX {{output}}" + outputs = [ + "{{target_out_dir}}/{{source_name_part}}.o", + ] + } + + tool("cxx") { + depfile = "{{output}}.d" + command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}" + depsformat = "gcc" + description = "CXX {{output}}" + outputs = [ + "{{target_out_dir}}/{{source_name_part}}.o", + ] + } + + tool("objc") { + depfile = "{{output}}.d" + command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_objc}} -c {{source}} -o {{output}}" + depsformat = "gcc" + description = "OBJC {{output}}" + outputs = [ + "{{target_out_dir}}/{{source_name_part}}.o", + ] + } + + tool("objcxx") { + depfile = "{{output}}.d" + command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_objcc}} -c {{source}} -o {{output}}" + depsformat = "gcc" + description = "OBJCXX {{output}}" + outputs = [ + "{{target_out_dir}}/{{source_name_part}}.o", + ] + } + + tool("alink") { + command = "libtool -static {{arflags}} -o {{output}} {{inputs}}" + description = "LIBTOOL-STATIC {{output}}" + default_output_dir = "{{target_out_dir}}" + default_output_extension = ".a" + output_prefix = "lib" + outputs = [ + "{{output_dir}}/{{target_output_name}}{{output_extension}}", + ] + } + + tool("stamp") { + command = "touch {{output}}" + description = "STAMP {{output}}" + } +} + +toolchain("msvc_toolchain") { + # TODO(rsesek): Not it! +}
diff --git a/build/BUILDCONFIG.gn b/build/BUILDCONFIG.gn new file mode 100644 index 0000000..d61de34 --- /dev/null +++ b/build/BUILDCONFIG.gn
@@ -0,0 +1,105 @@ +# Copyright 2016 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. + +if (target_os == "") { + target_os = host_os +} + +if (current_os == "") { + current_os = target_os +} + +declare_args() { + is_debug = false + is_clang = current_os == "mac" +} + +is_mac = false +is_win = false +is_linux = false +is_android = false + +if (current_os == "mac") { + is_mac = true +} else if (current_os == "win") { + is_win = true +} else if (current_os == "android") { + is_android = true +} else if (current_os == "linux") { + is_linux = true +} + +is_posix = is_mac || is_linux || is_android + +if (is_win) { + set_default_toolchain("//build:msvc_toolchain") +} else { + set_default_toolchain("//build:gcc_like_toolchain") +} + +set_defaults("static_library") { + configs = [ "//build:default" ] +} + +################################################################################ +# SOURCE FILENAME RULES +################################################################################ + +sources_assignment_filter = [] +if (!is_mac) { + sources_assignment_filter += [ + "*_mac.h", + "*_mac.cc", + "*_mac.mm", + "*_mac_unittest.h", + "*_mac_unittest.cc", + "*_mac_unittest.mm", + "*\bmac/*", + "*_cocoa.h", + "*_cocoa.cc", + "*_cocoa.mm", + "*_cocoa_unittest.h", + "*_cocoa_unittest.cc", + "*_cocoa_unittest.mm", + "*\bcocoa/*", + "*\bmach/*", + ] +} +if (!is_linux) { + sources_assignment_filter += [ + "*_linux.h", + "*_linux.cc", + "*_linux_unittest.h", + "*_linux_unittest.cc", + "*\blinux/*", + ] +} +if (!is_android) { + sources_assignment_filter += [ + "*_android.h", + "*_android.cc", + "*_android_unittest.h", + "*_android_unittest.cc", + "*\bandroid/*", + ] +} +if (!is_win) { + sources_assignment_filter += [ + "*_win.cc", + "*_win.h", + "*_win_unittest.cc", + "*\bwin/*", + ] +} +if (!is_posix) { + sources_assignment_filter += [ + "*_posix.h", + "*_posix.cc", + "*_posix_unittest.h", + "*_posix_unittest.cc", + "*\bposix/*", + ] +} + +set_sources_assignment_filter(sources_assignment_filter)
diff --git a/build/common.gypi b/build/common.gypi index 00a038f..de0fa46 100644 --- a/build/common.gypi +++ b/build/common.gypi
@@ -68,7 +68,7 @@ 'CLANG_CXX_LANGUAGE_STANDARD': 'c++11', # -std=c++11 # Don't link in libarclite_macosx.a, see http://crbug.com/156530. - 'CLANG_LINK_OBJC_RUNTIME': 'NO', # -fno-objc-link-runtime + 'CLANG_LINK_OBJC_RUNTIME': 'NO', # No -fobjc-link-runtime # CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS maps to # -Wobjc-missing-property-synthesis