diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-13 17:41:06 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-13 17:41:06 +0000 |
commit | a74ddbcd6cac542608157b56f6e8d06c8c149322 (patch) | |
tree | 2f881bed85a43aeb3f427c89e1f5ee02fabc9cc3 | |
parent | f28a94764fd9d475add499cfb1038110de0a3acc (diff) | |
download | chromium_src-a74ddbcd6cac542608157b56f6e8d06c8c149322.zip chromium_src-a74ddbcd6cac542608157b56f6e8d06c8c149322.tar.gz chromium_src-a74ddbcd6cac542608157b56f6e8d06c8c149322.tar.bz2 |
Make GN Android build link executables.
Some minor tweaks in STL usage in GN itself to enable it to compile using the Android version of the STL. Enable this in the build (not so much because we need a GN binary on Android, but for build verification purposes).
Moved the executable_ldconfig config from the linux file to the gcc one since its shared between the Linux and Android builds. Added "-Bdynamic" and "-Wl,-z,nocopyreloc" to this on Android.
Moved some sysroot path components from sysroot.gni to android/config.gni (which sysroot uses) so it can be shared with the toolchain definitions.
Added the android_full_debug build flag. Made the "optimize off" mode of the build match the GYP build's "light optimization" on Android contingent on this flag.
Pulls out the optimize and optimize_max shared flags into one list to avoid duplication.
Adds a bunch of linker optimization flags that should be passed on non-Mac Posix platforms, and turns on dead code stripping for Mac builds.
Adds functionality to the gcc toolchain template to be able to insert strings before and after the libs. Adds a wrapper template for android toolchains that sets these accordingly to get the gross Android crtbegin/end files inserted in the right place on the linker line.
Made the android_ndk_root variable relative to the source root rather than the system root. Uses of this now rebase according to their own needs which makes some of the arguments a lot easier to follow.
Build file updates for base and libevent for Android. Implement ashmem library.
The only change on desktop linux is the addition of -Wl,--fatal-warnings to the linker line.
R=ajwong@chromium.org, cjhopman@chromium.org, scottmg@chromium.org
Review URL: https://codereview.chromium.org/275703003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270138 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/BUILD.gn | 46 | ||||
-rw-r--r-- | build/config/BUILDCONFIG.gn | 2 | ||||
-rw-r--r-- | build/config/android/config.gni | 60 | ||||
-rw-r--r-- | build/config/compiler/BUILD.gn | 169 | ||||
-rw-r--r-- | build/config/gcc/BUILD.gn | 18 | ||||
-rw-r--r-- | build/config/linux/BUILD.gn | 11 | ||||
-rw-r--r-- | build/config/sysroot.gni | 6 | ||||
-rw-r--r-- | build/toolchain/android/BUILD.gn | 75 | ||||
-rw-r--r-- | build/toolchain/gcc_toolchain.gni | 24 | ||||
-rw-r--r-- | third_party/ashmem/BUILD.gn | 22 | ||||
-rw-r--r-- | third_party/libevent/BUILD.gn | 17 | ||||
-rw-r--r-- | tools/gn/args.cc | 2 | ||||
-rw-r--r-- | tools/gn/escape.cc | 2 | ||||
-rw-r--r-- | tools/gn/settings.cc | 4 | ||||
-rw-r--r-- | tools/gn/target.cc | 10 |
15 files changed, 352 insertions, 116 deletions
diff --git a/base/BUILD.gn b/base/BUILD.gn index 28967db..c09946b 100644 --- a/base/BUILD.gn +++ b/base/BUILD.gn @@ -714,11 +714,41 @@ component("base") { ] if (is_android) { + sources += [ + "memory/discardable_memory_ashmem_allocator.cc", + "memory/discardable_memory_ashmem_allocator.h", + "memory/discardable_memory_ashmem.cc", + "memory/discardable_memory_ashmem.h", + ] + sources -= [ + "base_paths_posix.cc", + "power_monitor/power_monitor_device_source_posix.cc", + ] + + # Android uses some Linux sources, put those back. + set_sources_assignment_filter([]) + sources += [ + "debug/proc_maps_linux.cc", + "files/file_path_watcher_linux.cc", + "process/memory_linux.cc", + "process/internal_linux.cc", + "process/process_handle_linux.cc", + "process/process_iterator_linux.cc", + "process/process_metrics_linux.cc", + "posix/unix_domain_socket_linux.cc", + "sys_info_linux.cc", + ] + set_sources_assignment_filter(sources_assignment_filter) + deps += [ ":base_jni_headers", + "//third_party/ashmem", "//third_party/android_tools:cpu_features" ] + # logging.cc uses the Android logging library. + libs = [ "log" ] + sources -= [ "debug/stack_trace_posix.cc", ] @@ -799,15 +829,13 @@ component("base") { configs += linux_configs all_dependent_configs = linux_configs - if (!is_android) { - # These dependencies are not required on Android, and in the case - # of xdg_mime must be excluded due to licensing restrictions. - deps += [ - "//base/third_party/symbolize", - "//base/third_party/xdg_mime", - "//base/third_party/xdg_user_dirs", - ] - } + # These dependencies are not required on Android, and in the case + # of xdg_mime must be excluded due to licensing restrictions. + deps += [ + "//base/third_party/symbolize", + "//base/third_party/xdg_mime", + "//base/third_party/xdg_user_dirs", + ] } else { # Non-Linux. sources -= [ diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index 7f80595..d4d585a 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -418,7 +418,7 @@ set_defaults("executable") { "//build/config/mac:mac_dynamic_flags", "//build/config/mac:mac_executable_flags" ] } else if (is_linux || is_android) { - configs += [ "//build/config/linux:executable_ldconfig" ] + configs += [ "//build/config/gcc:executable_ldconfig" ] } } diff --git a/build/config/android/config.gni b/build/config/android/config.gni index 6a9080b..dc0a384 100644 --- a/build/config/android/config.gni +++ b/build/config/android/config.gni @@ -20,10 +20,64 @@ if (is_android) { "You must specify android_src for an Android WebView build.") } - # android_ndk_root ----------------------------------------------------------- + # Host stuff ----------------------------------------------------------------- - # Full system path to the Android NDK. - android_ndk_root = rebase_path("//third_party/android_tools/ndk") + # Defines the name the Android build gives to the current host CPU + # architecture, which is different than the names GN uses. + if (build_cpu_arch == "x64") { + android_host_arch = "x86_64" + } else if (build_cpu_arch == "x86") { + android_host_arch = "x86" + } else { + assert(false, "Need Android toolchain support for your build CPU arch.") + } + + # Defines the name the Android build gives to the current host CPU + # architecture, which is different than the names GN uses. + if (build_os == "linux") { + android_host_os = "linux" + } else { + assert(false, "Need Android toolchain support for your build OS.") + } + + # Directories and files ------------------------------------------------------ + # + # We define may of the dirs strings here for each output architecture (rather + # than just the current one) since these are needed by the Android toolchain + # file to define toolchains for all possible targets in one pass. + + # Path to the Android NDK. + android_ndk_root = "//third_party/android_tools/ndk" + + # Subdirectories inside android_ndk_root that contain the sysroot for the + # associated platform. + _android_api_level = 14 + x86_android_sysroot_subdir = "platforms/android-${_android_api_level}/arch-x86" + arm_android_sysroot_subdir = "platforms/android-${_android_api_level}/arch-arm" + mips_android_sysroot_subdir = "platforms/android-${_android_api_level}/arch-mips" + + # Toolchain root directory for each build. The actual binaries are inside + # a "bin" directory inside of these. + _android_toolchain_version = "4.6" + x86_android_toolchain_root = "$android_ndk_root/toolchains/x86-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}" + arm_android_toolchain_root = "$android_ndk_root/toolchains/arm-linux-androideabi-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}" + mips_android_toolchain_root = "$android_ndk_root/toolchains/mipsel-linux-android-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}" + + # Location of libgcc. This is only needed for the current GN toolchain, so we + # only need to define the current one, rather than one for every platform + # like the toolchain roots. + if (cpu_arch == "x86") { + android_libgcc_file = + "$x86_android_toolchain_root/lib/gcc/i686-linux-android/${_android_toolchain_version}/libgcc.a" + } else if (cpu_arch == "arm") { + android_libgcc_file = + "$arm_android_toolchain_root/lib/gcc/arm-linux-androideabi/${_android_toolchain_version}/libgcc.a" + } else if (cpu_arch == "mips") { + android_libgcc_file = + "$mips_android_toolchain_root/lib/gcc/mipsel-linux-android/${_android_toolchain_version}/libgcc.a" + } else { + assert(false, "Need android libgcc support for your target arch.") + } # stlport stuff -------------------------------------------------------------- diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index c492356..9b12234 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -7,6 +7,12 @@ if (cpu_arch == "arm") { import("//build/config/arm.gni") } +declare_args() { + # Normally, Android builds are lightly optimized, even for debug builds, to + # keep binary size down. Setting this flag to true disables such optimization + android_full_debug = false +} + # compiler --------------------------------------------------------------------- # # Base compiler configuration. @@ -59,6 +65,12 @@ config("compiler") { } else if (is_linux) { cflags += [ "-fstack-protector", "--param=ssp-buffer-size=4" ] } + + # Linker warnings. + if (!(is_chromeos && cpu_arch == "arm")) { + # TODO(jochen): Enable this on chromeos on arm. http://crbug.com/356580 + ldflags += [ "-Wl,--fatal-warnings" ] + } } # Mac-specific compiler flags setup. @@ -131,16 +143,26 @@ config("compiler") { } } - # Linux-specific compiler flags setup. - # ------------------------------------ - if (is_linux) { + # Linux/Android common flags setup. + # --------------------------------- + if (is_linux || is_android) { cflags += [ "-fPIC", "-pipe", # Use pipes for communicating between sub-processes. Faster. ] - if (!is_android) { - cflags += [ "-pthread" ] - } + + ldflags += [ + "-fPIC", + "-Wl,-z,noexecstack", + "-Wl,-z,now", + "-Wl,-z,relro", + ] + } + + # Linux-specific compiler flags setup. + # ------------------------------------ + if (is_linux) { + cflags += [ "-pthread" ] if (cpu_arch == "x64") { # Use gold for linking on 64-bit Linux only (on 32-bit it runs out of @@ -170,11 +192,7 @@ config("compiler") { } ldflags += [ - "-fPIC", "-pthread", - "-Wl,-z,noexecstack", - "-Wl,-z,now", - "-Wl,-z,relro", ] } @@ -225,6 +243,20 @@ config("compiler") { defines += [ "HAVE_SYS_UIO_H" ] } + # Use gold for Android for most CPU architectures. + if (cpu_arch == "x86" || cpu_arch == "x64" || cpu_arch == "arm") { + if (is_clang) { + # Clang does not support -fuse-ld to invoke the built-in gold linker, + # so use the -B option which requires us to specify the path. + ldflags += [ + "-B" + rebase_path("//build/android/arm-linux-androideabi-gold", + root_build_dir) + ] + } else { + ldflags += [ "-fuse-ld=gold" ] + } + } + ldflags += [ "-Wl,--no-undefined", # Don't export symbols from statically linked libraries. @@ -322,10 +354,10 @@ config("runtime_library") { ] ldflags += [ + "-Wl,--warn-shared-textrel", "-nostdlib", ] - # NOTE: The stlport header include paths below are specified in cflags # rather than include_dirs because they need to come after include_dirs. # Think of them like system headers, but don't use '-isystem' because the @@ -335,8 +367,9 @@ config("runtime_library") { if (use_system_stlport) { cflags += [ # For libstdc++/include, which is used by stlport. - "-I$android_src/bionic", - "-I$android_src/external/stlport/stlport", + "-I" + rebase_path("$android_src/bionic", root_build_dir), + "-I" + rebase_path("$android_src/external/stlport/stlport", + root_build_dir), ] libs += [ "stlport", @@ -344,7 +377,9 @@ config("runtime_library") { } else { android_stlport_root = "$android_ndk_root/sources/cxx-stl/stlport" - cflags += [ "-I$android_stlport_root/stlport" ] + cflags += [ + "-I" + rebase_path("$android_stlport_root/stlport", root_build_dir) + ] lib_dirs += [ "$android_stlport_root/libs/$android_app_abi" ] if (component_mode == "shared_library") { @@ -353,6 +388,16 @@ config("runtime_library") { libs += [ "stlport_static" ] } } + + libs += [ + # Manually link the libgcc.a that the cross compiler uses. This is + # absolute because the linker will look inside the sysroot if it's not. + rebase_path(android_libgcc_file), + "c", + "dl", + "m", + ] + } } @@ -587,23 +632,60 @@ config("wexit_time_destructors") { # configs -= default_optimization_config # configs += [ "//build/config/compiler/optimize_max" ] +# Shared settings for both "optimize" and "optimize_max" configs. +if (is_win) { + common_optimize_on_cflags = [ + "/O2", + "/Ob2", # both explicit and auto inlining. + "/Oy-", # disable omitting frame pointers, must be after /o2. + "/Os", # favor size over speed. + ] + common_optimize_on_ldflags = [] +} else { + common_optimize_on_cflags = [ + # Don't emit the GCC version ident directives, they just end up in the + # .comment section taking up binary size. + "-fno-ident", + # Put data and code in their own sections, so that unused symbols + # can be removed at link time with --gc-sections. + "-fdata-sections", + "-ffunction-sections", + ] + + common_optimize_on_ldflags = [] + if (is_mac) { + if (symbol_level == 2) { + # Mac dead code stripping requires symbols. + common_optimize_on_ldflags += [ + "-Wl,-dead_strip", + ] + } + } else { + # Non-Mac Posix linker flags. + common_optimize_on_ldflags += [ + # Specifically tell the linker to perform optimizations. + # See http://lwn.net/Articles/192624/ . + "-Wl,-O1", + "-Wl,--as-needed", + "-Wl,--gc-sections", + ] + } + + if (is_android || is_ios) { + common_optimize_on_cflags += [ "-Os" ] + } else { + common_optimize_on_cflags += [ "-O2" ] + } +} + # Default "optimization on" config. On Windows, this favors size over speed. -# -# IF YOU CHANGE THIS also consider whether optimize_max should be updated. config("optimize") { + cflags = common_optimize_on_cflags + ldflags = common_optimize_on_ldflags if (is_win) { - cflags = [ - "/O2", - "/Ob2", # Both explicit and auto inlining. - "/Oy-", # Disable omitting frame pointers, must be after /O2. - "/Os", # Favor size over speed. + cflags += [ + "/Os", # favor size over speed. ] - } else { - if (is_ios) { - cflags = [ "-Os" ] - } else { - cflags = [ "-O2" ] - } } } @@ -615,6 +697,20 @@ config("no_optimize") { "/Ob0", # Disable all inlining (on by default). "/RTC1", # Runtime checks for stack frame and uninitialized variables. ] + } else if (is_android && !android_full_debug) { + # On Android we kind of optimize some things that don't affect debugging + # much even when optimization is disabled to get the binary size down. + cflags = [ + "-Os", + "-fomit-frame-pointer", + "-fdata-sections", + "-ffunction-sections", + ] + ldflags = [ + "-Wl,-O1", + "-Wl,--as-needed", + "-Wl,--gc-sections", + ] } else { cflags = [ "-O0" ] } @@ -624,31 +720,18 @@ config("no_optimize") { # optimization and link-time code generation which is very expensive and should # be used sparingly. For non-Windows, this is the same as "optimize". config("optimize_max") { + cflags = common_optimize_on_cflags + ldflags = common_optimize_on_ldflags if (is_win) { - cflags = [ - "/O2", - "/Ob2", # Both explicit and auto inlining. - "/Oy-", # Disable omitting frame pointers, must be after /O2. + cflags += [ "/Ot", # Favor speed over size. "/GL", # Whole program optimization. ] - } else { - if (is_ios) { - cflags = [ "-Os" ] - } else { - cflags = [ "-O2" ] - } } } # 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. diff --git a/build/config/gcc/BUILD.gn b/build/config/gcc/BUILD.gn index 00ea3ca..8272d8a 100644 --- a/build/config/gcc/BUILD.gn +++ b/build/config/gcc/BUILD.gn @@ -17,3 +17,21 @@ config("symbol_visibility_hidden") { # config since that can almost always be applied. cflags = [ "-fvisibility=hidden" ] } + +# Settings for executables and shared libraries. +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/", + ] + + if (is_android) { + ldflags += [ + "-Bdynamic", + "-Wl,-z,nocopyreloc", + ] + } +} diff --git a/build/config/linux/BUILD.gn b/build/config/linux/BUILD.gn index e611b7c..29bc47f 100644 --- a/build/config/linux/BUILD.gn +++ b/build/config/linux/BUILD.gn @@ -18,17 +18,6 @@ config("sdk") { } } -# 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/", - ] -} - pkg_config("dridrm") { packages = [ "libdrm" ] } diff --git a/build/config/sysroot.gni b/build/config/sysroot.gni index cecc1ea..2b04c56 100644 --- a/build/config/sysroot.gni +++ b/build/config/sysroot.gni @@ -9,11 +9,11 @@ if (is_android) { import("//build/config/android/config.gni") if (!is_android_webview_build) { if (cpu_arch == "x86") { - sysroot = "$android_ndk_root/platforms/android-14/arch-x86" + sysroot = rebase_path("$android_ndk_root/$x86_android_sysroot_subdir") } else if (cpu_arch == "arm") { - sysroot = "$android_ndk_root/platforms/android-14/arch-arm" + sysroot = rebase_path("$android_ndk_root/$arm_android_sysroot_subdir") } else if (cpu_arch == "mipsel") { - sysroot = "$android_ndk_root/platforms/android-14/arch-mips" + sysroot = rebase_path("$android_ndk_root/$mips_android_sysroot_subdir") } else { sysroot = "" } diff --git a/build/toolchain/android/BUILD.gn b/build/toolchain/android/BUILD.gn index bdf2632..dc3bfed 100644 --- a/build/toolchain/android/BUILD.gn +++ b/build/toolchain/android/BUILD.gn @@ -2,49 +2,66 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -import("//build/config/android/config.gni") +import("//build/config/sysroot.gni") # Imports android/config.gni. import("//build/toolchain/clang.gni") import("//build/toolchain/goma.gni") import("//build/toolchain/gcc_toolchain.gni") -# Get the Android version of the name of the build host's architecture. -if (build_cpu_arch == "x64") { - android_host_arch = "x86_64" -} else if (build_cpu_arch == "x86") { - android_host_arch = "x86" -} else { - assert(false, "Need Android toolchain support for your build OS.") +# The Android GCC toolchains share most of the same parameters, so we have this +# wrapper around gcc_toolchain to avoid duplication of logic. +# +# Parameters: +# - android_ndk_sysroot +# Sysroot for this architecture. +# - android_ndk_lib_dir +# Subdirectory inside of android_ndk_sysroot where libs go. +# - tool_prefix +# Prefix to be added to the tool names. +# - toolchain_cpu_arch +# Same as gcc_toolchain +template("android_gcc_toolchain") { + gcc_toolchain(target_name) { + # Make our manually injected libs relative to the build dir. + android_ndk_lib = rebase_path( + invoker.android_ndk_sysroot + "/" + invoker.android_ndk_lib_dir, + root_build_dir) + + libs_section_prefix = "$android_ndk_lib/crtbegin_dynamic.o" + libs_section_postfix = "$android_ndk_lib/crtend_android.o" + + # The tools should be run relative to the build dir. + tool_prefix = rebase_path(invoker.tool_prefix, root_build_dir) + + cc = tool_prefix + "gcc" + cxx = tool_prefix + "g++" + ar = tool_prefix + "ar" + ld = cxx + + toolchain_os = "android" + toolchain_cpu_arch = invoker.toolchain_cpu_arch + } } -gcc_toolchain("x86") { - prefix = "$android_ndk_root/toolchains/x86-4.6/prebuilt/$build_os-$android_host_arch/bin/i686-linux-android-" - cc = prefix + "gcc" - cxx = prefix + "g++" - ar = prefix + "ar" - ld = cxx +android_gcc_toolchain("x86") { + android_ndk_sysroot = "$android_ndk_root/$x86_android_sysroot_subdir" + android_ndk_lib_dir = "usr/lib" + tool_prefix = "$x86_android_toolchain_root/bin/i686-linux-android-" toolchain_cpu_arch = "x86" - toolchain_os = "android" } -gcc_toolchain("arm") { - prefix = "$android_ndk_root/toolchains/arm-linux-androideabi-4.6/prebuilt/$build_os-$android_host_arch/bin/arm-linux-androideabi-" - cc = prefix + "gcc" - cxx = prefix + "g++" - ar = prefix + "ar" - ld = cxx +android_gcc_toolchain("arm") { + android_ndk_sysroot = "$android_ndk_root/$arm_android_sysroot_subdir" + android_ndk_lib_dir = "usr/lib" + tool_prefix = "$arm_android_toolchain_root/bin/arm-linux-androideabi-" toolchain_cpu_arch = "arm" - toolchain_os = "android" } -gcc_toolchain("mipsel") { - prefix = "$android_ndk_root/toolchains/mipsel-linux-android-4.6/prebuilt/$build_os-$android_host_arch/bin/mipsel-linux-android-" - cc = prefix + "gcc" - cxx = prefix + "g++" - ar = prefix + "ar" - ld = cxx +android_gcc_toolchain("mipsel") { + android_ndk_sysroot = "$android_ndk_root/$mips_android_sysroot_subdir" + android_ndk_lib_dir = "usr/lib" + tool_prefix = "$mips_android_toolchain_root/bin/mipsel-linux-android-" toolchain_cpu_arch = "mipsel" - toolchain_os = "android" } diff --git a/build/toolchain/gcc_toolchain.gni b/build/toolchain/gcc_toolchain.gni index 9e53ef6..91baa11 100644 --- a/build/toolchain/gcc_toolchain.gni +++ b/build/toolchain/gcc_toolchain.gni @@ -14,6 +14,13 @@ # build using this toolchain.) # - toolchain_os (What "os" should be set to when invoking a build using this # toolchain.) +# +# Optional parameters: +# - libs_section_prefix +# - libs_section_postfix +# The contents of these strings, if specified, will be placed around +# the libs section of the linker line. It allows one to inject libraries +# at the beginning and end for all targets in a toolchain. template("gcc_toolchain") { toolchain(target_name) { assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value") @@ -33,6 +40,19 @@ template("gcc_toolchain") { ar = invoker.ar ld = invoker.ld + # Bring these into our scope for string interpolation with default values. + if (defined(invoker.libs_section_prefix)) { + libs_section_prefix = invoker.libs_section_prefix + } else { + libs_section_prefix = "" + } + + if (defined(invoker.libs_section_postfix)) { + libs_section_postfix = invoker.libs_section_postfix + } else { + libs_section_postfix = "" + } + # Make these apply to all tools below. lib_prefix = "-l" lib_dir_prefix="-L" @@ -56,13 +76,13 @@ template("gcc_toolchain") { 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" + 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_section_prefix \$libs $libs_section_postfix && { 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" + command = "$ld \$ldflags -o \$out -Wl,--start-group \$in \$solibs -Wl,--end-group $libs_section_prefix \$libs $libs_section_postfix" description = "LINK \$out" #pool = "link_pool" } diff --git a/third_party/ashmem/BUILD.gn b/third_party/ashmem/BUILD.gn new file mode 100644 index 0000000..7266e65 --- /dev/null +++ b/third_party/ashmem/BUILD.gn @@ -0,0 +1,22 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +assert(is_android) + +import("//build/config/android/config.gni") + +if (is_android_webview_build) { + # WebView build uses the Android system version of ashmem to avoid linking + # problems. + group("ashmem") { + assert(false, "Implement system ashmem for webview build") + } +} else { + source_set("ashmem") { + sources = [ + "ashmem.h", + "ashmem-dev.c", + ] + } +} diff --git a/third_party/libevent/BUILD.gn b/third_party/libevent/BUILD.gn index 0e3064a..648dae3 100644 --- a/third_party/libevent/BUILD.gn +++ b/third_party/libevent/BUILD.gn @@ -5,8 +5,6 @@ static_library("libevent") { sources = [ "buffer.c", - "epoll.c", - "epoll_sub.c", "evbuffer.c", "evdns.c", "event.c", @@ -14,7 +12,6 @@ static_library("libevent") { "evrpc.c", "evutil.c", "http.c", - "kqueue.c", "log.c", "poll.c", "select.c", @@ -24,20 +21,16 @@ static_library("libevent") { defines = [ "HAVE_CONFIG_H" ] - if (is_linux) { - libs = [ "rt" ] - } else { - sources -= [ "epoll.c", "epoll_sub.c" ] - } - - if (is_mac) { + if (is_mac || is_ios) { + sources += [ "kqueue.c" ] include_dirs = [ "mac" ] } else if (is_linux) { + sources += [ "epoll.c" ] include_dirs = [ "linux" ] - sources -= [ "kqueue.c" ] + libs = [ "rt" ] } else if (is_android) { + sources += [ "epoll.c" ] include_dirs = [ "android" ] - sources -= [ "kqueue.c" ] } configs -= [ "//build/config/compiler:chromium_code" ] diff --git a/tools/gn/args.cc b/tools/gn/args.cc index db7b84d..846b8b8 100644 --- a/tools/gn/args.cc +++ b/tools/gn/args.cc @@ -222,6 +222,8 @@ void Args::SetSystemVarsLocked(Scope* dest) const { os = "mac"; #elif defined(OS_LINUX) os = "linux"; +#elif defined(OS_ANDROID) + os = "android"; #else #error Unknown OS type. #endif diff --git a/tools/gn/escape.cc b/tools/gn/escape.cc index c1acc72..1cc5daa 100644 --- a/tools/gn/escape.cc +++ b/tools/gn/escape.cc @@ -89,5 +89,5 @@ void EscapeStringToStream(std::ostream& out, result->reserve(str.size() + 4); // Guess we'll add a couple of extra chars. EscapeStringToString(str, options, &result.container(), NULL); if (!result->empty()) - out.write(result->data(), result->size()); + out.write(&result[0], result->size()); } diff --git a/tools/gn/settings.cc b/tools/gn/settings.cc index 08f510d..a5f90d6 100644 --- a/tools/gn/settings.cc +++ b/tools/gn/settings.cc @@ -36,6 +36,10 @@ Settings::Settings(const BuildSettings* build_settings, target_os_ = MAC; #elif defined(OS_LINUX) target_os_ = LINUX; +#elif defined(OS_ANDROID) + // Currently we don't have an "Android" target OS, it looks just like Linux + // from our perspective. + target_os_ = LINUX; #else #error implement me #endif diff --git a/tools/gn/target.cc b/tools/gn/target.cc index d1c0c4a..2ddbde9 100644 --- a/tools/gn/target.cc +++ b/tools/gn/target.cc @@ -213,7 +213,13 @@ void Target::PullRecursiveHardDeps() { const Target* dep = deps_[dep_i].ptr; if (dep->hard_dep()) recursive_hard_deps_.insert(dep); - recursive_hard_deps_.insert(dep->recursive_hard_deps().begin(), - dep->recursive_hard_deps().end()); + + // Android STL doesn't like insert(begin, end) so do it manually. + // TODO(brettw) this can be changed to insert(dep->begin(), dep->end()) when + // Android uses a better STL. + for (std::set<const Target*>::const_iterator cur = + dep->recursive_hard_deps().begin(); + cur != dep->recursive_hard_deps().end(); ++cur) + recursive_hard_deps_.insert(*cur); } } |