blob: 98d7b28da51eb8c844e99f7088d8f737892383c1 [file] [log] [blame]
# Copyright 2021 The Cobalt Authors. All Rights Reserved.
#
# 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.
declare_args() {
raspi_home = getenv("RASPI_HOME")
}
config("compiler_flags") {
cflags = []
cflags_c = []
cflags_cc = []
defines = []
ldflags = []
defines += [
# By default, <EGL/eglplatform.h> pulls in some X11 headers that have some
# nasty macros (|Status|, for example) that conflict with Chromium base.
"MESA_EGL_NO_X11_HEADERS",
# Cobalt on Linux flag
"COBALT_LINUX",
"__STDC_FORMAT_MACROS", # so that we get PRI*
"_GNU_SOURCE=1",
]
if (is_debug) {
cflags += [ "-O0" ]
cflags_cc += [ "-frtti" ]
} else if (is_devel) {
cflags += [ "-O2" ]
cflags_cc += [ "-frtti" ]
} else {
cflags += [ "-Wno-unused-but-set-variable" ]
cflags_cc += [ "-fno-rtti" ]
}
ldflags += [
"--sysroot=$raspi_home/busterroot",
# This is a quirk of Raspbian, these are required to link any GL-related
# libraries.
"-L$raspi_home/busterroot/opt/vc/lib",
"-Wl,-rpath=$raspi_home/busterroot/opt/vc/lib",
"-L$raspi_home/busterroot/usr/lib/arm-linux-gnueabihf",
"-Wl,-rpath=$raspi_home/busterroot/usr/lib/arm-linux-gnueabihf",
"-L$raspi_home/busterroot/lib/arm-linux-gnueabihf",
"-Wl,-rpath=$raspi_home/busterroot/lib/arm-linux-gnueabihf",
# Cleanup unused sections
"-Wl,-gc-sections",
"-Wl,--unresolved-symbols=ignore-in-shared-libs",
]
cflags += [
# Generated by Audio Renderer and Audio Sink implementations.
"-Wno-reorder",
# Generated by code in the raspi/shared/open_max.
"-Wno-sign-compare",
# Generated by many starboard implementation files.
"-Wno-unused-parameter",
"-Wno-unused-variable",
]
cflags += [
# Force char to be signed.
"-fsigned-char",
# Disable strict aliasing.
"-fno-strict-aliasing",
# Allow Skia"s SkVx.h to convert between vectors of different element
# types or number of subparts.
"-flax-vector-conversions",
# To support large files
"-D_FILE_OFFSET_BITS=64",
# Suppress some warnings that will be hard to fix.
"-Wno-unused-local-typedefs",
"-Wno-unused-result",
"-Wno-unused-function",
"-Wno-deprecated-declarations",
"-Wno-missing-field-initializers",
"-Wno-extra",
"-Wno-comment", # Talk to my lawyer.
"-Wno-narrowing",
"-Wno-unknown-pragmas",
"-Wno-type-limits", # TODO: We should actually look into these.
# It"s OK not to use some input parameters. Note that the order
# matters: Wall implies Wunused-parameter and Wno-unused-parameter
# has no effect if specified before Wall.
"-Wno-unused-parameter",
# Specify the sysroot with all your include dependencies.
"--sysroot=$raspi_home/busterroot",
# This is a quirk of Raspbian, these are required to include any
# GL-related headers.
"-I$raspi_home/busterroot/opt/vc/include",
"-I$raspi_home/busterroot/opt/vc/include/interface/vcos/pthreads",
"-I$raspi_home/busterroot/opt/vc/include/interface/vmcs_host/linux",
"-I$raspi_home/busterroot/usr/include/arm-linux-gnueabihf",
]
if (!cobalt_fastbuild && (is_debug || is_devel)) {
cflags += [ "-g" ]
}
cflags_c += [ "-std=c11" ]
cflags_cc += [
"-std=gnu++14",
"-Wno-literal-suffix",
]
}
config("platform_configuration") {
libs = [
"asound",
"avcodec",
"avformat",
"avutil",
":libpthread.so.0",
"pthread",
"rt",
"openmaxil",
"bcm_host",
"vcos",
"vchiq_arm",
"brcmGLESv2",
"brcmEGL",
# Static libs must be last, to avoid __dlopen linker errors
"EGL_static",
"GLESv2_static",
]
configs = [ "//starboard/raspi/shared/platform_configuration:compiler_flags" ]
}
config("speed") {
cflags = [
"-O2",
# Compile symbols in separate sections
"-ffunction-sections",
"-fdata-sections",
]
}
config("size") {
cflags = [
"-Os",
# Compile symbols in separate sections
"-ffunction-sections",
"-fdata-sections",
]
}
config("pedantic_warnings") {
cflags = [
"-Wall",
"-Wextra",
"-Wunreachable-code",
# Raspi toolchain is based off an old version of gcc, which
# falsely flags some code. That same code does not warn with gcc 6.3.
# This decision should be revisited after raspi toolchain is upgraded.
"-Wno-maybe-uninitialized",
#TODO: Renable -Werror after fixing all warnings.
#"-Werror",
"-Wno-expansion-to-defined",
"-Wno-implicit-fallthrough",
]
}
config("no_pedantic_warnings") {
cflags = [
# Do not warn for implicit type conversions that may change a value.
"-Wno-conversion",
]
}