Starting work on full GN build

This change:
- Sucks in gn binaries
- Sucks in a version of llvm that the GN build likes
- Adds tools/gn.py to invoke gn
- Adds a root BUILD.gn and .gn file
- Removes chrome boilerplate we don't need
- etc.

This lets us do a standalone build of the 'runtime'
target for x64, ia32, arm, arm64, mips, and the
simulators on Linux, and arm and arm64 on Android.

It does not include tcmalloc, and hasn't been tested
on Mac or Windows. That work and more cleanup of
chrome boilerplate will come in follow-up CLs.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2350583002 .
This commit is contained in:
Zachary Anderson
2016-09-23 07:47:36 -07:00
parent f87e62ef14
commit 7e1b7e54d7
51 changed files with 2630 additions and 5653 deletions
-54
View File
@@ -1,54 +0,0 @@
# Copyright 2014 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("gmock_config") {
# Gmock headers need to be able to find themselves.
include_dirs = [ "include" ]
}
static_library("gmock") {
# TODO http://crbug.com/412064 enable this flag all the time.
testonly = !is_component_build
sources = [
# Sources based on files in r173 of gmock.
"include/gmock/gmock-actions.h",
"include/gmock/gmock-cardinalities.h",
"include/gmock/gmock-generated-actions.h",
"include/gmock/gmock-generated-function-mockers.h",
"include/gmock/gmock-generated-matchers.h",
"include/gmock/gmock-generated-nice-strict.h",
"include/gmock/gmock-matchers.h",
"include/gmock/gmock-spec-builders.h",
"include/gmock/gmock.h",
"include/gmock/internal/gmock-generated-internal-utils.h",
"include/gmock/internal/gmock-internal-utils.h",
"include/gmock/internal/gmock-port.h",
#"src/gmock-all.cc", # Not needed by our build.
"src/gmock-cardinalities.cc",
"src/gmock-internal-utils.cc",
"src/gmock-matchers.cc",
"src/gmock-spec-builders.cc",
"src/gmock.cc",
]
# This project includes some stuff form gtest's guts.
include_dirs = [ "../gtest/include" ]
public_configs = [
":gmock_config",
"//testing/gtest:gtest_config",
]
}
static_library("gmock_main") {
# TODO http://crbug.com/412064 enable this flag all the time.
testonly = !is_component_build
sources = [
"src/gmock_main.cc",
]
deps = [
":gmock",
]
}
-135
View File
@@ -1,135 +0,0 @@
# Copyright 2014 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("gtest_config") {
visibility = [
":*",
"//testing/gmock:*", # gmock also shares this config.
]
defines = [
# In order to allow regex matches in gtest to be shared between Windows
# and other systems, we tell gtest to always use it's internal engine.
"GTEST_HAS_POSIX_RE=0",
# Chrome doesn't support / require C++11, yet.
"GTEST_LANG_CXX11=0",
]
# Gtest headers need to be able to find themselves.
include_dirs = [ "include" ]
if (is_win) {
cflags = [ "/wd4800" ] # Unused variable warning.
}
if (is_posix) {
defines += [
# gtest isn't able to figure out when RTTI is disabled for gcc
# versions older than 4.3.2, and assumes it's enabled. Our Mac
# and Linux builds disable RTTI, and cannot guarantee that the
# compiler will be 4.3.2. or newer. The Mac, for example, uses
# 4.2.1 as that is the latest available on that platform. gtest
# must be instructed that RTTI is disabled here, and for any
# direct dependents that might include gtest headers.
"GTEST_HAS_RTTI=0",
]
}
if (is_android) {
defines += [
# We want gtest features that use tr1::tuple, but we currently
# don't support the variadic templates used by libstdc++'s
# implementation. gtest supports this scenario by providing its
# own implementation but we must opt in to it.
"GTEST_USE_OWN_TR1_TUPLE=1",
# GTEST_USE_OWN_TR1_TUPLE only works if GTEST_HAS_TR1_TUPLE is set.
# gtest r625 made it so that GTEST_HAS_TR1_TUPLE is set to 0
# automatically on android, so it has to be set explicitly here.
"GTEST_HAS_TR1_TUPLE=1",
]
}
}
config("gtest_direct_config") {
visibility = [ ":*" ]
defines = [ "UNIT_TEST" ]
}
static_library("gtest") {
# TODO http://crbug.com/412064 enable this flag all the time.
testonly = !is_component_build
sources = [
"include/gtest/gtest-death-test.h",
"include/gtest/gtest-message.h",
"include/gtest/gtest-param-test.h",
"include/gtest/gtest-printers.h",
"include/gtest/gtest-spi.h",
"include/gtest/gtest-test-part.h",
"include/gtest/gtest-typed-test.h",
"include/gtest/gtest.h",
"include/gtest/gtest_pred_impl.h",
"include/gtest/internal/gtest-death-test-internal.h",
"include/gtest/internal/gtest-filepath.h",
"include/gtest/internal/gtest-internal.h",
"include/gtest/internal/gtest-linked_ptr.h",
"include/gtest/internal/gtest-param-util-generated.h",
"include/gtest/internal/gtest-param-util.h",
"include/gtest/internal/gtest-port.h",
"include/gtest/internal/gtest-string.h",
"include/gtest/internal/gtest-tuple.h",
"include/gtest/internal/gtest-type-util.h",
#"gtest/src/gtest-all.cc", # Not needed by our build.
"../multiprocess_func_list.cc",
"../multiprocess_func_list.h",
"../platform_test.h",
"src/gtest-death-test.cc",
"src/gtest-filepath.cc",
"src/gtest-internal-inl.h",
"src/gtest-port.cc",
"src/gtest-printers.cc",
"src/gtest-test-part.cc",
"src/gtest-typed-test.cc",
"src/gtest.cc",
]
if (is_mac) {
sources += [
"../gtest_mac.h",
"../gtest_mac.mm",
"../platform_test_mac.mm",
]
}
include_dirs = [ "." ]
all_dependent_configs = [ ":gtest_config" ]
public_configs = [ ":gtest_direct_config" ]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
config("gtest_warnings") {
if (is_win && is_clang) {
# The Mutex constructor initializer list in gtest-port.cc is incorrectly
# ordered. See
# https://groups.google.com/d/msg/googletestframework/S5uSV8L2TX8/U1FaTDa6J6sJ.
cflags = [ "-Wno-reorder" ]
}
}
configs += [ ":gtest_warnings" ]
}
source_set("gtest_main") {
# TODO http://crbug.com/412064 enable this flag all the time.
testonly = !is_component_build
sources = [
"src/gtest_main.cc",
]
deps = [
":gtest",
]
}
-221
View File
@@ -1,221 +0,0 @@
# Copyright 2014 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.
# Do not use the targets in this file unless you need a certain libjpeg
# implementation. Use the meta target //third_party:jpeg instead.
import("//build/config/sanitizers/sanitizers.gni")
if (current_cpu == "arm") {
import("//build/config/arm.gni")
}
if (current_cpu == "x86" || current_cpu == "x64") {
import("//third_party/yasm/yasm_assemble.gni")
yasm_assemble("simd_asm") {
defines = []
if (current_cpu == "x86") {
sources = [
"simd/jccolor-mmx.asm",
"simd/jccolor-sse2.asm",
"simd/jcgray-mmx.asm",
"simd/jcgray-sse2.asm",
"simd/jchuff-sse2.asm",
"simd/jcsample-mmx.asm",
"simd/jcsample-sse2.asm",
"simd/jdcolor-mmx.asm",
"simd/jdcolor-sse2.asm",
"simd/jdmerge-mmx.asm",
"simd/jdmerge-sse2.asm",
"simd/jdsample-mmx.asm",
"simd/jdsample-sse2.asm",
"simd/jfdctflt-3dn.asm",
"simd/jfdctflt-sse.asm",
"simd/jfdctfst-mmx.asm",
"simd/jfdctfst-sse2.asm",
"simd/jfdctint-mmx.asm",
"simd/jfdctint-sse2.asm",
"simd/jidctflt-3dn.asm",
"simd/jidctflt-sse.asm",
"simd/jidctflt-sse2.asm",
"simd/jidctfst-mmx.asm",
"simd/jidctfst-sse2.asm",
"simd/jidctint-mmx.asm",
"simd/jidctint-sse2.asm",
"simd/jidctred-mmx.asm",
"simd/jidctred-sse2.asm",
"simd/jquant-3dn.asm",
"simd/jquant-mmx.asm",
"simd/jquant-sse.asm",
"simd/jquantf-sse2.asm",
"simd/jquanti-sse2.asm",
"simd/jsimdcpu.asm",
]
defines += [
"__x86__",
"PIC",
]
} else if (current_cpu == "x64") {
sources = [
"simd/jccolor-sse2-64.asm",
"simd/jcgray-sse2-64.asm",
"simd/jchuff-sse2-64.asm",
"simd/jcsample-sse2-64.asm",
"simd/jdcolor-sse2-64.asm",
"simd/jdmerge-sse2-64.asm",
"simd/jdsample-sse2-64.asm",
"simd/jfdctflt-sse-64.asm",
"simd/jfdctfst-sse2-64.asm",
"simd/jfdctint-sse2-64.asm",
"simd/jidctflt-sse2-64.asm",
"simd/jidctfst-sse2-64.asm",
"simd/jidctint-sse2-64.asm",
"simd/jidctred-sse2-64.asm",
"simd/jquantf-sse2-64.asm",
"simd/jquanti-sse2-64.asm",
]
defines += [
"__x86_64__",
"PIC",
]
}
if (is_win) {
defines += [ "MSVC" ]
include_dirs = [ "win" ]
if (current_cpu == "x86") {
defines += [ "WIN32" ]
} else {
defines += [ "WIN64" ]
}
} else if (is_mac) {
defines += [ "MACHO" ]
include_dirs = [ "mac" ]
} else if (is_linux || is_android) {
defines += [ "ELF" ]
include_dirs = [ "linux" ]
}
}
}
source_set("simd") {
if (current_cpu == "x86") {
deps = [
":simd_asm",
]
sources = [
"simd/jsimd_i386.c",
]
if (is_win) {
cflags = [ "/wd4245" ]
}
} else if (current_cpu == "x64") {
deps = [
":simd_asm",
]
sources = [
"simd/jsimd_x86_64.c",
]
} else if (current_cpu == "arm" && arm_version >= 7 &&
(arm_use_neon || arm_optionally_use_neon)) {
sources = [
"simd/jsimd_arm.c",
"simd/jsimd_arm_neon.S",
]
} else {
sources = [
"jsimd_none.c",
]
}
if (is_win) {
cflags = [ "/wd4245" ]
}
}
config("libjpeg_config") {
include_dirs = [ "." ]
}
source_set("libjpeg") {
sources = [
"jcapimin.c",
"jcapistd.c",
"jccoefct.c",
"jccolor.c",
"jcdctmgr.c",
"jchuff.c",
"jchuff.h",
"jcinit.c",
"jcmainct.c",
"jcmarker.c",
"jcmaster.c",
"jcomapi.c",
"jconfig.h",
"jcparam.c",
"jcphuff.c",
"jcprepct.c",
"jcsample.c",
"jdapimin.c",
"jdapistd.c",
"jdatadst.c",
"jdatasrc.c",
"jdcoefct.c",
"jdcolor.c",
"jdct.h",
"jddctmgr.c",
"jdhuff.c",
"jdhuff.h",
"jdinput.c",
"jdmainct.c",
"jdmarker.c",
"jdmaster.c",
"jdmerge.c",
"jdphuff.c",
"jdpostct.c",
"jdsample.c",
"jerror.c",
"jerror.h",
"jfdctflt.c",
"jfdctfst.c",
"jfdctint.c",
"jidctflt.c",
"jidctfst.c",
"jidctint.c",
"jidctred.c",
"jinclude.h",
"jmemmgr.c",
"jmemnobs.c",
"jmemsys.h",
"jmorecfg.h",
"jpegint.h",
"jpeglib.h",
"jpeglibmangler.h",
"jquant1.c",
"jquant2.c",
"jutils.c",
"jversion.h",
]
defines = [
"WITH_SIMD",
"NO_GETENV",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
public_configs = [ ":libjpeg_config" ]
# MemorySanitizer doesn't support assembly code, so keep it disabled in
# MSan builds for now.
if (is_msan) {
sources += [ "jsimd_none.c" ]
} else {
deps = [
":simd",
]
}
}
-391
View File
@@ -1,391 +0,0 @@
# Copyright 2014 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.
declare_args() {
use_system_libsrtp = false
use_srtp_boringssl = true
}
config("libsrtp_config") {
defines = [
"HAVE_CONFIG_H",
"HAVE_STDLIB_H",
"HAVE_STRING_H",
"TESTAPP_SOURCE",
]
include_dirs = [
"config",
"srtp/include",
"srtp/crypto/include",
]
if (use_srtp_boringssl) {
defines += [ "OPENSSL" ]
}
if (is_posix) {
defines += [
"HAVE_INT16_T",
"HAVE_INT32_T",
"HAVE_INT8_T",
"HAVE_UINT16_T",
"HAVE_UINT32_T",
"HAVE_UINT64_T",
"HAVE_UINT8_T",
"HAVE_STDINT_H",
"HAVE_INTTYPES_H",
"HAVE_NETINET_IN_H",
"HAVE_ARPA_INET_H",
"HAVE_UNISTD_H",
]
cflags = [ "-Wno-unused-variable" ]
}
if (is_win) {
defines += [
"HAVE_BYTESWAP_METHODS_H",
# All Windows architectures are this way.
"SIZEOF_UNSIGNED_LONG=4",
"SIZEOF_UNSIGNED_LONG_LONG=8",
]
}
if (current_cpu == "x64" || current_cpu == "x86" || current_cpu == "arm") {
defines += [
# TODO(leozwang): CPU_RISC doesn"t work properly on android/arm
# platform for unknown reasons, need to investigate the root cause
# of it. CPU_RISC is used for optimization only, and CPU_CISC should
# just work just fine, it has been tested on android/arm with srtp
# test applications and libjingle.
"CPU_CISC",
]
}
if (current_cpu == "mipsel") {
defines += [ "CPU_RISC" ]
}
}
config("system_libsrtp_config") {
defines = [ "USE_SYSTEM_LIBSRTP" ]
include_dirs = [ "/usr/include/srtp" ]
}
if (use_system_libsrtp) {
group("libsrtp") {
public_configs = [
":libsrtp_config",
":system_libsrtp_config",
]
libs = [ "-lsrtp" ]
}
} else {
static_library("libsrtp") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
public_configs = [ ":libsrtp_config" ]
sources = [
# includes
"srtp/include/ekt.h",
"srtp/include/getopt_s.h",
"srtp/include/rtp.h",
"srtp/include/rtp_priv.h",
"srtp/include/srtp.h",
"srtp/include/srtp_priv.h",
"srtp/include/ut_sim.h",
# headers
"srtp/crypto/include/aes.h",
"srtp/crypto/include/aes_cbc.h",
"srtp/crypto/include/aes_icm.h",
"srtp/crypto/include/alloc.h",
"srtp/crypto/include/auth.h",
"srtp/crypto/include/cipher.h",
"srtp/crypto/include/crypto.h",
"srtp/crypto/include/crypto_kernel.h",
"srtp/crypto/include/crypto_math.h",
"srtp/crypto/include/crypto_types.h",
"srtp/crypto/include/cryptoalg.h",
"srtp/crypto/include/datatypes.h",
"srtp/crypto/include/err.h",
"srtp/crypto/include/gf2_8.h",
"srtp/crypto/include/hmac.h",
"srtp/crypto/include/integers.h",
"srtp/crypto/include/kernel_compat.h",
"srtp/crypto/include/key.h",
"srtp/crypto/include/null_auth.h",
"srtp/crypto/include/null_cipher.h",
"srtp/crypto/include/prng.h",
"srtp/crypto/include/rand_source.h",
"srtp/crypto/include/rdb.h",
"srtp/crypto/include/rdbx.h",
"srtp/crypto/include/sha1.h",
"srtp/crypto/include/stat.h",
"srtp/crypto/include/xfm.h",
# sources
"srtp/crypto/cipher/aes.c",
"srtp/crypto/cipher/aes_cbc.c",
"srtp/crypto/cipher/aes_icm.c",
"srtp/crypto/cipher/cipher.c",
"srtp/crypto/cipher/null_cipher.c",
"srtp/crypto/hash/auth.c",
"srtp/crypto/hash/hmac.c",
"srtp/crypto/hash/null_auth.c",
"srtp/crypto/hash/sha1.c",
"srtp/crypto/kernel/alloc.c",
"srtp/crypto/kernel/crypto_kernel.c",
"srtp/crypto/kernel/err.c",
"srtp/crypto/kernel/key.c",
"srtp/crypto/math/datatypes.c",
"srtp/crypto/math/gf2_8.c",
"srtp/crypto/math/stat.c",
"srtp/crypto/replay/rdb.c",
"srtp/crypto/replay/rdbx.c",
"srtp/crypto/replay/ut_sim.c",
"srtp/crypto/rng/ctr_prng.c",
"srtp/crypto/rng/prng.c",
"srtp/crypto/rng/rand_source.c",
"srtp/srtp/ekt.c",
"srtp/srtp/srtp.c",
]
if (is_clang) {
cflags = [ "-Wno-implicit-function-declaration" ]
}
if (use_srtp_boringssl) {
deps = [
"//third_party/boringssl:boringssl",
]
public_deps = [
"//third_party/boringssl:boringssl",
]
sources -= [
"srtp/crypto/cipher/aes_cbc.c",
"srtp/crypto/cipher/aes_icm.c",
"srtp/crypto/hash/hmac.c",
"srtp/crypto/hash/sha1.c",
"srtp/crypto/rng/ctr_prng.c",
"srtp/crypto/rng/prng.c",
]
sources += [
"srtp/crypto/cipher/aes_gcm_ossl.c",
"srtp/crypto/cipher/aes_icm_ossl.c",
"srtp/crypto/hash/hmac_ossl.c",
"srtp/crypto/include/aes_gcm_ossl.h",
"srtp/crypto/include/aes_icm_ossl.h",
]
}
}
# TODO(GYP): A bunch of these tests don't compile (in gyp either). They're
# not very broken, so could probably be made to work if it's useful.
if (!is_win) {
executable("rdbx_driver") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
deps = [
":libsrtp",
]
sources = [
"srtp/include/getopt_s.h",
"srtp/test/getopt_s.c",
"srtp/test/rdbx_driver.c",
]
}
executable("srtp_driver") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
deps = [
":libsrtp",
]
sources = [
"srtp/include/getopt_s.h",
"srtp/include/srtp_priv.h",
"srtp/test/getopt_s.c",
"srtp/test/srtp_driver.c",
]
}
executable("roc_driver") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
deps = [
":libsrtp",
]
sources = [
"srtp/crypto/include/rdbx.h",
"srtp/include/ut_sim.h",
"srtp/test/roc_driver.c",
]
}
executable("replay_driver") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
deps = [
":libsrtp",
]
sources = [
"srtp/crypto/include/rdbx.h",
"srtp/include/ut_sim.h",
"srtp/test/replay_driver.c",
]
}
executable("rtpw") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
deps = [
":libsrtp",
]
sources = [
"srtp/crypto/include/datatypes.h",
"srtp/include/getopt_s.h",
"srtp/include/rtp.h",
"srtp/include/srtp.h",
"srtp/test/getopt_s.c",
"srtp/test/rtp.c",
"srtp/test/rtpw.c",
]
if (is_android) {
defines = [ "HAVE_SYS_SOCKET_H" ]
}
if (is_clang) {
cflags = [ "-Wno-implicit-function-declaration" ]
}
}
executable("srtp_test_cipher_driver") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
deps = [
":libsrtp",
]
sources = [
"srtp/crypto/test/cipher_driver.c",
"srtp/include/getopt_s.h",
"srtp/test/getopt_s.c",
]
}
executable("srtp_test_datatypes_driver") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
deps = [
":libsrtp",
]
sources = [
"srtp/crypto/test/datatypes_driver.c",
]
}
executable("srtp_test_stat_driver") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
deps = [
":libsrtp",
]
sources = [
"srtp/crypto/test/stat_driver.c",
]
}
executable("srtp_test_sha1_driver") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
deps = [
":libsrtp",
]
sources = [
"srtp/crypto/test/sha1_driver.c",
]
}
executable("srtp_test_kernel_driver") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
deps = [
":libsrtp",
]
sources = [
"srtp/crypto/test/kernel_driver.c",
"srtp/include/getopt_s.h",
"srtp/test/getopt_s.c",
]
}
executable("srtp_test_aes_calc") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
deps = [
":libsrtp",
]
sources = [
"srtp/crypto/test/aes_calc.c",
]
}
executable("srtp_test_rand_gen") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
deps = [
":libsrtp",
]
sources = [
"srtp/crypto/test/rand_gen.c",
"srtp/include/getopt_s.h",
"srtp/test/getopt_s.c",
]
}
executable("srtp_test_rand_gen_soak") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
deps = [
":libsrtp",
]
sources = [
"srtp/crypto/test/rand_gen_soak.c",
"srtp/include/getopt_s.h",
"srtp/test/getopt_s.c",
]
}
executable("srtp_test_env") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
deps = [
":libsrtp",
]
sources = [
"srtp/crypto/test/env.c",
]
}
group("srtp_runtest") {
deps = [
":rdbx_driver",
":srtp_driver",
":roc_driver",
":replay_driver",
":rtpw",
":srtp_test_cipher_driver",
":srtp_test_datatypes_driver",
":srtp_test_stat_driver",
":srtp_test_sha1_driver",
":srtp_test_kernel_driver",
":srtp_test_aes_calc",
":srtp_test_rand_gen",
":srtp_test_rand_gen_soak",
":srtp_test_env",
]
}
}
}
File diff suppressed because it is too large Load Diff
-27
View File
@@ -1,27 +0,0 @@
# Copyright 2014 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.
# This target creates a stamp file that depends on all the sources in the grit
# directory. By depending on this, a target can force itself to be rebuilt if
# grit itself changes.
action("grit_sources") {
depfile = "$target_out_dir/grit_sources.d"
script = "//build/secondary/tools/grit/stamp_grit_sources.py"
inputs = [
"grit.py",
]
# Note that we can't call this "grit_sources.stamp" because that file is
# implicitly created by GN for script actions.
outputs = [
"$target_out_dir/grit_sources.script.stamp",
]
args = [
rebase_path("//tools/grit", root_build_dir),
rebase_path(outputs[0], root_build_dir),
rebase_path(depfile, root_build_dir),
]
}
-483
View File
@@ -1,483 +0,0 @@
# Copyright 2014 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.
# Instantiate grit. This will produce a script target to run grit, and a
# static library that compiles the .cc files.
#
# Parameters
#
# source (required)
# Path to .grd file.
#
# outputs (required)
# List of outputs from grit, relative to the target_gen_dir. Grit will
# verify at build time that this list is correct and will fail if there
# is a mismatch between the outputs specified by the .grd file and the
# outputs list here.
#
# To get this list, you can look in the .grd file for
# <output filename="..." and put those filename here. The base directory
# of the list in Grit and the output list specified in the GN grit target
# are the same (the target_gen_dir) so you can generally copy the names
# exactly.
#
# To get the list of outputs programatically, run:
# python tools/grit/grit_info.py --outputs . path/to/your.grd
# And strip the leading "./" from the output files.
#
# defines (optional)
# Extra defines to pass to grit (on top of the global grit_defines list).
#
# grit_flags (optional)
# List of strings containing extra command-line flags to pass to Grit.
#
# resource_ids (optional)
# Path to a grit "firstidsfile". Default is
# //tools/gritsettings/resource_ids. Set to "" to use the value specified
# in the <grit> nodes of the processed files.
#
# output_dir (optional)
# Directory for generated files. If you specify this, you will often
# want to specify output_name if the target name is not particularly
# unique, since this can cause files from multiple grit targets to
# overwrite each other.
#
# output_name (optiona)
# Provide an alternate base name for the generated files, like the .d
# files. Normally these are based on the target name and go in the
# output_dir, but if multiple targets with the same name end up in
# the same output_dir, they can collide.
#
# depfile_dir (optional)
# If set, used to store the depfile and corresponding stamp file.
# Defaults to output_dir
#
# use_qualified_include (optional)
# If set, output_dir is not added to include_dirs.
#
# configs (optional)
# List of additional configs to be applied to the generated target.
# deps (optional)
# inputs (optional)
# List of additional files, required for grit to process source file.
# visibility (optional)
# Normal meaning.
#
# Example
#
# grit("my_resources") {
# # Source and outputs are required.
# source = "myfile.grd"
# outputs = [
# "foo_strings.h",
# "foo_strings.pak",
# ]
#
# grit_flags = [ "-E", "foo=bar" ] # Optional extra flags.
# # You can also put deps here if the grit source depends on generated
# # files.
# }
import("//build/config/chrome_build.gni")
import("//build/config/crypto.gni")
import("//build/config/features.gni")
import("//build/config/ui.gni")
grit_defines = []
# Mac and iOS want Title Case strings.
use_titlecase_in_grd_files = is_mac || is_ios
if (use_titlecase_in_grd_files) {
grit_defines += [
"-D",
"use_titlecase",
]
}
if (is_chrome_branded) {
grit_defines += [
"-D",
"_google_chrome",
"-E",
"CHROMIUM_BUILD=google_chrome",
]
} else {
grit_defines += [
"-D",
"_chromium",
"-E",
"CHROMIUM_BUILD=chromium",
]
}
if (is_chromeos) {
grit_defines += [
"-D",
"chromeos",
"-D",
"scale_factors=2x",
]
}
if (is_desktop_linux) {
grit_defines += [
"-D",
"desktop_linux",
]
}
if (toolkit_views) {
grit_defines += [
"-D",
"toolkit_views",
]
}
if (use_aura) {
grit_defines += [
"-D",
"use_aura",
]
}
if (use_ash) {
grit_defines += [
"-D",
"use_ash",
]
}
if (use_nss_certs) {
grit_defines += [
"-D",
"use_nss_certs",
]
}
if (use_ozone) {
grit_defines += [
"-D",
"use_ozone",
]
}
if (enable_image_loader_extension) {
grit_defines += [
"-D",
"image_loader_extension",
]
}
if (enable_remoting) {
grit_defines += [
"-D",
"remoting",
]
}
if (is_android) {
grit_defines += [
"-t",
"android",
"-E",
"ANDROID_JAVA_TAGGED_ONLY=true",
]
}
if (is_mac || is_ios) {
grit_defines += [
"-D",
"scale_factors=2x",
]
}
if (is_ios) {
grit_defines += [
"-t",
"ios",
# iOS uses a whitelist to filter resources.
"-w",
rebase_path("//build/ios/grit_whitelist.txt", root_build_dir),
]
}
if (enable_extensions) {
grit_defines += [
"-D",
"enable_extensions",
]
}
if (enable_media_router) {
grit_defines += [
"-D",
"enable_media_router",
]
}
if (enable_plugins) {
grit_defines += [
"-D",
"enable_plugins",
]
}
if (enable_basic_printing || enable_print_preview) {
grit_defines += [
"-D",
"enable_printing",
]
if (enable_print_preview) {
grit_defines += [
"-D",
"enable_print_preview",
]
}
}
if (enable_themes) {
grit_defines += [
"-D",
"enable_themes",
]
}
if (enable_app_list) {
grit_defines += [
"-D",
"enable_app_list",
]
}
if (enable_settings_app) {
grit_defines += [
"-D",
"enable_settings_app",
]
}
if (enable_google_now) {
grit_defines += [
"-D",
"enable_google_now",
]
}
# Note: use_concatenated_impulse_responses is omitted. It is never used and
# should probably be removed from GYP build.
if (enable_webrtc) {
grit_defines += [
"-D",
"enable_webrtc",
]
}
if (enable_hangout_services_extension) {
grit_defines += [
"-D",
"enable_hangout_services_extension",
]
}
if (enable_task_manager) {
grit_defines += [
"-D",
"enable_task_manager",
]
}
if (enable_notifications) {
grit_defines += [
"-D",
"enable_notifications",
]
}
if (enable_wifi_bootstrapping) {
grit_defines += [
"-D",
"enable_wifi_bootstrapping",
]
}
if (enable_service_discovery) {
grit_defines += [
"-D",
"enable_service_discovery",
]
}
if (mac_views_browser) {
grit_defines += [
"-D",
"mac_views_browser",
]
}
grit_resource_id_file = "//tools/gritsettings/resource_ids"
grit_info_script = "//tools/grit/grit_info.py"
template("grit") {
assert(defined(invoker.source),
"\"source\" must be defined for the grit template $target_name")
grit_inputs = [ invoker.source ]
if (defined(invoker.resource_ids)) {
resource_ids = invoker.resource_ids
} else {
resource_ids = grit_resource_id_file
}
if (resource_ids != "") {
# The script depends on the ID file. Only add this dependency if the ID
# file is specified.
grit_inputs += [ resource_ids ]
}
if (defined(invoker.output_dir)) {
output_dir = invoker.output_dir
} else {
output_dir = target_gen_dir
}
if (defined(invoker.output_name)) {
grit_output_name = invoker.output_name
} else {
grit_output_name = target_name
}
if (defined(invoker.depfile_dir)) {
depfile_dir = invoker.depfile_dir
} else {
depfile_dir = output_dir
}
# These are all passed as arguments to the script so have to be relative to
# the build directory.
if (resource_ids != "") {
resource_ids = rebase_path(resource_ids, root_build_dir)
}
rebased_output_dir = rebase_path(output_dir, root_build_dir)
source_path = rebase_path(invoker.source, root_build_dir)
if (defined(invoker.grit_flags)) {
grit_flags = invoker.grit_flags
} else {
grit_flags = [] # These are optional so default to empty list.
}
assert_files_flags = []
# We want to make sure the declared outputs actually match what Grit is
# writing. We write the list to a file (some of the output lists are long
# enough to not fit on a Windows command line) and ask Grit to verify those
# are the actual outputs at runtime.
asserted_list_file =
"$target_out_dir/${grit_output_name}_expected_outputs.txt"
write_file(asserted_list_file,
rebase_path(invoker.outputs, root_build_dir, output_dir))
assert_files_flags += [ "--assert-file-list=" +
rebase_path(asserted_list_file, root_build_dir) ]
grit_outputs =
get_path_info(rebase_path(invoker.outputs, ".", output_dir), "abspath")
# The config and the action below get this visibility son only the generated
# source set can depend on them. The variable "target_name" will get
# overwritten inside the inner classes so we need to compute it here.
target_visibility = [ ":$target_name" ]
# The current grit setup makes an file in $output_dir/grit/foo.h that
# the source code expects to include via "grit/foo.h". It would be nice to
# change this to including absolute paths relative to the root gen directory
# (like "mycomponent/foo.h"). This config sets up the include path.
grit_config = target_name + "_grit_config"
config(grit_config) {
if (!defined(invoker.use_qualified_include) ||
!invoker.use_qualified_include) {
include_dirs = [ output_dir ]
}
visibility = target_visibility
}
grit_custom_target = target_name + "_grit"
action(grit_custom_target) {
script = "//tools/grit/grit.py"
inputs = grit_inputs
depfile = "$depfile_dir/${grit_output_name}_stamp.d"
outputs = [ "${depfile}.stamp" ] + grit_outputs
args = [
"-i",
source_path,
"build",
]
if (resource_ids != "") {
args += [
"-f",
resource_ids,
]
}
args += [
"-o",
rebased_output_dir,
"--depdir",
".",
"--depfile",
rebase_path(depfile, root_build_dir),
"--write-only-new=1",
"--depend-on-stamp",
] + grit_defines
# Add extra defines with -D flags.
if (defined(invoker.defines)) {
foreach(i, invoker.defines) {
args += [
"-D",
i,
]
}
}
args += grit_flags + assert_files_flags
if (defined(invoker.visibility)) {
# This needs to include both what the invoker specified (since they
# probably include generated headers from this target), as well as the
# generated source set (since there's no guarantee that the visibility
# specified by the invoker includes our target).
#
# Only define visibility at all if the invoker specified it. Otherwise,
# we want to keep the public "no visibility specified" default.
visibility = target_visibility + invoker.visibility
}
deps = [
"//tools/grit:grit_sources",
]
if (defined(invoker.deps)) {
deps += invoker.deps
}
if (defined(invoker.inputs)) {
inputs += invoker.inputs
}
}
# This is the thing that people actually link with, it must be named the
# same as the argument the template was invoked with.
source_set(target_name) {
# Since we generate a file, we need to be run before the targets that
# depend on us.
sources = grit_outputs
# Deps set on the template invocation will go on the action that runs
# grit above rather than this library. This target needs to depend on the
# action publicly so other scripts can take the outputs from the grit
# script as inputs.
public_deps = [
":$grit_custom_target",
]
public_configs = [ ":$grit_config" ]
if (defined(invoker.public_configs)) {
public_configs += invoker.public_configs
}
if (defined(invoker.configs)) {
configs += invoker.configs
}
if (defined(invoker.visibility)) {
visibility = invoker.visibility
}
output_name = grit_output_name
}
}
-47
View File
@@ -1,47 +0,0 @@
# Copyright 2014 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.
# This file defines a template to invoke grit repack in a consistent manner.
#
# Parameters:
# sources [required]
# List of pak files that need to be combined.
#
# output [required]
# File name (single string) of the output file.
#
# repack_options [optional]
# List of extra arguments to pass.
#
# deps [optional]
# visibility [optional]
# Normal meaning.
template("repack") {
action(target_name) {
assert(defined(invoker.sources), "Need sources for $target_name")
assert(defined(invoker.output), "Need output for $target_name")
if (defined(invoker.visibility)) {
visibility = invoker.visibility
}
script = "//tools/grit/grit/format/repack.py"
inputs = invoker.sources
outputs = [
invoker.output,
]
args = []
if (defined(invoker.repack_options)) {
args += invoker.repack_options
}
args += [ rebase_path(invoker.output, root_build_dir) ]
args += rebase_path(invoker.sources, root_build_dir)
if (defined(invoker.deps)) {
deps = invoker.deps
}
}
}
@@ -1,55 +0,0 @@
# Copyright 2014 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.
# This script enumerates the files in the given directory, writing an empty
# stamp file and a .d file listing the inputs required to make the stamp. This
# allows us to dynamically depend on the grit sources without enumerating the
# grit directory for every invocation of grit (which is what adding the source
# files to every .grd file's .d file would entail) or shelling out to grit
# synchronously during GN execution to get the list (which would be slow).
#
# Usage:
# stamp_grit_sources.py <directory> <stamp-file> <.d-file>
import os
import sys
def GritSourceFiles(grit_root_dir):
files = []
for root, _, filenames in os.walk(grit_root_dir):
grit_src = [os.path.join(root, f) for f in filenames
if f.endswith('.py') and not f.endswith('_unittest.py')]
files.extend(grit_src)
files = [f.replace('\\', '/') for f in files]
return sorted(files)
def WriteDepFile(dep_file, stamp_file, source_files):
with open(dep_file, "w") as f:
f.write(stamp_file)
f.write(": ")
f.write(' '.join(source_files))
def WriteStampFile(stamp_file):
with open(stamp_file, "w"):
pass
def main(argv):
if len(argv) != 4:
print "Error: expecting 3 args."
return 1
grit_root_dir = sys.argv[1]
stamp_file = sys.argv[2]
dep_file = sys.argv[3]
WriteStampFile(stamp_file)
WriteDepFile(dep_file, stamp_file, GritSourceFiles(grit_root_dir))
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv))