Move files from the secondary GN directory to build.
Since this build is looking less experimental, I'm moving the files out of secondary into the corresponding location in src/build. I added owners files that just include me. For now I'd like to review all changes here. BUG= R=scottmg@chromium.org Review URL: https://codereview.chromium.org/68793009 git-svn-id: http://src.chromium.org/svn/trunk/src/build@236319 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
Родитель
7ed047c46b
Коммит
c54085c7d3
|
@ -0,0 +1,50 @@
|
|||
# Copyright (c) 2013 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("my_msvs") {
|
||||
defines = [
|
||||
"CHROMIUM_BUILD",
|
||||
"TOOLKIT_VIEWS=1",
|
||||
"USE_LIBJPEG_TURBO=1",
|
||||
"ENABLE_ONE_CLICK_SIGNIN",
|
||||
"ENABLE_REMOTING=1",
|
||||
"ENABLE_WEBRTC=1",
|
||||
"ENABLE_CONFIGURATION_POLICY",
|
||||
"ENABLE_INPUT_SPEECH",
|
||||
"ENABLE_NOTIFICATIONS",
|
||||
"ENABLE_EGLIMAGE=1",
|
||||
"ENABLE_TASK_MANAGER=1",
|
||||
"ENABLE_EXTENSIONS=1",
|
||||
"ENABLE_PLUGIN_INSTALLATION=1",
|
||||
"ENABLE_PLUGINS=1",
|
||||
"ENABLE_SESSION_SERVICE=1",
|
||||
"ENABLE_THEMES=1",
|
||||
"ENABLE_AUTOFILL_DIALOG=1",
|
||||
"ENABLE_BACKGROUND=1",
|
||||
"ENABLE_AUTOMATION=1",
|
||||
"ENABLE_GOOGLE_NOW=1",
|
||||
"ENABLE_PRINTING=1",
|
||||
"ENABLE_CAPTIVE_PORTAL_DETECTION=1",
|
||||
"ENABLE_APP_LIST=1",
|
||||
"ENABLE_MESSAGE_CENTER=1",
|
||||
"ENABLE_SETTINGS_APP=1",
|
||||
"ENABLE_MANAGED_USERS=1",
|
||||
]
|
||||
}
|
||||
|
||||
config("feature_flags") {
|
||||
#defines =
|
||||
}
|
||||
|
||||
config("debug") {
|
||||
defines = [
|
||||
"_DEBUG",
|
||||
"DYNAMIC_ANNOTATIONS_ENABLED=1",
|
||||
"WTF_USE_DYNAMIC_ANNOTATIONS=1",
|
||||
]
|
||||
}
|
||||
|
||||
config("release") {
|
||||
|
||||
}
|
|
@ -0,0 +1,388 @@
|
|||
# Copyright (c) 2013 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.
|
||||
|
||||
# =============================================================================
|
||||
# BUILD FLAGS
|
||||
# =============================================================================
|
||||
#
|
||||
# This block lists input arguments to the build, along with their default
|
||||
# values. GN requires listing them explicitly so it can validate input and have
|
||||
# a central place to manage the build flags.
|
||||
#
|
||||
# If a value is specified on the command line, it will overwrite the defaults
|
||||
# given here, otherwise the default will be injected into the root scope.
|
||||
#
|
||||
# KEEP IN ALPHABETICAL ORDER and write a good description for everything.
|
||||
# Use "is_*" names for intrinsic platform descriptions and build modes, and
|
||||
# "use_*" names for optional features libraries, and configurations.
|
||||
declare_args() {
|
||||
# How many symbols to include in the build. This affects the performance of
|
||||
# the build since the symbols are large and dealing with them is slow.
|
||||
# 2 means regular build with symbols.
|
||||
# 1 means minimal symbols, usually enough for backtraces only.
|
||||
# 0 means no symbols.
|
||||
symbol_level = 2
|
||||
|
||||
# Component build.
|
||||
is_component_build = false
|
||||
# Debug build.
|
||||
is_debug = true
|
||||
|
||||
# Set to true when compiling with the Clang compiler. Typically this is used
|
||||
# to configure warnings.
|
||||
is_clang = false
|
||||
|
||||
# ASH is enabled.
|
||||
# TODO(brettw) this should be moved out of the main build config file.
|
||||
use_ash = false
|
||||
# Aura is enabled.
|
||||
# TODO(brettw) this should be moved out of the main build config file.
|
||||
use_aura = false
|
||||
# Ozone is enabled.
|
||||
# TODO(brettw) this should be moved out of the main build config file.
|
||||
use_ozone = false
|
||||
|
||||
# Set to true on the command line when invoked by GYP. Build files can key
|
||||
# off of this to make any GYP-output-specific changes to the build.
|
||||
is_gyp = false
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
# OS DEFINITIONS
|
||||
# =============================================================================
|
||||
#
|
||||
# We set these various is_FOO booleans for convenience in writing OS-based
|
||||
# conditions.
|
||||
#
|
||||
# - is_android, is_chromeos, is_ios, and is_win should be obvious.
|
||||
# - is_mac is set only for desktop Mac. It is not set on iOS.
|
||||
# - is_posix is true for mac and any Unix-like system (basically everything
|
||||
# except Windows).
|
||||
# - is_linux is true for any Linux variant including Android and ChromeOS.
|
||||
#
|
||||
# Do not add more is_* variants here for random lesser-used Unix systems like
|
||||
# aix or one of the BSDs. If you need to check these, just check the os value
|
||||
# directly.
|
||||
|
||||
if (os == "win") {
|
||||
is_android = false
|
||||
is_chromeos = false
|
||||
is_ios = false
|
||||
is_linux = false
|
||||
is_mac = false
|
||||
is_nacl = false
|
||||
is_posix = false
|
||||
is_win = true
|
||||
} else if (os == "mac") {
|
||||
is_android = false
|
||||
is_chromeos = false
|
||||
is_ios = false
|
||||
is_linux = false
|
||||
is_mac = true
|
||||
is_nacl = false
|
||||
is_posix = true
|
||||
is_win = false
|
||||
is_clang = true # Always use clang on Mac.
|
||||
} else if (os == "android") {
|
||||
is_android = false
|
||||
is_chromeos = false
|
||||
is_ios = false
|
||||
is_linux = true
|
||||
is_mac = false
|
||||
is_nacl = false
|
||||
is_posix = true
|
||||
is_win = false
|
||||
} else if (os == "chromeos") {
|
||||
is_android = false
|
||||
is_chromeos = true
|
||||
is_ios = false
|
||||
is_linux = true
|
||||
is_mac = false
|
||||
is_nacl = false
|
||||
is_posix = true
|
||||
is_win = false
|
||||
} else if (os == "nacl") {
|
||||
# os == "nacl" will be passed by the nacl toolchain definition. It is not
|
||||
# set by default or on the command line. We treat is as a Posix variant.
|
||||
is_android = false
|
||||
is_chromeos = false
|
||||
is_ios = false
|
||||
is_linux = false
|
||||
is_mac = false
|
||||
is_nacl = true
|
||||
is_posix = true
|
||||
is_win = false
|
||||
} else if (os == "ios") {
|
||||
is_android = false
|
||||
is_chromeos = false
|
||||
is_ios = true
|
||||
is_linux = false
|
||||
is_mac = false
|
||||
is_nacl = false
|
||||
is_posix = true
|
||||
is_win = false
|
||||
} else if (os == "linux") {
|
||||
is_android = false
|
||||
is_chromeos = false
|
||||
is_ios = false
|
||||
is_linux = true
|
||||
is_mac = false
|
||||
is_nacl = false
|
||||
is_posix = true
|
||||
is_win = false
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
# CPU ARCHITECTURE
|
||||
# =============================================================================
|
||||
|
||||
if (is_win) {
|
||||
# Always use 32-bit on Windows, even when compiling on a 64-bit host OS.
|
||||
# TODO(brettw) when we support 64-bit cross-compiles, we probably need to
|
||||
# set a build arg in the toolchain to disable this override.
|
||||
cpu_arch = "ia32"
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
# SOURCES FILTERS
|
||||
# =============================================================================
|
||||
#
|
||||
# These patterns filter out platform-specific files when assigning to the
|
||||
# sources variable. The magic variable |sources_assignment_filter| is applied
|
||||
# to each assignment or appending to the sources variable and matches are
|
||||
# automatcally removed.
|
||||
#
|
||||
# We define lists of filters for each platform for all builds so they can
|
||||
# be used by individual targets if necessary (a target can always change
|
||||
# sources_assignment_filter on itself if it needs something more specific).
|
||||
#
|
||||
# Note that the patterns are NOT regular expressions. Only "*" and "\b" (path
|
||||
# boundary = end of string or slash) are supported, and the entire string
|
||||
# muct match the pattern (so you need "*.cc" to match all .cc files, for
|
||||
# example).
|
||||
|
||||
windows_sources_filters = [
|
||||
"*_win.cc",
|
||||
"*_win.h",
|
||||
"*_win_unittest.cc",
|
||||
"*\bwin/*",
|
||||
]
|
||||
mac_sources_filters = [
|
||||
"*_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/*",
|
||||
]
|
||||
ios_sources_filters = [
|
||||
"*_ios.h",
|
||||
"*_ios.cc",
|
||||
"*_ios.mm",
|
||||
"*_ios_unittest.h",
|
||||
"*_ios_unittest.cc",
|
||||
"*_ios_unittest.mm",
|
||||
"*\bios/*",
|
||||
]
|
||||
objective_c_sources_filters = [
|
||||
"*.mm",
|
||||
]
|
||||
linux_sources_filters = [
|
||||
"*_linux.h",
|
||||
"*_linux.cc",
|
||||
"*_linux_unittest.h",
|
||||
"*_linux_unittest.cc",
|
||||
"*\blinux/*",
|
||||
"*_x11.cc",
|
||||
"*_x11.h",
|
||||
]
|
||||
android_sources_filters = [
|
||||
"*_android.h",
|
||||
"*_android.cc",
|
||||
"*_android_unittest.h",
|
||||
"*_android_unittest.cc",
|
||||
"*\bandroid/*",
|
||||
]
|
||||
posix_sources_filters = [
|
||||
"*_posix.h",
|
||||
"*_posix.cc",
|
||||
"*_posix_unittest.h",
|
||||
"*_posix_unittest.cc",
|
||||
"*\bposix/*",
|
||||
]
|
||||
|
||||
# Construct the full list of sources we're using for this platform.
|
||||
sources_assignment_filter = []
|
||||
if (is_win) {
|
||||
sources_assignment_filter += posix_sources_filters
|
||||
} else {
|
||||
sources_assignment_filter += windows_sources_filters
|
||||
}
|
||||
if (!is_mac) {
|
||||
sources_assignment_filter += mac_sources_filters
|
||||
}
|
||||
if (!is_ios) {
|
||||
sources_assignment_filter += ios_sources_filters
|
||||
}
|
||||
if (!is_mac && !is_ios) {
|
||||
sources_assignment_filter += objective_c_sources_filters
|
||||
}
|
||||
if (!is_linux) {
|
||||
sources_assignment_filter += linux_sources_filters
|
||||
}
|
||||
if (!is_android) {
|
||||
sources_assignment_filter += android_sources_filters
|
||||
}
|
||||
|
||||
# This is the actual set.
|
||||
set_sources_assignment_filter(sources_assignment_filter)
|
||||
|
||||
# =============================================================================
|
||||
# BUILD OPTIONS
|
||||
# =============================================================================
|
||||
|
||||
if (is_component_build) {
|
||||
component_mode = "shared_library"
|
||||
} else {
|
||||
component_mode = "static_library"
|
||||
}
|
||||
|
||||
toolkit_uses_gtk = is_linux
|
||||
|
||||
# =============================================================================
|
||||
# TARGET DEFAULTS
|
||||
# =============================================================================
|
||||
#
|
||||
# Set up the default configuration for every build target of the given type.
|
||||
# The values configured here will be automatically set on the scope of the
|
||||
# corresponding target. Target definitions can add or remove to the settings
|
||||
# here as needed.
|
||||
|
||||
# Holds all configs used for making native executables and libraries, to avoid
|
||||
# duplication in each target below.
|
||||
native_compiler_configs = [
|
||||
"//build/config:my_msvs", # TODO(brettw) eraseme
|
||||
|
||||
"//build/config/compiler:compiler",
|
||||
"//build/config/compiler:chromium_code",
|
||||
"//build/config/compiler:default_warnings",
|
||||
"//build/config/compiler:no_rtti",
|
||||
"//build/config/compiler:runtime_library",
|
||||
]
|
||||
if (is_win) {
|
||||
native_compiler_configs += [
|
||||
"//build/config/win:sdk",
|
||||
]
|
||||
} else if (is_clang) {
|
||||
native_compiler_configs += "//build/config/clang:find_bad_constructs"
|
||||
}
|
||||
|
||||
# Optimizations and debug checking.
|
||||
if (is_debug) {
|
||||
native_compiler_configs += "//build/config:debug"
|
||||
default_optimization_config = "//build/config/compiler:no_optimize"
|
||||
} else {
|
||||
native_compiler_configs += "//build/config:release"
|
||||
default_optimization_config = "//build/config/compiler:optimize"
|
||||
}
|
||||
native_compiler_configs += default_optimization_config
|
||||
|
||||
# Symbol setup.
|
||||
if (is_clang && (is_linux || is_android)) {
|
||||
# Clang creates chubby debug information, which makes linking very slow.
|
||||
# For now, don't create debug information with clang.
|
||||
# See http://crbug.com/70000
|
||||
# TODO(brettw) This just copies GYP. Why not do this on Mac as well?
|
||||
default_symbols_config = "//build/config/compiler:no_symbols"
|
||||
} else if (symbol_level == 2) {
|
||||
default_symbols_config = "//build/config/compiler:symbols"
|
||||
} else if (symbol_level == 1) {
|
||||
default_symbols_config = "//build/config/compiler:minimal_symbols"
|
||||
} else if (symbol_level == 0) {
|
||||
default_symbols_config = "//build/config/compiler:no_symbols"
|
||||
} else {
|
||||
assert(false, "Bad value for symbol_level.")
|
||||
}
|
||||
native_compiler_configs += default_symbols_config
|
||||
|
||||
# Windows linker setup for EXEs and DLLs.
|
||||
if (is_win) {
|
||||
if (is_debug) {
|
||||
default_incremental_linking_config =
|
||||
"//build/config/win:incremental_linking"
|
||||
} else {
|
||||
default_incremental_linking_config =
|
||||
"//build/config/win:no_incremental_linking"
|
||||
}
|
||||
windows_linker_configs = [
|
||||
default_incremental_linking_config,
|
||||
"//build/config/win:sdk_link",
|
||||
"//build/config/win:common_linker_setup",
|
||||
# Default to console-mode apps. Most of our targets are tests and such
|
||||
# that shouldn't use the windows subsystem.
|
||||
"//build/config/win:console",
|
||||
]
|
||||
}
|
||||
|
||||
set_defaults("executable") {
|
||||
configs = native_compiler_configs
|
||||
if (is_win) {
|
||||
configs += windows_linker_configs
|
||||
} else if (is_mac) {
|
||||
configs += "//build/config/mac:mac_dynamic_flags"
|
||||
} else if (is_linux) {
|
||||
configs += "//build/config/linux:executable_ldconfig"
|
||||
}
|
||||
}
|
||||
|
||||
set_defaults("static_library") {
|
||||
configs = native_compiler_configs
|
||||
}
|
||||
|
||||
set_defaults("shared_library") {
|
||||
configs = native_compiler_configs
|
||||
if (is_win) {
|
||||
configs += windows_linker_configs
|
||||
} else if (is_mac) {
|
||||
configs += "//build/config/mac:mac_dynamic_flags"
|
||||
}
|
||||
}
|
||||
|
||||
set_defaults("source_set") {
|
||||
configs = native_compiler_configs
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# TOOLCHAIN SETUP
|
||||
# ==============================================================================
|
||||
#
|
||||
# Here we set the default toolchain, as well as the variable host_toolchain
|
||||
# which will identify the toolchain corresponding to the local system when
|
||||
# doing cross-compiles. When not cross-compiling, this will be the same as the
|
||||
# default toolchain.
|
||||
|
||||
if (is_win) {
|
||||
host_toolchain = "//build/toolchain/win:32"
|
||||
set_default_toolchain(host_toolchain)
|
||||
} else if (is_linux) {
|
||||
host_toolchain = "//build/toolchain/linux:host"
|
||||
if (cpu_arch == "arm" && build_cpu_arch != "arm") {
|
||||
# Special toolchain for ARM cross-compiling.
|
||||
set_default_toolchain("//build/toolchain/linux:arm-cross-compile")
|
||||
} else {
|
||||
# Use whatever GCC is on the current platform.
|
||||
set_default_toolchain(host_toolchain)
|
||||
}
|
||||
} else if (is_mac) {
|
||||
host_toolchain = "//build/toolchain/mac:clang"
|
||||
set_default_toolchain(host_toolchain)
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
set noparent
|
||||
brettw@chromium.org
|
|
@ -0,0 +1,18 @@
|
|||
# Copyright (c) 2013 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("find_bad_constructs") {
|
||||
cflags = [
|
||||
"-Xclang", "-load",
|
||||
"-Xclang",
|
||||
|
||||
# TODO(brettw) express this in terms of a relative dir from the output.
|
||||
# for now, assume the output dir is two levels deep under the source
|
||||
# (like "out/Debug").
|
||||
"../../third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.dylib",
|
||||
|
||||
"-Xclang", "-add-plugin",
|
||||
"-Xclang", "find-bad-constructs",
|
||||
]
|
||||
}
|
|
@ -0,0 +1,396 @@
|
|||
# Copyright (c) 2013 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.
|
||||
|
||||
# Base compiler configuration.
|
||||
config("compiler") {
|
||||
include_dirs = [ "//", root_gen_dir ]
|
||||
if (is_win) {
|
||||
cflags = [
|
||||
"/Gy", # Enable function-level linking.
|
||||
"/GS", # Enable buffer security checking.
|
||||
"/EHsc", # Assume C functions can't throw exceptions and don't catch
|
||||
# structured exceptions (only C++ ones).
|
||||
]
|
||||
} else {
|
||||
# Common GCC compiler flags setup.
|
||||
# --------------------------------
|
||||
cflags = [
|
||||
"-fno-strict-aliasing", # See http://crbug.com/32204
|
||||
"-fvisibility=hidden",
|
||||
]
|
||||
cflags_c = [
|
||||
]
|
||||
cflags_cc = [
|
||||
"-fno-exceptions",
|
||||
"-fno-threadsafe-statics",
|
||||
"-fvisibility-inlines-hidden",
|
||||
]
|
||||
ldflags = [
|
||||
]
|
||||
|
||||
# Stack protection.
|
||||
# TODO(brettw) why do we have different values for all of these cases?
|
||||
if (is_mac) {
|
||||
cflags += "-fstack-protector-all"
|
||||
} else if (is_chromeos) {
|
||||
cflags += "-fstack-protector-strong"
|
||||
} else if (is_linux) {
|
||||
cflags += [ "-fstack-protector", "--param=ssp-buffer-size=4" ]
|
||||
}
|
||||
|
||||
# Mac-specific compiler flags setup.
|
||||
# ----------------------------------
|
||||
if (is_mac) {
|
||||
# These flags are shared between the C compiler and linker.
|
||||
common_mac_flags = [
|
||||
# TODO(brettw) obviously this arch flag needs to be parameterized.
|
||||
"-arch i386",
|
||||
|
||||
# Set which SDK to use.
|
||||
# TODO(brettw) this needs to be configurable somehow.
|
||||
"-isysroot", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk",
|
||||
|
||||
"-mmacosx-version-min=10.6",
|
||||
]
|
||||
|
||||
cflags += common_mac_flags + [
|
||||
# Without this, the constructors and destructors of a C++ object inside
|
||||
# an Objective C struct won't be called, which is very bad.
|
||||
"-fobjc-call-cxx-cdtors",
|
||||
]
|
||||
|
||||
cflags_c += [ "-std=c99" ]
|
||||
cflags_cc += [ "-std=gnu++11" ]
|
||||
|
||||
ldflags += common_mac_flags + [
|
||||
"-L.",
|
||||
|
||||
# TODO(brettW) I don't understand these options.
|
||||
"-Wl,-rpath,@loader_path/.",
|
||||
"-Wl,-rpath,@loader_path/../../..",
|
||||
]
|
||||
}
|
||||
|
||||
# Linux-specific compiler flags setup.
|
||||
# ------------------------------------
|
||||
if (is_linux) {
|
||||
cflags += [
|
||||
"-fPIC",
|
||||
"-pthread",
|
||||
"-pipe", # Use pipes for communicating between sub-processes. Faster.
|
||||
]
|
||||
|
||||
# Use gold for linking on 64-bit Linux only (on 32-bit it runs out of
|
||||
# address space, and it doesn't support cross-compiling).
|
||||
if (cpu_arch == "ia64") {
|
||||
gold_path = rebase_path("//third_party/gold", ".", root_build_dir)
|
||||
ldflags += [
|
||||
"-B$gold_path",
|
||||
|
||||
# There seems to be a conflict of --icf and -pie in gold which can
|
||||
# generate crashy binaries. As a security measure, -pie takes
|
||||
# precendence for now.
|
||||
# TODO(brettw) common.gypi has this only for target toolset.
|
||||
#"-Wl,--icf=safe",
|
||||
"-Wl,--icf=none",
|
||||
|
||||
# Experimentation found that using four linking threads
|
||||
# saved ~20% of link time.
|
||||
# https://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/281527606915bb36
|
||||
# Only apply this to the target linker, since the host
|
||||
# linker might not be gold, but isn't used much anyway.
|
||||
"-Wl,--threads",
|
||||
"-Wl,--thread-count=4",
|
||||
]
|
||||
}
|
||||
|
||||
ldflags += [
|
||||
"-fPIC",
|
||||
"-pthread",
|
||||
"-Wl,-z,noexecstack",
|
||||
"-Wl,-z,now",
|
||||
"-Wl,-z,relro",
|
||||
]
|
||||
}
|
||||
|
||||
# Clang-specific compiler flags setup.
|
||||
# ------------------------------------
|
||||
if (is_clang) {
|
||||
cflags += [
|
||||
"-fcolor-diagnostics",
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# runtime_library -------------------------------------------------------------
|
||||
#
|
||||
# Sets the runtime library and associated options.
|
||||
#
|
||||
# We don't bother making multiple versions that are toggle-able since there
|
||||
# is more than one axis of control (which makes it complicated) and there's
|
||||
# no practical reason for anybody to change this since the CRT must agree.
|
||||
|
||||
config("runtime_library") {
|
||||
if (is_component_build) {
|
||||
# Component mode: dynamic CRT.
|
||||
defines = [ "COMPONENT_BUILD" ]
|
||||
if (is_win) {
|
||||
# Since the library is shared, it requires exceptions or will give errors
|
||||
# about things not matching, so keep exceptions on.
|
||||
if (is_debug) {
|
||||
cflags = [ "/MDd" ]
|
||||
} else {
|
||||
cflags = [ "/MD" ]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# Static CRT.
|
||||
if (is_win) {
|
||||
# We don't use exceptions, and when we link statically we can just get
|
||||
# rid of them entirely.
|
||||
defines = [ "_HAS_EXCEPTIONS=0" ]
|
||||
if (is_debug) {
|
||||
cflags = [ "/MTd" ]
|
||||
} else {
|
||||
cflags = [ "/MT" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_win) {
|
||||
defines += [
|
||||
"__STD_C",
|
||||
"__STDC_CONSTANT_MACROS",
|
||||
"__STDC_FORMAT_MACROS",
|
||||
"_CRT_RAND_S",
|
||||
"_CRT_SECURE_NO_DEPRECATE",
|
||||
"_SCL_SECURE_NO_DEPRECATE",
|
||||
"_UNICODE",
|
||||
"UNICODE",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
# chromium_code ---------------------------------------------------------------
|
||||
#
|
||||
# Toggles between higher and lower warnings for code that is (or isn't)
|
||||
# part of Chromium.
|
||||
|
||||
config("chromium_code") {
|
||||
if (is_win) {
|
||||
cflags = [
|
||||
"/W4", # Warning level 4.
|
||||
"/WX", # Treat warnings as errors.
|
||||
]
|
||||
} else {
|
||||
cflags = [
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
|
||||
# GCC turns on -Wsign-compare for C++ under -Wall, but clang doesn't,
|
||||
# so we specify it explicitly.
|
||||
# TODO(fischman): remove this if http://llvm.org/PR10448 obsoletes it.
|
||||
# http://code.google.com/p/chromium/issues/detail?id=90453
|
||||
"-Wsign-compare",
|
||||
]
|
||||
|
||||
# In Chromium code, we define __STDC_foo_MACROS in order to get the
|
||||
# C99 macros on Mac and Linux.
|
||||
defines = [
|
||||
"__STDC_CONSTANT_MACROS",
|
||||
"__STDC_FORMAT_MACROS",
|
||||
]
|
||||
|
||||
# TODO(brettw) this should also be enabled on Linux but some files
|
||||
# currently fail.
|
||||
if (is_mac) {
|
||||
cflags += "-Wextra"
|
||||
}
|
||||
}
|
||||
}
|
||||
config("no_chromium_code") {
|
||||
if (is_win) {
|
||||
cflags = [
|
||||
"/W3", # Warning level 3.
|
||||
"/wd4800", # Disable warning when forcing value to bool.
|
||||
]
|
||||
defines = [
|
||||
"_CRT_NONSTDC_NO_WARNINGS",
|
||||
"_CRT_NONSTDC_NO_DEPRECATE",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
# rtti ------------------------------------------------------------------------
|
||||
#
|
||||
# Allows turning Run-Time Type Identification on or off.
|
||||
|
||||
config("rtti") {
|
||||
if (is_win) {
|
||||
cflags_cc = [ "/GR" ]
|
||||
}
|
||||
}
|
||||
config("no_rtti") {
|
||||
if (is_win) {
|
||||
cflags_cc = [ "/GR-" ]
|
||||
} else {
|
||||
cflags_cc = [ "-fno-rtti" ]
|
||||
}
|
||||
}
|
||||
|
||||
# Warnings ---------------------------------------------------------------------
|
||||
|
||||
config("default_warnings") {
|
||||
if (is_win) {
|
||||
# Please keep ordered and add names if you add more.
|
||||
cflags = [
|
||||
"/wd4018", # Comparing signed and unsigned values.
|
||||
"/wd4100", # Unreferenced formal function parameter.
|
||||
"/wd4121", # Alignment of a member was sensitive to packing.
|
||||
"/wd4125", # Decimal digit terminates octal escape sequence.
|
||||
"/wd4127", # Conditional expression is constant.
|
||||
"/wd4130", # Logical operation on address of string constant.
|
||||
# TODO(brettw) is this necessary? If so, it should probably be on whoever
|
||||
# is silly enough to be doing this rather than globally.
|
||||
#"/wd4131", # Function uses old-style declarator.
|
||||
"/wd4189", # A variable was declared and initialized but never used.
|
||||
"/wd4201", # Nonstandard extension used: nameless struct/union.
|
||||
"/wd4238", # Nonstandard extension used: class rvalue used as lvalue.
|
||||
"/wd4244", # Conversion: possible loss of data.
|
||||
"/wd4245", # Conversion: signed/unsigned mismatch,
|
||||
"/wd4251", # Class needs to have dll-interface.
|
||||
"/wd4310", # Cast truncates constant value.
|
||||
"/wd4351", # Elements of array will be default initialized.
|
||||
"/wd4355", # 'this' used in base member initializer list.
|
||||
"/wd4396", # Inline friend template thing.
|
||||
"/wd4428", # Universal character name encountered in source.
|
||||
"/wd4481", # Nonstandard extension: override specifier.
|
||||
"/wd4503", # Decorated name length exceeded, name was truncated.
|
||||
"/wd4505", # Unreferenced local function has been removed.
|
||||
"/wd4510", # Default constructor could not be generated.
|
||||
"/wd4512", # Assignment operator could not be generated.
|
||||
"/wd4530", # Exception handler used, but unwind semantics not enabled.
|
||||
"/wd4610", # Class can never be instantiated, constructor required.
|
||||
"/wd4611", # C++ object destruction and 'catch'.
|
||||
"/wd4701", # Potentially uninitialized local variable name used.
|
||||
"/wd4702", # Unreachable code.
|
||||
"/wd4706", # Assignment within conditional expression.
|
||||
"/wd4819", # Character not in the current code page.
|
||||
]
|
||||
} else {
|
||||
# Common GCC warning setup.
|
||||
cflags = [
|
||||
# Enables.
|
||||
"-Wendif-labels", # Weird old-style text after an #endif.
|
||||
|
||||
# Disables.
|
||||
"-Wno-missing-field-initializers", # "struct foo f = {0};"
|
||||
"-Wno-unused-parameter", # Unused function parameters.
|
||||
"-Wno-write-strings",
|
||||
]
|
||||
|
||||
if (is_mac) {
|
||||
cflags += [
|
||||
"-Wnewline-eof",
|
||||
]
|
||||
}
|
||||
|
||||
# TODO(brettw) Ones below here should be clang-only when we have a flag
|
||||
# for it.
|
||||
if (is_clang) {
|
||||
cflags += [
|
||||
"-Wheader-hygiene",
|
||||
|
||||
# This warns on using ints as initializers for floats in
|
||||
# initializer lists (e.g. |int a = f(); CGSize s = { a, a };|),
|
||||
# which happens in several places in chrome code. Not sure if
|
||||
# this is worth fixing.
|
||||
"-Wno-c++11-narrowing",
|
||||
|
||||
# Don't die on dtoa code that uses a char as an array index.
|
||||
# This is required solely for base/third_party/dmg_fp/dtoa.cc.
|
||||
# TODO(brettw) move this to that project then!
|
||||
"-Wno-char-subscripts",
|
||||
|
||||
# Warns on switches on enums that cover all enum values but
|
||||
# also contain a default: branch. Chrome is full of that.
|
||||
"-Wno-covered-switch-default",
|
||||
|
||||
# Clang considers the `register` keyword as deprecated, but e.g.
|
||||
# code generated by flex (used in angle) contains that keyword.
|
||||
# http://crbug.com/255186
|
||||
"-Wno-deprecated-register",
|
||||
|
||||
# Clang spots more unused functions.
|
||||
"-Wno-unused-function",
|
||||
|
||||
# Warns when a const char[] is converted to bool.
|
||||
"-Wstring-conversion",
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Optimization -----------------------------------------------------------------
|
||||
|
||||
config("optimize") {
|
||||
if (is_win) {
|
||||
cflags = [
|
||||
"/O2",
|
||||
"/Ob2", # Both explicit and auto inlining.
|
||||
"/Oy-", # Disable omitting frame pointers, must be after /O2.
|
||||
]
|
||||
} else {
|
||||
if (is_ios) {
|
||||
cflags = [ "-Os" ]
|
||||
} else {
|
||||
cflags = [ "-O2" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
config("no_optimize") {
|
||||
if (is_win) {
|
||||
cflags = [
|
||||
"/Od", # Disable optimization.
|
||||
"/Ob0", # Disable all inlining (on by default).
|
||||
"/RTC1", # Runtime checks for stack frame and uninitialized variables.
|
||||
]
|
||||
} else {
|
||||
cflags = [ "-O0" ]
|
||||
}
|
||||
}
|
||||
|
||||
# Symbols ----------------------------------------------------------------------
|
||||
|
||||
# TODO(brettw) Since this sets ldflags on Windows which is inherited across
|
||||
# static library boundaries, if you want to remove the default symbol config
|
||||
# and set a different one on a target, you also have to do it for all static
|
||||
# libraries that go into that target, which is messed up. Either we need a
|
||||
# more flexible system for defining linker flags, or we need to separate this
|
||||
# out into a "symbols_linker" config that is only applied to DLLs and EXEs.
|
||||
config("symbols") {
|
||||
if (is_win) {
|
||||
cflags = [ "/Zi" ] # Produce PDB file, no edit and continue.
|
||||
ldflags = [ "/DEBUG" ]
|
||||
} else {
|
||||
cflags = [ "-g2" ]
|
||||
}
|
||||
}
|
||||
|
||||
config("minimal_symbols") {
|
||||
if (is_win) {
|
||||
# Linker symbols for backtraces only.
|
||||
ldflags = [ "/DEBUG" ]
|
||||
} else {
|
||||
cflags = [ "-g1" ]
|
||||
}
|
||||
}
|
||||
|
||||
config("no_symbols") {
|
||||
if (!is_win) {
|
||||
cflags = [ "-g0" ]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
# Copyright (c) 2013 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.
|
||||
|
||||
# Sets up the dynamic library search path to include our "lib" directory.
|
||||
config("executable_ldconfig") {
|
||||
ldflags = [
|
||||
# Want to pass "\$". Need to escape both '\' and '$'. GN will re-escape as
|
||||
# required for ninja.
|
||||
"-Wl,-rpath=\\\$ORIGIN/lib/",
|
||||
|
||||
"-Wl,-rpath-link=lib/",
|
||||
]
|
||||
}
|
||||
|
||||
# This script returns a list consisting of two nested lists: the first is the
|
||||
# list of cflags, the second are the linker flags.
|
||||
pkg_script = "pkg-config.py"
|
||||
|
||||
config("fontconfig") {
|
||||
libs = [ "fontconfig" ]
|
||||
}
|
||||
|
||||
config("freetype2") {
|
||||
pkgresult = exec_script(pkg_script, [ "freetype2" ], "value")
|
||||
include_dirs = pkgresult[0]
|
||||
cflags = pkgresult[1]
|
||||
libs = pkgresult[2]
|
||||
lib_dirs = pkgresult[3]
|
||||
}
|
||||
|
||||
config("glib") {
|
||||
pkgresult = exec_script(pkg_script,
|
||||
[ "glib-2.0", "gmodule-2.0", "gobject-2.0", "gthread-2.0" ], "value" )
|
||||
include_dirs = pkgresult[0]
|
||||
cflags = pkgresult[1]
|
||||
libs = pkgresult[2]
|
||||
lib_dirs = pkgresult[3]
|
||||
}
|
||||
|
||||
config("gtk") {
|
||||
# Gtk requires gmodule, but it does not list it as a dependency in some
|
||||
# misconfigured systems.
|
||||
pkgresult = exec_script(pkg_script,
|
||||
[ "gmodule-2.0", "gtk+-2.0", "gthread-2.0" ], "value" )
|
||||
include_dirs = pkgresult[0]
|
||||
cflags = pkgresult[1]
|
||||
libs = pkgresult[2]
|
||||
lib_dirs = pkgresult[3]
|
||||
|
||||
defines = [ "TOOLKIT_GTK" ]
|
||||
}
|
||||
|
||||
config("pangocairo") {
|
||||
pkgresult = exec_script(pkg_script, [ "pangocairo" ], "value" )
|
||||
include_dirs = pkgresult[0]
|
||||
cflags = pkgresult[1]
|
||||
libs = pkgresult[2]
|
||||
lib_dirs = pkgresult[3]
|
||||
}
|
||||
|
||||
config("udev") {
|
||||
pkgresult = exec_script(pkg_script, [ "libudev" ], "value" )
|
||||
include_dirs = pkgresult[0]
|
||||
cflags = pkgresult[1]
|
||||
libs = pkgresult[2]
|
||||
lib_dirs = pkgresult[3]
|
||||
}
|
||||
|
||||
config("x11") {
|
||||
# Don't bother running pkg-config for these X related libraries since it just
|
||||
# returns the same libs, and forking pkg-config is slow.
|
||||
defines = [ "USE_X11" ]
|
||||
libs = [
|
||||
"X11",
|
||||
"Xcomposite",
|
||||
"Xcursor",
|
||||
"Xdamage",
|
||||
"Xext",
|
||||
"Xfixes",
|
||||
"Xi",
|
||||
"Xrender",
|
||||
"Xss",
|
||||
"Xtst",
|
||||
]
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
# Copyright (c) 2013 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.
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
import re
|
||||
from optparse import OptionParser
|
||||
|
||||
# This script runs pkg-config, optionally filtering out some results, and
|
||||
# returns the result.
|
||||
#
|
||||
# The result will be [ <includes>, <cflags>, <libs>, <lib_dirs> ] where each
|
||||
# member is itself a list of strings.
|
||||
#
|
||||
# You can filter out matches using "-v <regexp>" where all results from
|
||||
# pkgconfig matching the given regular expression will be ignored. You can
|
||||
# specify more than one regular expression my specifying "-v" more than once.
|
||||
|
||||
# If this is run on non-Linux platforms, just return nothing and indicate
|
||||
# success. This allows us to "kind of emulate" a Linux build from other
|
||||
# platforms.
|
||||
if sys.platform.find("linux") == -1:
|
||||
print "[[],[],[]]"
|
||||
sys.exit(0)
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('-v', action='append', dest='strip_out', type='string')
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
# Make a list of regular expressions to strip out.
|
||||
strip_out = []
|
||||
if options.strip_out != None:
|
||||
for regexp in options.strip_out:
|
||||
strip_out.append(re.compile(regexp))
|
||||
|
||||
try:
|
||||
flag_string = subprocess.check_output(["pkg-config", "--cflags", "--libs"] +
|
||||
args)
|
||||
# For now just split on spaces to get the args out. This will break if
|
||||
# pkgconfig returns quoted things with spaces in them, but that doesn't seem
|
||||
# to happen in practice.
|
||||
all_flags = flag_string.strip().split(' ')
|
||||
except:
|
||||
print "Could not run pkg-config."
|
||||
sys.exit(1)
|
||||
|
||||
includes = []
|
||||
cflags = []
|
||||
libs = []
|
||||
lib_dirs = []
|
||||
|
||||
def MatchesAnyRegexp(flag, list_of_regexps):
|
||||
for regexp in list_of_regexps:
|
||||
if regexp.search(flag) != None:
|
||||
return True
|
||||
return False
|
||||
|
||||
for flag in all_flags[:]:
|
||||
if len(flag) == 0 or MatchesAnyRegexp(flag, strip_out):
|
||||
continue;
|
||||
|
||||
if flag[:2] == '-l':
|
||||
libs.append(flag[2:])
|
||||
if flag[:2] == '-L':
|
||||
lib_dirs.append(flag[2:])
|
||||
elif flag[:2] == '-I':
|
||||
includes.append(flag[2:])
|
||||
else:
|
||||
cflags.append(flag)
|
||||
|
||||
# Output a GN array, the first one is the cflags, the second are the libs. The
|
||||
# JSON formatter prints GN compatible lists when everything is a list of
|
||||
# strings.
|
||||
print json.dumps([includes, cflags, libs, lib_dirs])
|
|
@ -0,0 +1,10 @@
|
|||
# Copyright (c) 2013 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.
|
||||
|
||||
# On Mac, this is used for everything except static libraries.
|
||||
config("mac_dynamic_flags") {
|
||||
ldflags = [
|
||||
"-Wl,-search_paths_first",
|
||||
]
|
||||
}
|
|
@ -0,0 +1,148 @@
|
|||
# Copyright (c) 2013 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() {
|
||||
# Full path to the Windows SDK, not including a backslash at the end.
|
||||
windows_sdk_path = "C:\Program Files (x86)\Windows Kits\8.0"
|
||||
|
||||
# Full path to the Visual Studio installation, not including a backslash
|
||||
# at the end.
|
||||
visual_studio_path = "C:\Program Files (x86)\Microsoft Visual Studio 10.0"
|
||||
}
|
||||
|
||||
# Compiler setup for the Windows SDK. Applied to all targets.
|
||||
config("sdk") {
|
||||
# The include path is the stuff returned by the script.
|
||||
#include_dirs = msvc_config[0] TODO(brettw) make this work.
|
||||
|
||||
defines = [
|
||||
"_ATL_NO_OPENGL",
|
||||
"_SECURE_ATL",
|
||||
"_WIN32_WINNT=0x0602",
|
||||
"_WINDOWS",
|
||||
"CERT_CHAIN_PARA_HAS_EXTRA_FIELDS",
|
||||
"NOMINMAX",
|
||||
"NTDDI_VERSION=0x06020000",
|
||||
"PSAPI_VERSION=1",
|
||||
"WIN32",
|
||||
"WIN32_LEAN_AND_MEAN",
|
||||
"WINVER=0x0602",
|
||||
]
|
||||
|
||||
# The Windows SDK include directories must be first. They both have a sal.h,
|
||||
# and the SDK one is newer and the SDK uses some newer features from it not
|
||||
# present in the Visual Studio one.
|
||||
include_dirs = [
|
||||
"$windows_sdk_path\Include\shared",
|
||||
"$windows_sdk_path\Include\um",
|
||||
"$windows_sdk_path\Include\winrt",
|
||||
"$visual_studio_path\VC\include",
|
||||
"$visual_studio_path\VC\atlmfc\include",
|
||||
]
|
||||
}
|
||||
|
||||
# Linker flags for Windows SDK setup, this is applied only to EXEs and DLLs.
|
||||
config("sdk_link") {
|
||||
# TODO(brettw) 64-bit.
|
||||
is_64bit = false
|
||||
|
||||
if (is_64bit) {
|
||||
ldflags = [ "/MACHINE:X64" ]
|
||||
lib_dirs = [
|
||||
"$windows_sdk_path\Lib\win8\um\x64",
|
||||
"$visual_studio_path\VC\lib\amd64",
|
||||
"$visual_studio_path\VC\atlmfc\lib\amd64",
|
||||
]
|
||||
} else {
|
||||
ldflags = [
|
||||
"/MACHINE:X86",
|
||||
"/SAFESEH", # Not compatible with x64 so use only for x86.
|
||||
]
|
||||
lib_dirs = [
|
||||
"$windows_sdk_path\Lib\win8\um\x86",
|
||||
"$visual_studio_path\VC\lib",
|
||||
"$visual_studio_path\VC\atlmfc\lib",
|
||||
]
|
||||
#if (!is_asan) { TODO(brettw) Address Sanitizer
|
||||
# ldflags += "/largeaddressaware"
|
||||
#}
|
||||
}
|
||||
}
|
||||
|
||||
# This default linker setup is provided separately from the SDK setup so
|
||||
# targets who want different libraries linked can remove this and specify their
|
||||
# own.
|
||||
config("common_linker_setup") {
|
||||
ldflags = [
|
||||
"/FIXED:NO",
|
||||
"/ignore:4199",
|
||||
"/ignore:4221",
|
||||
"/NXCOMPAT",
|
||||
]
|
||||
|
||||
# ASLR makes debugging with windbg difficult because Chrome.exe and
|
||||
# Chrome.dll share the same base name. As result, windbg will name the
|
||||
# Chrome.dll module like chrome_<base address>, where <base address>
|
||||
# typically changes with each launch. This in turn means that breakpoints in
|
||||
# Chrome.dll don't stick from one launch to the next. For this reason, we
|
||||
# turn ASLR off in debug builds.
|
||||
if (is_debug) {
|
||||
ldflags += "/DYNAMICBASE:NO"
|
||||
} else {
|
||||
ldflags += "/DYNAMICBASE"
|
||||
}
|
||||
|
||||
# Common libraries.
|
||||
libs = [
|
||||
"advapi32.lib",
|
||||
"comdlg32.lib",
|
||||
"dbghelp.lib",
|
||||
"delayimp.lib",
|
||||
"dnsapi.lib",
|
||||
"gdi32.lib",
|
||||
"kernel32.lib",
|
||||
"msimg32.lib",
|
||||
"odbc32.lib",
|
||||
"odbccp32.lib",
|
||||
"ole32.lib",
|
||||
"oleaut32.lib",
|
||||
"psapi.lib",
|
||||
"shell32.lib",
|
||||
"shlwapi.lib",
|
||||
"user32.lib",
|
||||
"usp10.lib",
|
||||
"uuid.lib",
|
||||
"version.lib",
|
||||
"wininet.lib",
|
||||
"winmm.lib",
|
||||
"winspool.lib",
|
||||
"ws2_32.lib",
|
||||
]
|
||||
|
||||
# Delay loaded DLLs.
|
||||
ldflags += [
|
||||
"/DELAYLOAD:dbghelp.dll",
|
||||
"/DELAYLOAD:dwmapi.dll",
|
||||
"/DELAYLOAD:shell32.dll",
|
||||
"/DELAYLOAD:uxtheme.dll",
|
||||
]
|
||||
}
|
||||
|
||||
# Subsystem --------------------------------------------------------------------
|
||||
|
||||
config("console") {
|
||||
ldflags = [ "/SUBSYSTEM:CONSOLE" ]
|
||||
}
|
||||
config("windowed") {
|
||||
ldflags = [ "/SUBSYSTEM:WINDOWS" ]
|
||||
}
|
||||
|
||||
# Incremental linking ----------------------------------------------------------
|
||||
|
||||
config("incremental_linking") {
|
||||
ldflags = [ "/INCREMENTAL" ]
|
||||
}
|
||||
config("no_incremental_linking") {
|
||||
ldflags = [ "/INCREMENTAL:NO" ]
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
# Copyright (c) 2013 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 returns the MSVC config used by the Windows build.
|
||||
# It's a bit hardcoded right now. I suspect we want to build this functionality
|
||||
# into GN itself in the future.
|
||||
|
||||
import sys
|
||||
|
||||
# This script expects one parameter: the path to the root output directory.
|
||||
|
||||
# TODO(brettw): do escaping.
|
||||
def FormatStringForGN(x):
|
||||
return '"' + x + '"'
|
||||
|
||||
def PrintListOfStrings(x):
|
||||
print '['
|
||||
for i in x:
|
||||
print FormatStringForGN(i) + ', '
|
||||
print ']'
|
||||
|
||||
# GN wants system-absolutepaths to begin in slashes.
|
||||
sdk_root = '/C:\\Program Files (x86)\\Windows Kits\\8.0\\'
|
||||
vs_root = '/C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\'
|
||||
|
||||
def GetIncludes():
|
||||
return [
|
||||
sdk_root + 'Include\\shared',
|
||||
sdk_root + 'Include\\um',
|
||||
sdk_root + 'Include\\winrt',
|
||||
vs_root + 'VC\\atlmfc\\include'
|
||||
]
|
||||
|
||||
def _FormatAsEnvironmentBlock(envvar_dict):
|
||||
"""Format as an 'environment block' directly suitable for CreateProcess.
|
||||
Briefly this is a list of key=value\0, terminated by an additional \0. See
|
||||
CreateProcess documentation for more details."""
|
||||
block = ''
|
||||
nul = '\0'
|
||||
for key, value in envvar_dict.iteritems():
|
||||
block += key + '=' + value + nul
|
||||
block += nul
|
||||
return block
|
||||
|
||||
def WriteEnvFile(file_path, values):
|
||||
f = open(file_path, "w")
|
||||
f.write(_FormatAsEnvironmentBlock(values))
|
||||
|
||||
includes = GetIncludes()
|
||||
|
||||
# Write the environment files.
|
||||
WriteEnvFile(sys.argv[1] + '\\environment.x86',
|
||||
{ 'TMP': 'C:\\Users\\brettw\\AppData\\Local\\Temp',
|
||||
'SYSTEMROOT': 'C:\\Windows',
|
||||
'TEMP': 'C:\\Users\\brettw\\AppData\\Local\\Temp',
|
||||
'LIB': 'c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\LIB;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\LIB;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\lib;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\LIB;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\LIB;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\lib;',
|
||||
'LIBPATH': 'C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework\\v3.5;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\LIB;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\LIB;C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework\\v3.5;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\LIB;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\LIB;',
|
||||
'PATH': 'C:\\apps\\depot_tools\\python_bin;c:\\Program Files (x86)\\Microsoft F#\\v4.0\\;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VSTSDB\\Deploy;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\BIN;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\Tools;C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework\\v3.5;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\VCPackages;C:\\Program Files (x86)\\HTML Help Workshop;C:\\Program Files (x86)\\HTML Help Workshop;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\bin\\NETFX 4.0 Tools;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\bin;C:\\apps\\depot_tools\\python_bin;C:\\apps\\depot_tools\\;C:\\apps\\depot_tools\\;C:\\apps\\depot_tools\\;c:\\Program Files (x86)\\Microsoft F#\\v4.0\\;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VSTSDB\\Deploy;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\BIN;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\Tools;C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework\\v3.5;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\VCPackages;C:\\Program Files (x86)\\HTML Help Workshop;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\bin\\NETFX 4.0 Tools;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\bin;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\windows\\corpam;C:\\python_26_amd64\\files;C:\\Windows\\ccmsetup;c:\\Program Files (x86)\\Microsoft SQL Server\\100\\Tools\\Binn\\;c:\\Program Files\\Microsoft SQL Server\\100\\Tools\\Binn\\;c:\\Program Files\\Microsoft SQL Server\\100\\DTS\\Binn\\;c:\\cygwin\\bin;C:\\apps\\;C:\\apps\\depot_tools;C:\\Program Files (x86)\\Windows Kits\\8.0\\Windows Performance Toolkit\\;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\Google\\Cert Installer;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\Google\\google_appengine\\',
|
||||
'PATHEXT': '=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC',
|
||||
'INCLUDE': 'c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\INCLUDE;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\INCLUDE;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\include;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\INCLUDE;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\INCLUDE;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\include;'})
|
||||
|
||||
WriteEnvFile(sys.argv[1] + '\\environment.x64',
|
||||
{ 'TMP': 'C:\\Users\\brettw\\AppData\\Local\\Temp',
|
||||
'SYSTEMROOT': 'C:\\Windows',
|
||||
'TEMP': 'C:\\Users\\brettw\\AppData\\Local\\Temp',
|
||||
'LIB': 'c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\LIB\\amd64;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\LIB\\amd64;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\lib\\x64;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\LIB;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\LIB;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\lib;',
|
||||
'LIBPATH': 'C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework64\\v3.5;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\LIB\\amd64;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\LIB\\amd64;C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework\\v3.5;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\LIB;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\LIB;',
|
||||
'PATH': 'C:\\apps\\depot_tools\\python_bin;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\BIN\\amd64;C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework64\\v3.5;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\VCPackages;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\Tools;C:\\Program Files (x86)\\HTML Help Workshop;C:\\Program Files (x86)\\HTML Help Workshop;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\bin\\NETFX 4.0 Tools\\x64;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\bin\\x64;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\bin;C:\\apps\\depot_tools\\python_bin;C:\\apps\\depot_tools\\;C:\\apps\\depot_tools\\;C:\\apps\\depot_tools\\;c:\\Program Files (x86)\\Microsoft F#\\v4.0\\;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VSTSDB\\Deploy;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\BIN;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\Tools;C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework\\v3.5;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\VCPackages;C:\\Program Files (x86)\\HTML Help Workshop;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\bin\\NETFX 4.0 Tools;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\bin;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\windows\\corpam;C:\\python_26_amd64\\files;C:\\Windows\\ccmsetup;c:\\Program Files (x86)\\Microsoft SQL Server\\100\\Tools\\Binn\\;c:\\Program Files\\Microsoft SQL Server\\100\\Tools\\Binn\\;c:\\Program Files\\Microsoft SQL Server\\100\\DTS\\Binn\\;c:\\cygwin\\bin;C:\\apps\\;C:\\apps\\depot_tools;C:\\Program Files (x86)\\Windows Kits\\8.0\\Windows Performance Toolkit\\;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\Google\\Cert Installer;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\Google\\google_appengine\\',
|
||||
'PATHEXT': '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC',
|
||||
'INCLUDE': 'c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\INCLUDE;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\INCLUDE;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\include;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\INCLUDE;c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\INCLUDE;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\include;'})
|
||||
|
||||
# Return the includes and such.
|
||||
print '['
|
||||
PrintListOfStrings(includes)
|
||||
print ']'
|
||||
|
|
@ -0,0 +1,575 @@
|
|||
# Copyright (c) 2013 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 copies the logic from GYP to find the MSVC configuration. It's not
|
||||
# currently used because it is too slow. We will probably build this
|
||||
# functionality into the C++ code in the future.
|
||||
|
||||
"""Handle version information related to Visual Stuio."""
|
||||
|
||||
import errno
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
class VisualStudioVersion(object):
|
||||
"""Information regarding a version of Visual Studio."""
|
||||
|
||||
def __init__(self, short_name, description,
|
||||
solution_version, project_version, flat_sln, uses_vcxproj,
|
||||
path, sdk_based, default_toolset=None):
|
||||
self.short_name = short_name
|
||||
self.description = description
|
||||
self.solution_version = solution_version
|
||||
self.project_version = project_version
|
||||
self.flat_sln = flat_sln
|
||||
self.uses_vcxproj = uses_vcxproj
|
||||
self.path = path
|
||||
self.sdk_based = sdk_based
|
||||
self.default_toolset = default_toolset
|
||||
|
||||
def ShortName(self):
|
||||
return self.short_name
|
||||
|
||||
def Description(self):
|
||||
"""Get the full description of the version."""
|
||||
return self.description
|
||||
|
||||
def SolutionVersion(self):
|
||||
"""Get the version number of the sln files."""
|
||||
return self.solution_version
|
||||
|
||||
def ProjectVersion(self):
|
||||
"""Get the version number of the vcproj or vcxproj files."""
|
||||
return self.project_version
|
||||
|
||||
def FlatSolution(self):
|
||||
return self.flat_sln
|
||||
|
||||
def UsesVcxproj(self):
|
||||
"""Returns true if this version uses a vcxproj file."""
|
||||
return self.uses_vcxproj
|
||||
|
||||
def ProjectExtension(self):
|
||||
"""Returns the file extension for the project."""
|
||||
return self.uses_vcxproj and '.vcxproj' or '.vcproj'
|
||||
|
||||
def Path(self):
|
||||
"""Returns the path to Visual Studio installation."""
|
||||
return self.path
|
||||
|
||||
def ToolPath(self, tool):
|
||||
"""Returns the path to a given compiler tool. """
|
||||
return os.path.normpath(os.path.join(self.path, "VC/bin", tool))
|
||||
|
||||
def DefaultToolset(self):
|
||||
"""Returns the msbuild toolset version that will be used in the absence
|
||||
of a user override."""
|
||||
return self.default_toolset
|
||||
|
||||
def SetupScript(self, target_arch):
|
||||
"""Returns a command (with arguments) to be used to set up the
|
||||
environment."""
|
||||
# Check if we are running in the SDK command line environment and use
|
||||
# the setup script from the SDK if so. |target_arch| should be either
|
||||
# 'x86' or 'x64'.
|
||||
assert target_arch in ('x86', 'x64')
|
||||
sdk_dir = os.environ.get('WindowsSDKDir')
|
||||
if self.sdk_based and sdk_dir:
|
||||
return [os.path.normpath(os.path.join(sdk_dir, 'Bin/SetEnv.Cmd')),
|
||||
'/' + target_arch]
|
||||
else:
|
||||
# We don't use VC/vcvarsall.bat for x86 because vcvarsall calls
|
||||
# vcvars32, which it can only find if VS??COMNTOOLS is set, which it
|
||||
# isn't always.
|
||||
if target_arch == 'x86':
|
||||
return [os.path.normpath(
|
||||
os.path.join(self.path, 'Common7/Tools/vsvars32.bat'))]
|
||||
else:
|
||||
assert target_arch == 'x64'
|
||||
arg = 'x86_amd64'
|
||||
if (os.environ.get('PROCESSOR_ARCHITECTURE') == 'AMD64' or
|
||||
os.environ.get('PROCESSOR_ARCHITEW6432') == 'AMD64'):
|
||||
# Use the 64-on-64 compiler if we can.
|
||||
arg = 'amd64'
|
||||
return [os.path.normpath(
|
||||
os.path.join(self.path, 'VC/vcvarsall.bat')), arg]
|
||||
|
||||
|
||||
def _RegistryQueryBase(sysdir, key, value):
|
||||
"""Use reg.exe to read a particular key.
|
||||
|
||||
While ideally we might use the win32 module, we would like gyp to be
|
||||
python neutral, so for instance cygwin python lacks this module.
|
||||
|
||||
Arguments:
|
||||
sysdir: The system subdirectory to attempt to launch reg.exe from.
|
||||
key: The registry key to read from.
|
||||
value: The particular value to read.
|
||||
Return:
|
||||
stdout from reg.exe, or None for failure.
|
||||
"""
|
||||
# Skip if not on Windows or Python Win32 setup issue
|
||||
if sys.platform not in ('win32', 'cygwin'):
|
||||
return None
|
||||
# Setup params to pass to and attempt to launch reg.exe
|
||||
cmd = [os.path.join(os.environ.get('WINDIR', ''), sysdir, 'reg.exe'),
|
||||
'query', key]
|
||||
if value:
|
||||
cmd.extend(['/v', value])
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
# Obtain the stdout from reg.exe, reading to the end so p.returncode is valid
|
||||
# Note that the error text may be in [1] in some cases
|
||||
text = p.communicate()[0]
|
||||
# Check return code from reg.exe; officially 0==success and 1==error
|
||||
if p.returncode:
|
||||
return None
|
||||
return text
|
||||
|
||||
|
||||
def _RegistryQuery(key, value=None):
|
||||
"""Use reg.exe to read a particular key through _RegistryQueryBase.
|
||||
|
||||
First tries to launch from %WinDir%\Sysnative to avoid WoW64 redirection. If
|
||||
that fails, it falls back to System32. Sysnative is available on Vista and
|
||||
up and available on Windows Server 2003 and XP through KB patch 942589. Note
|
||||
that Sysnative will always fail if using 64-bit python due to it being a
|
||||
virtual directory and System32 will work correctly in the first place.
|
||||
|
||||
KB 942589 - http://support.microsoft.com/kb/942589/en-us.
|
||||
|
||||
Arguments:
|
||||
key: The registry key.
|
||||
value: The particular registry value to read (optional).
|
||||
Return:
|
||||
stdout from reg.exe, or None for failure.
|
||||
"""
|
||||
text = None
|
||||
try:
|
||||
text = _RegistryQueryBase('Sysnative', key, value)
|
||||
except OSError, e:
|
||||
if e.errno == errno.ENOENT:
|
||||
text = _RegistryQueryBase('System32', key, value)
|
||||
else:
|
||||
raise
|
||||
return text
|
||||
|
||||
|
||||
def _RegistryGetValue(key, value):
|
||||
"""Use reg.exe to obtain the value of a registry key.
|
||||
|
||||
Args:
|
||||
key: The registry key.
|
||||
value: The particular registry value to read.
|
||||
Return:
|
||||
contents of the registry key's value, or None on failure.
|
||||
"""
|
||||
text = _RegistryQuery(key, value)
|
||||
if not text:
|
||||
return None
|
||||
# Extract value.
|
||||
match = re.search(r'REG_\w+\s+([^\r]+)\r\n', text)
|
||||
if not match:
|
||||
return None
|
||||
return match.group(1)
|
||||
|
||||
|
||||
def _RegistryKeyExists(key):
|
||||
"""Use reg.exe to see if a key exists.
|
||||
|
||||
Args:
|
||||
key: The registry key to check.
|
||||
Return:
|
||||
True if the key exists
|
||||
"""
|
||||
if not _RegistryQuery(key):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def _CreateVersion(name, path, sdk_based=False):
|
||||
"""Sets up MSVS project generation.
|
||||
|
||||
Setup is based off the GYP_MSVS_VERSION environment variable or whatever is
|
||||
autodetected if GYP_MSVS_VERSION is not explicitly specified. If a version is
|
||||
passed in that doesn't match a value in versions python will throw a error.
|
||||
"""
|
||||
if path:
|
||||
path = os.path.normpath(path)
|
||||
versions = {
|
||||
'2013': VisualStudioVersion('2013',
|
||||
'Visual Studio 2013',
|
||||
solution_version='13.00',
|
||||
project_version='4.0',
|
||||
flat_sln=False,
|
||||
uses_vcxproj=True,
|
||||
path=path,
|
||||
sdk_based=sdk_based,
|
||||
default_toolset='v110'),
|
||||
'2013e': VisualStudioVersion('2013e',
|
||||
'Visual Studio 2013',
|
||||
solution_version='13.00',
|
||||
project_version='4.0',
|
||||
flat_sln=True,
|
||||
uses_vcxproj=True,
|
||||
path=path,
|
||||
sdk_based=sdk_based,
|
||||
default_toolset='v110'),
|
||||
'2012': VisualStudioVersion('2012',
|
||||
'Visual Studio 2012',
|
||||
solution_version='12.00',
|
||||
project_version='4.0',
|
||||
flat_sln=False,
|
||||
uses_vcxproj=True,
|
||||
path=path,
|
||||
sdk_based=sdk_based,
|
||||
default_toolset='v110'),
|
||||
'2012e': VisualStudioVersion('2012e',
|
||||
'Visual Studio 2012',
|
||||
solution_version='12.00',
|
||||
project_version='4.0',
|
||||
flat_sln=True,
|
||||
uses_vcxproj=True,
|
||||
path=path,
|
||||
sdk_based=sdk_based,
|
||||
default_toolset='v110'),
|
||||
'2010': VisualStudioVersion('2010',
|
||||
'Visual Studio 2010',
|
||||
solution_version='11.00',
|
||||
project_version='4.0',
|
||||
flat_sln=False,
|
||||
uses_vcxproj=True,
|
||||
path=path,
|
||||
sdk_based=sdk_based),
|
||||
'2010e': VisualStudioVersion('2010e',
|
||||
'Visual Studio 2010',
|
||||
solution_version='11.00',
|
||||
project_version='4.0',
|
||||
flat_sln=True,
|
||||
uses_vcxproj=True,
|
||||
path=path,
|
||||
sdk_based=sdk_based),
|
||||
'2008': VisualStudioVersion('2008',
|
||||
'Visual Studio 2008',
|
||||
solution_version='10.00',
|
||||
project_version='9.00',
|
||||
flat_sln=False,
|
||||
uses_vcxproj=False,
|
||||
path=path,
|
||||
sdk_based=sdk_based),
|
||||
'2008e': VisualStudioVersion('2008e',
|
||||
'Visual Studio 2008',
|
||||
solution_version='10.00',
|
||||
project_version='9.00',
|
||||
flat_sln=True,
|
||||
uses_vcxproj=False,
|
||||
path=path,
|
||||
sdk_based=sdk_based),
|
||||
'2005': VisualStudioVersion('2005',
|
||||
'Visual Studio 2005',
|
||||
solution_version='9.00',
|
||||
project_version='8.00',
|
||||
flat_sln=False,
|
||||
uses_vcxproj=False,
|
||||
path=path,
|
||||
sdk_based=sdk_based),
|
||||
'2005e': VisualStudioVersion('2005e',
|
||||
'Visual Studio 2005',
|
||||
solution_version='9.00',
|
||||
project_version='8.00',
|
||||
flat_sln=True,
|
||||
uses_vcxproj=False,
|
||||
path=path,
|
||||
sdk_based=sdk_based),
|
||||
}
|
||||
return versions[str(name)]
|
||||
|
||||
|
||||
def _ConvertToCygpath(path):
|
||||
"""Convert to cygwin path if we are using cygwin."""
|
||||
if sys.platform == 'cygwin':
|
||||
p = subprocess.Popen(['cygpath', path], stdout=subprocess.PIPE)
|
||||
path = p.communicate()[0].strip()
|
||||
return path
|
||||
|
||||
|
||||
def _DetectVisualStudioVersions(versions_to_check, force_express):
|
||||
"""Collect the list of installed visual studio versions.
|
||||
|
||||
Returns:
|
||||
A list of visual studio versions installed in descending order of
|
||||
usage preference.
|
||||
Base this on the registry and a quick check if devenv.exe exists.
|
||||
Only versions 8-10 are considered.
|
||||
Possibilities are:
|
||||
2005(e) - Visual Studio 2005 (8)
|
||||
2008(e) - Visual Studio 2008 (9)
|
||||
2010(e) - Visual Studio 2010 (10)
|
||||
2012(e) - Visual Studio 2012 (11)
|
||||
2013(e) - Visual Studio 2013 (11)
|
||||
Where (e) is e for express editions of MSVS and blank otherwise.
|
||||
"""
|
||||
version_to_year = {
|
||||
'8.0': '2005',
|
||||
'9.0': '2008',
|
||||
'10.0': '2010',
|
||||
'11.0': '2012',
|
||||
'12.0': '2013',
|
||||
}
|
||||
versions = []
|
||||
for version in versions_to_check:
|
||||
# Old method of searching for which VS version is installed
|
||||
# We don't use the 2010-encouraged-way because we also want to get the
|
||||
# path to the binaries, which it doesn't offer.
|
||||
keys = [r'HKLM\Software\Microsoft\VisualStudio\%s' % version,
|
||||
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\%s' % version,
|
||||
r'HKLM\Software\Microsoft\VCExpress\%s' % version,
|
||||
r'HKLM\Software\Wow6432Node\Microsoft\VCExpress\%s' % version]
|
||||
for index in range(len(keys)):
|
||||
path = _RegistryGetValue(keys[index], 'InstallDir')
|
||||
if not path:
|
||||
continue
|
||||
path = _ConvertToCygpath(path)
|
||||
# Check for full.
|
||||
full_path = os.path.join(path, 'devenv.exe')
|
||||
express_path = os.path.join(path, 'vcexpress.exe')
|
||||
if not force_express and os.path.exists(full_path):
|
||||
# Add this one.
|
||||
versions.append(_CreateVersion(version_to_year[version],
|
||||
os.path.join(path, '..', '..')))
|
||||
# Check for express.
|
||||
elif os.path.exists(express_path):
|
||||
# Add this one.
|
||||
versions.append(_CreateVersion(version_to_year[version] + 'e',
|
||||
os.path.join(path, '..', '..')))
|
||||
|
||||
# The old method above does not work when only SDK is installed.
|
||||
keys = [r'HKLM\Software\Microsoft\VisualStudio\SxS\VC7',
|
||||
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7']
|
||||
for index in range(len(keys)):
|
||||
path = _RegistryGetValue(keys[index], version)
|
||||
if not path:
|
||||
continue
|
||||
path = _ConvertToCygpath(path)
|
||||
versions.append(_CreateVersion(version_to_year[version] + 'e',
|
||||
os.path.join(path, '..'), sdk_based=True))
|
||||
|
||||
return versions
|
||||
|
||||
|
||||
def SelectVisualStudioVersion(version='auto'):
|
||||
"""Select which version of Visual Studio projects to generate.
|
||||
|
||||
Arguments:
|
||||
version: Hook to allow caller to force a particular version (vs auto).
|
||||
Returns:
|
||||
An object representing a visual studio project format version.
|
||||
"""
|
||||
# In auto mode, check environment variable for override.
|
||||
if version == 'auto':
|
||||
version = os.environ.get('GYP_MSVS_VERSION', 'auto')
|
||||
version_map = {
|
||||
'auto': ('10.0', '9.0', '8.0', '11.0'),
|
||||
'2005': ('8.0',),
|
||||
'2005e': ('8.0',),
|
||||
'2008': ('9.0',),
|
||||
'2008e': ('9.0',),
|
||||
'2010': ('10.0',),
|
||||
'2010e': ('10.0',),
|
||||
'2012': ('11.0',),
|
||||
'2012e': ('11.0',),
|
||||
'2013': ('12.0',),
|
||||
'2013e': ('12.0',),
|
||||
}
|
||||
override_path = os.environ.get('GYP_MSVS_OVERRIDE_PATH')
|
||||
if override_path:
|
||||
msvs_version = os.environ.get('GYP_MSVS_VERSION')
|
||||
if not msvs_version or 'e' not in msvs_version:
|
||||
raise ValueError('GYP_MSVS_OVERRIDE_PATH requires GYP_MSVS_VERSION to be '
|
||||
'set to an "e" version (e.g. 2010e)')
|
||||
return _CreateVersion(msvs_version, override_path, sdk_based=True)
|
||||
version = str(version)
|
||||
versions = _DetectVisualStudioVersions(version_map[version], 'e' in version)
|
||||
if not versions:
|
||||
if version == 'auto':
|
||||
# Default to 2005 if we couldn't find anything
|
||||
return _CreateVersion('2005', None)
|
||||
else:
|
||||
return _CreateVersion(version, None)
|
||||
return versions[0]
|
||||
|
||||
def GenerateEnvironmentFiles(toplevel_build_dir, generator_flags, open_out):
|
||||
"""It's not sufficient to have the absolute path to the compiler, linker,
|
||||
etc. on Windows, as those tools rely on .dlls being in the PATH. We also
|
||||
need to support both x86 and x64 compilers within the same build (to support
|
||||
msvs_target_platform hackery). Different architectures require a different
|
||||
compiler binary, and different supporting environment variables (INCLUDE,
|
||||
LIB, LIBPATH). So, we extract the environment here, wrap all invocations
|
||||
of compiler tools (cl, link, lib, rc, midl, etc.) via win_tool.py which
|
||||
sets up the environment, and then we do not prefix the compiler with
|
||||
an absolute path, instead preferring something like "cl.exe" in the rule
|
||||
which will then run whichever the environment setup has put in the path.
|
||||
When the following procedure to generate environment files does not
|
||||
meet your requirement (e.g. for custom toolchains), you can pass
|
||||
"-G ninja_use_custom_environment_files" to the gyp to suppress file
|
||||
generation and use custom environment files prepared by yourself."""
|
||||
archs = ('x86', 'x64')
|
||||
if generator_flags.get('ninja_use_custom_environment_files', 0):
|
||||
cl_paths = {}
|
||||
for arch in archs:
|
||||
cl_paths[arch] = 'cl.exe'
|
||||
return cl_paths
|
||||
vs = GetVSVersion(generator_flags)
|
||||
cl_paths = {}
|
||||
for arch in archs:
|
||||
# Extract environment variables for subprocesses.
|
||||
args = vs.SetupScript(arch)
|
||||
args.extend(('&&', 'set'))
|
||||
popen = subprocess.Popen(
|
||||
args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
variables, _ = popen.communicate()
|
||||
env = _ExtractImportantEnvironment(variables)
|
||||
env_block = _FormatAsEnvironmentBlock(env)
|
||||
f = open_out(os.path.join(toplevel_build_dir, 'environment.' + arch), 'wb')
|
||||
f.write(env_block)
|
||||
f.close()
|
||||
|
||||
# Find cl.exe location for this architecture.
|
||||
args = vs.SetupScript(arch)
|
||||
args.extend(('&&',
|
||||
'for', '%i', 'in', '(cl.exe)', 'do', '@echo', 'LOC:%~$PATH:i'))
|
||||
popen = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE)
|
||||
output, _ = popen.communicate()
|
||||
cl_paths[arch] = _ExtractCLPath(output)
|
||||
return cl_paths
|
||||
|
||||
def OpenOutput(path, mode='w'):
|
||||
"""Open |path| for writing, creating directories if necessary."""
|
||||
try:
|
||||
os.makedirs(os.path.dirname(path))
|
||||
except OSError:
|
||||
pass
|
||||
return open(path, mode)
|
||||
|
||||
vs_version = None
|
||||
def GetVSVersion(generator_flags):
|
||||
global vs_version
|
||||
if not vs_version:
|
||||
vs_version = SelectVisualStudioVersion(
|
||||
generator_flags.get('msvs_version', 'auto'))
|
||||
return vs_version
|
||||
|
||||
def _ExtractImportantEnvironment(output_of_set):
|
||||
"""Extracts environment variables required for the toolchain to run from
|
||||
a textual dump output by the cmd.exe 'set' command."""
|
||||
envvars_to_save = (
|
||||
'goma_.*', # TODO(scottmg): This is ugly, but needed for goma.
|
||||
'include',
|
||||
'lib',
|
||||
'libpath',
|
||||
'path',
|
||||
'pathext',
|
||||
'systemroot',
|
||||
'temp',
|
||||
'tmp',
|
||||
)
|
||||
env = {}
|
||||
for line in output_of_set.splitlines():
|
||||
for envvar in envvars_to_save:
|
||||
if re.match(envvar + '=', line.lower()):
|
||||
var, setting = line.split('=', 1)
|
||||
if envvar == 'path':
|
||||
# Our own rules (for running gyp-win-tool) and other actions in
|
||||
# Chromium rely on python being in the path. Add the path to this
|
||||
# python here so that if it's not in the path when ninja is run
|
||||
# later, python will still be found.
|
||||
setting = os.path.dirname(sys.executable) + os.pathsep + setting
|
||||
env[var.upper()] = setting
|
||||
break
|
||||
for required in ('SYSTEMROOT', 'TEMP', 'TMP'):
|
||||
if required not in env:
|
||||
raise Exception('Environment variable "%s" '
|
||||
'required to be set to valid path' % required)
|
||||
return env
|
||||
|
||||
def _FormatAsEnvironmentBlock(envvar_dict):
|
||||
"""Format as an 'environment block' directly suitable for CreateProcess.
|
||||
Briefly this is a list of key=value\0, terminated by an additional \0. See
|
||||
CreateProcess documentation for more details."""
|
||||
block = ''
|
||||
nul = '\0'
|
||||
for key, value in envvar_dict.iteritems():
|
||||
block += key + '=' + value + nul
|
||||
block += nul
|
||||
return block
|
||||
|
||||
|
||||
def GenerateEnvironmentFiles(toplevel_build_dir, generator_flags):
|
||||
"""It's not sufficient to have the absolute path to the compiler, linker,
|
||||
etc. on Windows, as those tools rely on .dlls being in the PATH. We also
|
||||
need to support both x86 and x64 compilers within the same build (to support
|
||||
msvs_target_platform hackery). Different architectures require a different
|
||||
compiler binary, and different supporting environment variables (INCLUDE,
|
||||
LIB, LIBPATH). So, we extract the environment here, wrap all invocations
|
||||
of compiler tools (cl, link, lib, rc, midl, etc.) via win_tool.py which
|
||||
sets up the environment, and then we do not prefix the compiler with
|
||||
an absolute path, instead preferring something like "cl.exe" in the rule
|
||||
which will then run whichever the environment setup has put in the path.
|
||||
When the following procedure to generate environment files does not
|
||||
meet your requirement (e.g. for custom toolchains), you can pass
|
||||
"-G ninja_use_custom_environment_files" to the gyp to suppress file
|
||||
generation and use custom environment files prepared by yourself."""
|
||||
archs = ('x86', 'x64')
|
||||
if generator_flags.get('ninja_use_custom_environment_files', 0):
|
||||
cl_paths = {}
|
||||
for arch in archs:
|
||||
cl_paths[arch] = 'cl.exe'
|
||||
return cl_paths
|
||||
vs = GetVSVersion(generator_flags)
|
||||
cl_paths = {}
|
||||
for arch in archs:
|
||||
# Extract environment variables for subprocesses.
|
||||
args = vs.SetupScript(arch)
|
||||
args.extend(('&&', 'set'))
|
||||
popen = subprocess.Popen(
|
||||
args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
variables, _ = popen.communicate()
|
||||
env = _ExtractImportantEnvironment(variables)
|
||||
env_block = _FormatAsEnvironmentBlock(env)
|
||||
f = OpenOutput(os.path.join(toplevel_build_dir, 'environment.' + arch), 'wb')
|
||||
f.write(env_block)
|
||||
f.close()
|
||||
|
||||
# Find cl.exe location for this architecture.
|
||||
args = vs.SetupScript(arch)
|
||||
args.extend(('&&',
|
||||
'for', '%i', 'in', '(cl.exe)', 'do', '@echo', 'LOC:%~$PATH:i'))
|
||||
popen = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE)
|
||||
output, _ = popen.communicate()
|
||||
cl_paths[arch] = _ExtractCLPath(output)
|
||||
return cl_paths
|
||||
|
||||
def _ExtractCLPath(output_of_where):
|
||||
"""Gets the path to cl.exe based on the output of calling the environment
|
||||
setup batch file, followed by the equivalent of `where`."""
|
||||
# Take the first line, as that's the first found in the PATH.
|
||||
for line in output_of_where.strip().splitlines():
|
||||
if line.startswith('LOC:'):
|
||||
return line[len('LOC:'):].strip()
|
||||
|
||||
#print SelectVisualStudioVersion().DefaultToolset()
|
||||
#GenerateEnvironmentFiles("D:\\src\\src1\\src\\out\\gn\\eraseme", {})
|
||||
#print '"', GetVSVersion({}).Path(), '"'
|
||||
print '"', GetVSVersion({}).sdk_based, '"'
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
version_info = {
|
||||
'2010': {
|
||||
'includes': [
|
||||
'VC\\atlmfc\\include',
|
||||
],
|
||||
},
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
set noparent
|
||||
brettw@chromium.org
|
|
@ -0,0 +1,122 @@
|
|||
# Copyright (c) 2013 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.
|
||||
|
||||
cc = "gcc"
|
||||
cxx = "g++"
|
||||
ar = "ar"
|
||||
ld = cxx
|
||||
|
||||
# Everything up to the toolchain args is an exact copy of the GCC version
|
||||
# below. Keep in sync! Only the compiler variable definitions have changed.
|
||||
toolchain("host") {
|
||||
# Make these apply to all tools below.
|
||||
lib_prefix = "-l"
|
||||
lib_dir_prefix="-L"
|
||||
|
||||
tool("cc") {
|
||||
# cflags_pch_c
|
||||
command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c -c \$in -o \$out"
|
||||
description = "CC \$out"
|
||||
depfile = "\$out.d"
|
||||
deps = "gcc"
|
||||
}
|
||||
tool("cxx") {
|
||||
# cflags_pch_cc
|
||||
command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc -c \$in -o \$out"
|
||||
description = "CXX \$out"
|
||||
depfile = "\$out.d"
|
||||
deps = "gcc"
|
||||
}
|
||||
tool("alink") {
|
||||
command = "rm -f \$out && $ar rcs \$out \$in"
|
||||
description = "AR \$out"
|
||||
}
|
||||
tool("solink") {
|
||||
command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ]; then $ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.TOC; else $ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.tmp && if ! cmp -s \${lib}.tmp \${lib}.TOC; then mv \${lib}.tmp \${lib}.TOC ; fi; fi"
|
||||
description = "SOLINK \$lib"
|
||||
#pool = "link_pool"
|
||||
restat = "1"
|
||||
}
|
||||
tool("link") {
|
||||
command = "$ld \$ldflags -o \$out -Wl,--start-group \$in \$solibs -Wl,--end-group \$libs"
|
||||
description = "LINK \$out"
|
||||
#pool = "link_pool"
|
||||
}
|
||||
tool("stamp") {
|
||||
command = "\${postbuilds}touch \$out"
|
||||
description = "STAMP \$out"
|
||||
}
|
||||
tool("copy") {
|
||||
command = "ln -f \$in \$out 2>/dev/null || (rm -rf \$out && cp -af \$in \$out)"
|
||||
description = "COPY \$in \$out"
|
||||
}
|
||||
|
||||
# When invoking this toolchain not as the default one, these args will be
|
||||
# passed to the build. They are ignored when this is the default toolchain.
|
||||
toolchain_args() {
|
||||
# Pass the current CPU architecture to the build as the toolchain to use.
|
||||
# If the default toolchain is set to ARM and the local system is x86, this
|
||||
# will make this secondary toolchain refer to the host GCC again.
|
||||
cpu_arch = build_cpu_arch
|
||||
}
|
||||
}
|
||||
|
||||
# ARM Cross-Compile ------------------------------------------------------------
|
||||
|
||||
cc = "arm-linux-gnueabi-gcc"
|
||||
cxx = "arm-linux-gnueabi-g++"
|
||||
ar = "arm-linux-gnueabi-ar"
|
||||
ld = cxx
|
||||
|
||||
# Everything up the the toolchain args is an exact copy of the GCC version
|
||||
# below. Keep in sync! Only the compiler variable definitions have changed.
|
||||
toolchain("arm-cross-compile") {
|
||||
# Make these apply to all tools below.
|
||||
lib_prefix = "-l"
|
||||
lib_dir_prefix="-L"
|
||||
|
||||
tool("cc") {
|
||||
# cflags_pch_c
|
||||
command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c -c \$in -o \$out"
|
||||
description = "CC \$out"
|
||||
depfile = "\$out.d"
|
||||
deps = "gcc"
|
||||
}
|
||||
tool("cxx") {
|
||||
# cflags_pch_cc
|
||||
command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc -c \$in -o \$out"
|
||||
description = "CXX \$out"
|
||||
depfile = "\$out.d"
|
||||
deps = "gcc"
|
||||
}
|
||||
tool("alink") {
|
||||
command = "rm -f \$out && $ar rcs \$out \$in"
|
||||
description = "AR \$out"
|
||||
}
|
||||
tool("solink") {
|
||||
command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ]; then $ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.TOC; else $ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.tmp && if ! cmp -s \${lib}.tmp \${lib}.TOC; then mv \${lib}.tmp \${lib}.TOC ; fi; fi"
|
||||
description = "SOLINK \$lib"
|
||||
#pool = "link_pool"
|
||||
restat = "1"
|
||||
}
|
||||
tool("link") {
|
||||
command = "$ld \$ldflags -o \$out -Wl,--start-group \$in \$solibs -Wl,--end-group \$libs"
|
||||
description = "LINK \$out"
|
||||
#pool = "link_pool"
|
||||
}
|
||||
tool("stamp") {
|
||||
command = "\${postbuilds}touch \$out"
|
||||
description = "STAMP \$out"
|
||||
}
|
||||
tool("copy") {
|
||||
command = "ln -f \$in \$out 2>/dev/null || (rm -rf \$out && cp -af \$in \$out)"
|
||||
description = "COPY \$in \$out"
|
||||
}
|
||||
|
||||
# When invoking this toolchain not as the default one, these args will be
|
||||
# passed to the build. They are ignored when this is the default toolchain.
|
||||
toolchain_args() {
|
||||
cpu_arch = "arm"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
# Copyright (c) 2013 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.
|
||||
|
||||
# Should only be running on Mac.
|
||||
assert(is_mac)
|
||||
|
||||
cc = rebase_path("//third_party/llvm-build/Release+Asserts/bin/clang", ".", root_build_dir)
|
||||
cxx = rebase_path("//third_party/llvm-build/Release+Asserts/bin/clang++", ".", root_build_dir)
|
||||
ld = cxx
|
||||
|
||||
# This will copy the gyp-mac-tool to the build directory. We pass in the source
|
||||
# file of the win tool.
|
||||
gyp_mac_tool_source =
|
||||
rebase_path("//tools/gyp/pylib/gyp/mac_tool.py", ".", root_build_dir)
|
||||
exec_script("setup_toolchain.py", [ gyp_mac_tool_source ], "value")
|
||||
|
||||
toolchain("clang") {
|
||||
# Make these apply to all tools below.
|
||||
lib_prefix = "-l"
|
||||
lib_dir_prefix="-L"
|
||||
|
||||
tool("cc") {
|
||||
command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c \$cflags_pch_c -c \$in -o \$out"
|
||||
description = "CC \$out"
|
||||
depfile = "\$out.d"
|
||||
deps = "gcc"
|
||||
}
|
||||
tool("cxx") {
|
||||
command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc \$cflags_pch_cc -c \$in -o \$out"
|
||||
description = "CXX \$out"
|
||||
depfile = "\$out.d"
|
||||
deps = "gcc"
|
||||
}
|
||||
tool("objc") {
|
||||
command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c \$cflags_objc \$cflags_pch_objc -c \$in -o \$out"
|
||||
description = "OBJC \$out"
|
||||
depfile = "\$out.d"
|
||||
deps = "gcc"
|
||||
}
|
||||
tool("objcxx") {
|
||||
command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc \$cflags_objcc \$cflags_pch_objcc -c \$in -o \$out"
|
||||
description = "OBJCXX \$out"
|
||||
depfile = "\$out.d"
|
||||
deps = "gcc"
|
||||
}
|
||||
tool("alink") {
|
||||
command = "rm -f \$out && ./gyp-mac-tool filter-libtool libtool \$libtool_flags -static -o \$out \$in \$postbuilds"
|
||||
description = "LIBTOOL-STATIC \$out, POSTBUILDS"
|
||||
}
|
||||
tool("solink") {
|
||||
command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ] || otool -l \$lib | grep -q LC_REEXPORT_DYLIB ; then $ld -shared \$ldflags -o \$lib \$in \$solibs \$libs \$postbuilds && { otool -l \$lib | grep LC_ID_DYLIB -A 5; nm -gP \$lib | cut -f1-2 -d' ' | grep -v U\$\$; true; } > \${lib}.TOC; else $ld -shared \$ldflags -o \$lib \$in \$solibs \$libs \$postbuilds && { otool -l \$lib | grep LC_ID_DYLIB -A 5; nm -gP \$lib | cut -f1-2 -d' ' | grep -v U\$\$; true; } > \${lib}.tmp && if ! cmp -s \${lib}.tmp \${lib}.TOC; then mv \${lib}.tmp \${lib}.TOC ; fi; fi"
|
||||
description = "SOLINK \$lib, POSTBUILDS"
|
||||
#pool = "link_pool"
|
||||
restat = "1"
|
||||
}
|
||||
tool("link") {
|
||||
command = "$ld \$ldflags -o \$out \$in \$solibs \$libs \$postbuilds"
|
||||
description = "LINK \$out, POSTBUILDS"
|
||||
#pool = "link_pool"
|
||||
}
|
||||
#tool("infoplist") {
|
||||
# command = "$cc -E -P -Wno-trigraphs -x c \$defines \$in -o \$out && plutil -convert xml1 \$out \$out"
|
||||
# description = "INFOPLIST \$out"
|
||||
#}
|
||||
#tool("mac_tool") {
|
||||
# command = "\$env ./gyp-mac-tool \$mactool_cmd \$in \$out"
|
||||
# description = "MACTOOL \$mactool_cmd \$in"
|
||||
#}
|
||||
#tool("package_framework") {
|
||||
# command = "./gyp-mac-tool package-framework \$out \$version \$postbuilds && touch \$out"
|
||||
# description = "PACKAGE FRAMEWORK \$out, POSTBUILDS"
|
||||
#}
|
||||
tool("stamp") {
|
||||
command = "\${postbuilds}touch \$out"
|
||||
description = "STAMP \$out"
|
||||
}
|
||||
tool("copy") {
|
||||
command = "ln -f \$in \$out 2>/dev/null || (rm -rf \$out && cp -af \$in \$out)"
|
||||
description = "COPY \$in \$out"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
# Copyright (c) 2013 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.
|
||||
|
||||
import os
|
||||
import stat
|
||||
import sys
|
||||
|
||||
def CopyTool(source_path):
|
||||
"""Copies the given tool to the current directory, including a warning not
|
||||
to edit it."""
|
||||
with open(source_path) as source_file:
|
||||
tool_source = source_file.readlines()
|
||||
|
||||
# Add header and write it out to the current directory (which should be the
|
||||
# root build dir).
|
||||
out_path = 'gyp-mac-tool'
|
||||
with open(out_path, 'w') as tool_file:
|
||||
tool_file.write(''.join([tool_source[0],
|
||||
'# Generated by setup_toolchain.py do not edit.\n']
|
||||
+ tool_source[1:]))
|
||||
st = os.stat(out_path)
|
||||
os.chmod(out_path, st.st_mode | stat.S_IEXEC)
|
||||
|
||||
# Find the tool source, it's the first argument, and copy it.
|
||||
if len(sys.argv) != 2:
|
||||
print "Need one argument (mac_tool source path)."
|
||||
sys.exit(1)
|
||||
CopyTool(sys.argv[1])
|
|
@ -0,0 +1,62 @@
|
|||
# Copyright (c) 2013 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.
|
||||
|
||||
|
||||
toolchain("x86_newlib") {
|
||||
toolprefix = "gen/sdk/toolchain/linux_x86_newlib/bin/x86_64-nacl-"
|
||||
cc = toolprefix + "gcc"
|
||||
cxx = toolprefix + "g++"
|
||||
ld = toolprefix + "g++"
|
||||
|
||||
tool("cc") {
|
||||
command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c -c \$in -o \$out"
|
||||
description = "CC(NaCl x86 Newlib) \$out"
|
||||
depfile = "\$out.d"
|
||||
deps = "gcc"
|
||||
}
|
||||
tool("cxx") {
|
||||
# cflags_pch_cc
|
||||
command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc -c \$in -o \$out"
|
||||
description = "CXX(NaCl x86 Newlib) \$out"
|
||||
depfile = "\$out.d"
|
||||
deps = "gcc"
|
||||
}
|
||||
tool("alink") {
|
||||
command = "rm -f \$out && ${toolprefix}ar rcs \$out \$in"
|
||||
description = "AR(NaCl x86 Newlib) \$out"
|
||||
}
|
||||
tool("solink") {
|
||||
command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ]; then $ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.TOC; else $ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.tmp && if ! cmp -s \${lib}.tmp \${lib}.TOC; then mv \${lib}.tmp \${lib}.TOC ; fi; fi"
|
||||
description = "SOLINK(NaCl x86 Newlib) \$lib"
|
||||
#pool = "link_pool"
|
||||
restat = "1"
|
||||
}
|
||||
tool("link") {
|
||||
command = "$ld \$ldflags -o \$out -Wl,--start-group \$in \$solibs -Wl,--end-group \$libs"
|
||||
description = "LINK(NaCl x86 Newlib) \$out"
|
||||
#pool = "link_pool"
|
||||
}
|
||||
|
||||
if (is_win) {
|
||||
tool("stamp") {
|
||||
command = "$python_path gyp-win-tool stamp \$out"
|
||||
description = "STAMP \$out"
|
||||
}
|
||||
} else {
|
||||
tool("stamp") {
|
||||
command = "touch \$out"
|
||||
description = "STAMP \$out"
|
||||
}
|
||||
}
|
||||
|
||||
toolchain_args() {
|
||||
# Override the default OS detection. The build config will set the is_*
|
||||
# flags accordingly.
|
||||
os = "nacl"
|
||||
|
||||
# Component build not supported in NaCl, since it does not support shared
|
||||
# libraries.
|
||||
is_component_build = false
|
||||
}
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
# Copyright (c) 2013 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.
|
||||
|
||||
# Should only be running on Windows.
|
||||
assert(is_win)
|
||||
|
||||
# Setup the Visual Studio state.
|
||||
#
|
||||
# Its argument is the location to write the environment files.
|
||||
# It will write "environment.x86" and "environment.x64" to this directory,
|
||||
# and return a list to us.
|
||||
#
|
||||
# The list contains the include path as its only element. (I'm expecting to
|
||||
# add more so it's currently a list inside a list.)
|
||||
#exec_script("get_msvc_config.py",
|
||||
# [relative_root_output_dir],
|
||||
# "value")
|
||||
|
||||
# This will save the environment block and and copy the gyp-win-tool to the
|
||||
# build directory. We pass in the source file of the win tool.
|
||||
gyp_win_tool_source =
|
||||
rebase_path("//tools/gyp/pylib/gyp/win_tool.py", ".", root_build_dir)
|
||||
exec_script("setup_toolchain.py", [ gyp_win_tool_source ], "value")
|
||||
|
||||
# 32-bit toolchain -------------------------------------------------------------
|
||||
|
||||
toolchain("32") {
|
||||
# Make these apply to all tools below.
|
||||
lib_prefix = ""
|
||||
lib_dir_prefix="/LIBPATH:"
|
||||
|
||||
tool("cc") {
|
||||
command = "ninja -t msvc -e environment.x86 -- cl.exe /nologo /showIncludes /FC @\$out.rsp /c \$in /Fo\$out /Fd\$pdbname"
|
||||
description = "CC \$out"
|
||||
rspfile = "\$out.rsp"
|
||||
rspfile_content = "\$defines \$includes \$cflags \$cflags_c"
|
||||
deps = "msvc"
|
||||
}
|
||||
tool("cxx") {
|
||||
command = "ninja -t msvc -e environment.x86 -- cl.exe /nologo /showIncludes /FC @\$out.rsp /c \$in /Fo\$out /Fd\$pdbname"
|
||||
description = "CXX \$out"
|
||||
rspfile = "\$out.rsp"
|
||||
rspfile_content = "\$defines \$includes \$cflags \$cflags_cc"
|
||||
deps = "msvc"
|
||||
}
|
||||
#tool("idl") {
|
||||
# command = $python_path gyp-win-tool midl-wrapper environment.x86 \$outdir \$tlb \$h \$dlldata \$iid \$
|
||||
# \$proxy \$in \$idlflags
|
||||
# description = IDL \$in
|
||||
#}
|
||||
tool("rc") {
|
||||
command = "$python_path gyp-win-tool rc-wrapper environment.x86 rc.exe \$defines \$includes \$rcflags /fo\$out \$in"
|
||||
description = "RC \$in"
|
||||
}
|
||||
#tool("asm") {
|
||||
# command = $python_path gyp-win-tool asm-wrapper environment.x86 ml.exe \$defines \$includes /c /Fo \$
|
||||
# \$out \$in
|
||||
# description = ASM \$in
|
||||
#}
|
||||
tool("alink") {
|
||||
command = "$python_path gyp-win-tool link-wrapper environment.x86 lib.exe /nologo /ignore:4221 /OUT:\$out @\$out.rsp"
|
||||
description = "LIB \$out"
|
||||
rspfile = "\$out.rsp"
|
||||
rspfile_content = "\$in_newline \$libflags"
|
||||
}
|
||||
#tool("solink_embed_inc") {
|
||||
# command = cmd /c $python_path gyp-win-tool link-wrapper environment.x86 link.exe /nologo \$implibflag \$
|
||||
# /DLL /OUT:\$dll /PDB:\$dll.pdb @\$dll.rsp && $python_path gyp-win-tool \$
|
||||
# manifest-wrapper environment.x86 cmd /c if exist \$dll.manifest del \$dll.manifest && \$
|
||||
# $python_path gyp-win-tool manifest-wrapper environment.x86 mt.exe -nologo -manifest \$manifests \$
|
||||
# -out:\$dll.manifest && $python_path gyp-win-tool manifest-to-rc environment.x86 \$dll.manifest \$
|
||||
# \$dll.manifest.rc 2 && $python_path gyp-win-tool rc-wrapper environment.x86 rc.exe \$
|
||||
# \$dll.manifest.rc && $python_path gyp-win-tool link-wrapper environment.x86 link.exe /nologo \$
|
||||
# \$implibflag /DLL /OUT:\$dll /PDB:\$dll.pdb @\$dll.rsp \$dll.manifest.res
|
||||
# description = LINK_EMBED_INC(DLL) \$dll
|
||||
# restat = 1
|
||||
# rspfile = \$dll.rsp
|
||||
# rspfile_content = \$libs \$in_newline \$ldflags
|
||||
#}
|
||||
#tool("solink_module_embed_inc") {
|
||||
# command = cmd /c $python_path gyp-win-tool link-wrapper environment.x86 link.exe /nologo \$implibflag \$
|
||||
# /DLL /OUT:\$dll /PDB:\$dll.pdb @\$dll.rsp && $python_path gyp-win-tool \$
|
||||
# manifest-wrapper environment.x86 cmd /c if exist \$dll.manifest del \$dll.manifest && \$
|
||||
# $python_path gyp-win-tool manifest-wrapper environment.x86 mt.exe -nologo -manifest \$manifests \$
|
||||
# -out:\$dll.manifest && $python_path gyp-win-tool manifest-to-rc environment.x86 \$dll.manifest \$
|
||||
# \$dll.manifest.rc 2 && $python_path gyp-win-tool rc-wrapper environment.x86 rc.exe \$
|
||||
# \$dll.manifest.rc && $python_path gyp-win-tool link-wrapper environment.x86 link.exe /nologo \$
|
||||
# \$implibflag /DLL /OUT:\$dll /PDB:\$dll.pdb @\$dll.rsp \$dll.manifest.res
|
||||
# description = LINK_EMBED_INC(DLL) \$dll
|
||||
# restat = 1
|
||||
# rspfile = \$dll.rsp
|
||||
# rspfile_content = \$libs \$in_newline \$ldflags
|
||||
#}
|
||||
#rule link_embed_inc
|
||||
# command = cmd /c $python_path gyp-win-tool link-wrapper environment.x86 link.exe /nologo /OUT:\$out \$
|
||||
# /PDB:\$out.pdb @\$out.rsp && $python_path gyp-win-tool manifest-wrapper environment.x86 cmd /c \$
|
||||
# if exist \$out.manifest del \$out.manifest && $python_path gyp-win-tool \$
|
||||
# manifest-wrapper environment.x86 mt.exe -nologo -manifest \$manifests -out:\$out.manifest && \$
|
||||
# $python_path gyp-win-tool manifest-to-rc environment.x86 \$out.manifest \$out.manifest.rc 1 && \$
|
||||
# $python_path gyp-win-tool rc-wrapper environment.x86 rc.exe \$out.manifest.rc && \$
|
||||
# $python_path gyp-win-tool link-wrapper environment.x86 link.exe /nologo /OUT:\$out /PDB:\$out.pdb \$
|
||||
# @\$out.rsp \$out.manifest.res
|
||||
# description = LINK_EMBED_INC \$out
|
||||
# rspfile = \$out.rsp
|
||||
# rspfile_content = \$in_newline \$libs \$ldflags
|
||||
#rule solink_embed
|
||||
# command = cmd /c $python_path gyp-win-tool link-wrapper environment.x86 link.exe /nologo \$implibflag \$
|
||||
# /DLL /OUT:\$dll /PDB:\$dll.pdb @\$dll.rsp && $python_path gyp-win-tool \$
|
||||
# manifest-wrapper environment.x86 cmd /c if exist \$dll.manifest del \$dll.manifest && \$
|
||||
# $python_path gyp-win-tool manifest-wrapper environment.x86 mt.exe -nologo -manifest \$manifests \$
|
||||
# -outputresource:\$dll;2
|
||||
# description = LINK_EMBED(DLL) \$dll
|
||||
# restat = 1
|
||||
# rspfile = \$dll.rsp
|
||||
# rspfile_content = \$libs \$in_newline \$ldflags
|
||||
#rule solink_module_embed
|
||||
# command = cmd /c $python_path gyp-win-tool link-wrapper environment.x86 link.exe /nologo \$implibflag \$
|
||||
# /DLL /OUT:\$dll /PDB:\$dll.pdb @\$dll.rsp && $python_path gyp-win-tool \$
|
||||
# manifest-wrapper environment.x86 cmd /c if exist \$dll.manifest del \$dll.manifest && \$
|
||||
# $python_path gyp-win-tool manifest-wrapper environment.x86 mt.exe -nologo -manifest \$manifests \$
|
||||
# -outputresource:\$dll;2
|
||||
# description = LINK_EMBED(DLL) \$dll
|
||||
# restat = 1
|
||||
# rspfile = \$dll.rsp
|
||||
# rspfile_content = \$libs \$in_newline \$ldflags
|
||||
#rule link_embed
|
||||
# command = cmd /c $python_path gyp-win-tool link-wrapper environment.x86 link.exe /nologo /OUT:\$out \$
|
||||
# /PDB:\$out.pdb @\$out.rsp && $python_path gyp-win-tool manifest-wrapper environment.x86 cmd /c \$
|
||||
# if exist \$out.manifest del \$out.manifest && $python_path gyp-win-tool \$
|
||||
# manifest-wrapper environment.x86 mt.exe -nologo -manifest \$manifests -outputresource:\$out;1
|
||||
# description = LINK_EMBED \$out
|
||||
# rspfile = \$out.rsp
|
||||
# rspfile_content = \$in_newline \$libs \$ldflags
|
||||
tool("solink") {
|
||||
command = "cmd /c $python_path gyp-win-tool link-wrapper environment.x86 link.exe /nologo \$implibflag /DLL /OUT:\$dll /PDB:\$dll.pdb @\$dll.rsp && $python_path gyp-win-tool manifest-wrapper environment.x86 cmd /c if exist \$dll.manifest del \$dll.manifest && $python_path gyp-win-tool manifest-wrapper environment.x86 mt.exe -nologo -manifest \$manifests -out:\$dll.manifest"
|
||||
description = "LINK(DLL) \$dll"
|
||||
restat = "1"
|
||||
rspfile = "\$dll.rsp"
|
||||
rspfile_content = "\$libs \$in_newline \$ldflags"
|
||||
}
|
||||
tool("link") {
|
||||
command = "cmd /c $python_path gyp-win-tool link-wrapper environment.x86 link.exe /nologo /OUT:\$out /PDB:\$out.pdb @\$out.rsp && $python_path gyp-win-tool manifest-wrapper environment.x86 cmd /c if exist \$out.manifest del \$out.manifest && $python_path gyp-win-tool manifest-wrapper environment.x86 mt.exe -nologo -manifest \$manifests -out:\$out.manifest"
|
||||
description = "LINK \$out"
|
||||
rspfile = "\$out.rsp"
|
||||
rspfile_content = "\$in_newline \$libs \$ldflags"
|
||||
}
|
||||
tool("stamp") {
|
||||
command = "$python_path gyp-win-tool stamp \$out"
|
||||
description = "STAMP \$out"
|
||||
}
|
||||
tool("copy") {
|
||||
command = "$python_path gyp-win-tool recursive-mirror \$in \$out"
|
||||
description = "COPY \$in \$out"
|
||||
}
|
||||
}
|
||||
|
||||
# 64-bit toolchain -------------------------------------------------------------
|
||||
|
||||
toolchain("64") {
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
# Copyright (c) 2013 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.
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
def ExtractImportantEnvironment():
|
||||
"""Extracts environment variables required for the toolchain from the
|
||||
current environment."""
|
||||
envvars_to_save = (
|
||||
'goma_.*', # TODO(scottmg): This is ugly, but needed for goma.
|
||||
'Path',
|
||||
'PATHEXT',
|
||||
'SystemRoot',
|
||||
'TEMP',
|
||||
'TMP',
|
||||
)
|
||||
result = {}
|
||||
for envvar in envvars_to_save:
|
||||
if envvar in os.environ:
|
||||
if envvar == 'Path':
|
||||
# Our own rules (for running gyp-win-tool) and other actions in
|
||||
# Chromium rely on python being in the path. Add the path to this
|
||||
# python here so that if it's not in the path when ninja is run
|
||||
# later, python will still be found.
|
||||
result[envvar.upper()] = os.path.dirname(sys.executable) + \
|
||||
os.pathsep + os.environ[envvar]
|
||||
else:
|
||||
result[envvar.upper()] = os.environ[envvar]
|
||||
for required in ('SYSTEMROOT', 'TEMP', 'TMP'):
|
||||
if required not in result:
|
||||
raise Exception('Environment variable "%s" '
|
||||
'required to be set to valid path' % required)
|
||||
return result
|
||||
|
||||
def FormatAsEnvironmentBlock(envvar_dict):
|
||||
"""Format as an 'environment block' directly suitable for CreateProcess.
|
||||
Briefly this is a list of key=value\0, terminated by an additional \0. See
|
||||
CreateProcess documentation for more details."""
|
||||
block = ''
|
||||
nul = '\0'
|
||||
for key, value in envvar_dict.iteritems():
|
||||
block += key + '=' + value + nul
|
||||
block += nul
|
||||
return block
|
||||
|
||||
def CopyTool(source_path):
|
||||
"""Copies the given tool to the current directory, including a warning not
|
||||
to edit it."""
|
||||
with open(source_path) as source_file:
|
||||
tool_source = source_file.readlines()
|
||||
|
||||
# Add header and write it out to the current directory (which should be the
|
||||
# root build dir).
|
||||
with open("gyp-win-tool", 'w') as tool_file:
|
||||
tool_file.write(''.join([tool_source[0],
|
||||
'# Generated by setup_toolchain.py do not edit.\n']
|
||||
+ tool_source[1:]))
|
||||
|
||||
# Find the tool source, it's the first argument, and copy it.
|
||||
if len(sys.argv) != 2:
|
||||
print "Need one argument (win_tool source path)."
|
||||
sys.exit(1)
|
||||
CopyTool(sys.argv[1])
|
||||
|
||||
# Write the environment file to the current directory.
|
||||
environ = FormatAsEnvironmentBlock(ExtractImportantEnvironment())
|
||||
with open('environment.x86', 'wb') as env_file:
|
||||
env_file.write(environ)
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
# Copyright (c) 2013 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 generates a "last_change.h" header file in the generated files
|
||||
# directory that contains a define of the last revision of the source tree
|
||||
# of the form:
|
||||
# #define LAST_CHANGE "123456"
|
||||
#
|
||||
# The version is a string rather than an integer for extra flexibility (for
|
||||
# example, we may require git hashes in the future).
|
||||
#
|
||||
# All you nede to do is depend on this target, and then from your source code:
|
||||
# #include "build/util/last_change.h"
|
||||
custom("last_change") {
|
||||
script = "//build/util/lastchange.py"
|
||||
|
||||
# This script must be run before targets depending on us.
|
||||
hard_dep = true
|
||||
|
||||
# Rerun the script any time this file changes.
|
||||
source_prereqs = [ "//build/util/LASTCHANGE" ]
|
||||
|
||||
output_header = "$target_gen_dir/last_change.h"
|
||||
outputs = [ output_header ]
|
||||
|
||||
build_relative_src = rebase_path("//", ".", root_build_dir)
|
||||
build_relative_outputs = rebase_path(output_header, ".", root_build_dir)
|
||||
|
||||
args = [
|
||||
"--source-dir=$build_relative_src",
|
||||
"--header=$build_relative_outputs",
|
||||
"--version-macro=LAST_CHANGE",
|
||||
]
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
per-file BUILD.gn=set noparent
|
||||
per-file BUILD.gn=brettw@chromium.org
|
Загрузка…
Ссылка в новой задаче