blob: 8b3470f7a12c02e55c618d826e4ebdcbfd3c39bb [file] [log] [blame]
# Copyright (C) 2017 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/android.gni")
config("extra_warnings") {
cflags = [ "-Wextra" ]
if (is_clang) {
cflags += [
"-Weverything",
"-Wno-c++98-compat-pedantic",
"-Wno-c++98-compat",
"-Wno-gnu-include-next",
"-Wno-gnu-statement-expression",
"-Wno-padded",
"-Wno-reserved-id-macro",
"-Wno-unused-parameter",
]
}
}
config("default") {
asmflags = []
cflags = []
cflags_c = []
cflags_cc = []
defines = []
ldflags = []
libs = []
include_dirs = [ ".." ]
cflags_cc += [ "-std=c++11" ]
cflags += [
"-fno-exceptions",
"-fno-rtti",
"-fstrict-aliasing",
"-fstack-protector",
"-fPIC",
"-Wa,--noexecstack",
"-Wformat",
"-Wall",
"-Werror",
]
if (current_cpu == "arm") {
cflags += [
"-march=armv7-a",
"-mfpu=neon",
"-mthumb",
]
} else if (current_cpu == "x86") {
asmflags += [ "-m32" ]
cflags += [
"-m32",
"-msse2",
"-mfpmath=sse",
]
ldflags += [ "-m32" ]
}
if (is_linux) {
libs += [ "pthread" ]
}
if (is_android) {
asmflags += [ "--target=$android_abi_target" ]
cflags += [
"-isystem$android_ndk_root/$android_sysroot_subdir/usr/include",
"--sysroot=$android_ndk_root/$android_sysroot_subdir",
"-DANDROID",
"--target=$android_abi_target",
]
cflags_cc += [
"-I$android_ndk_root/sources/cxx-stl/llvm-libc++/include",
"-I$android_ndk_root/sources/android/support/include",
"-I$android_ndk_root/sources/cxx-stl/llvm-libc++abi/include",
]
ldflags += [
"-Wl,-z,nocopyreloc",
"-gcc-toolchain",
"$android_toolchain_root",
"--sysroot=$android_ndk_root/$android_sysroot_subdir",
"--target=$android_abi_target",
"-Wl,--exclude-libs,libunwind.a",
"-Wl,--exclude-libs,libgcc.a",
"-Wl,--exclude-libs,libc++_static.a",
"-Wl,--build-id",
"-Wl,--no-undefined",
"-Wl,-z,noexecstack",
"-Wl,-z,relro",
"-Wl,-z,now",
"-Wl,--warn-shared-textrel",
"-Wl,--fatal-warnings",
]
lib_dirs = [
"$android_ndk_root/sources/cxx-stl/llvm-libc++/libs/$android_app_abi",
"$android_ndk_root/$android_sysroot_subdir/usr/lib",
]
libs += [
"gcc",
"c++_static",
"c++abi",
"android_support",
]
}
}
config("debug_symbols") {
if (is_android) {
cflags = [
"-gline-tables-only",
"-funwind-tables",
]
} else {
cflags = [ "-g" ]
}
}
config("release") {
cflags = [
"-O3",
"-fdata-sections",
"-ffunction-sections",
]
if (is_mac) {
ldflags = [ "-dead_strip" ]
} else {
ldflags = [ "-Wl,--gc-sections" ]
}
defines = [ "NDEBUG" ]
}
config("executable") {
if (is_android || is_linux) {
asmflags = [ "-fPIE" ]
cflags = [ "-fPIE" ]
ldflags = [
"-fPIE",
"-pie",
]
}
}