# Copyright (c) 2020 Huawei Device Co., Ltd. # 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. config("cpu_arch") { cflags = target_arch_cflags cflags_cc = cflags ldflags = cflags } config("language_c") { cflags_c = [ "-std=c99" ] } config("language_cpp") { cflags_cc = [ "-std=c++11" ] } config("kernel_macros") { if (ohos_kernel_type == "liteos_a") { defines = [ "__LITEOS__", "__LITEOS_A__", ] } else if (ohos_kernel_type == "liteos_m") { defines = [ "__LITEOS__", "__LITEOS_M__", ] } else if (ohos_kernel_type == "linux") { defines = [ "__linux__", "__LINUX__", ] } } config("werror") { cflags = [ "-Werror" ] cflags_cc = cflags } config("common") { defines = [ "_XOPEN_SOURCE=700" ] cflags = [ "-nostdlib", "-fno-common", "-fno-builtin", "-fno-strict-aliasing", "-Wall", ] cflags_cc = cflags ldflags = [ "-lc" ] cflags += [ "-fsigned-char" ] } config("security") { defines = [ "_FORTIFY_SOURCE=2" ] cflags = [ "-fstack-protector-all" ] cflags_cc = cflags ldflags = [ "-Wl,-z,now", "-Wl,-z,relro", "-Wl,-z,noexecstack", ] } config("exceptions") { cflags_cc = [ "-fexceptions" ] cflags_objcc = cflags_cc } config("no_exceptions") { cflags_cc = [ "-fno-exceptions" ] cflags_objcc = cflags_cc ldflags = cflags_cc } config("stack_protector") { cflags = [ "-fstack-protector-all" ] cflags_cc = cflags } config("static_pie_config") { cflags = [ "-fPIE" ] cflags_cc = cflags } config("shared_library_config") { cflags = [ "-fPIC" ] cflags_cc = cflags } config("pie_executable_config") { ldflags = [ "-pie" ] } config("ohos_clang") { if (ohos_kernel_type == "linux") { defines = [ "_LIBCPP_HAS_MUSL_LIBC", "__BUILD_LINUX_WITH_CLANG", ] } } config("release") { defines = [ "OHOS_RELEASE" ] } config("debug") { defines = [ "OHOS_DEBUG" ] } config("clang_opt") { cflags = [ "-Oz", "-flto", ] cflags_cc = cflags } config("gcc_opt") { cflags = [ "-Os" ] cflags_cc = cflags } config("default_link_path") { out_dir = rebase_path(root_build_dir) ldflags = [ "-L${out_dir}", "-Wl,-rpath-link=${out_dir}", ] } config("board_config") { cflags = [] cflags_cc = [] ldflags = [] include_dirs = [] defines = [] cflags += board_cflags cflags_cc += board_cxx_flags ldflags += board_ld_flags include_dirs += board_include_dirs if (defined(board_macro_defines)) { defines += board_macro_defines } } config("board_exe_ld_flags") { ldflags = [] if (defined(board_exe_ld_flags)) { ldflags += board_exe_ld_flags } }