• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2020 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14config("cpu_arch") {
15  cflags = target_arch_cflags
16  cflags_cc = cflags
17  ldflags = cflags
18  asmflags = cflags
19}
20
21config("gtest_feature_cpp") {
22  cflags_cc = [ "-std=c++17" ]
23}
24
25config("language_c") {
26  cflags_c = [ "-std=c99" ]
27}
28
29config("language_cpp") {
30  cflags_cc = [ "-std=c++11" ]
31}
32
33config("kernel_macros") {
34  if (ohos_kernel_type == "liteos_a") {
35    defines = [
36      "__LITEOS__",
37      "__LITEOS_A__",
38    ]
39  } else if (ohos_kernel_type == "liteos_m") {
40    defines = [
41      "__LITEOS__",
42      "__LITEOS_M__",
43    ]
44  } else if (ohos_kernel_type == "uniproton") {
45    defines = [
46      "__uniproton__",
47      "__UNIPROTON__",
48    ]
49  } else if (ohos_kernel_type == "linux") {
50    defines = [
51      "__linux__",
52      "__LINUX__",
53    ]
54  }
55}
56
57config("werror") {
58  cflags = [ "-Werror" ]
59  cflags_cc = cflags
60}
61
62config("common") {
63  defines = [ "_XOPEN_SOURCE=700" ]
64  cflags = [
65    "-fno-common",
66    "-fno-builtin",
67    "-fno-strict-aliasing",
68    "-Wall",
69  ]
70  if (ohos_kernel_type == "linux") {
71    cflags += [
72      "-funwind-tables",
73      "-fasynchronous-unwind-tables",
74    ]
75  }
76  cflags_cc = cflags
77  cflags += [ "-fsigned-char" ]
78}
79
80config("security") {
81  # Need to support fortify ability first in musl libc, so disable the option temporarily
82  # defines = [ "_FORTIFY_SOURCE=2" ]
83
84  cflags = [ "-fstack-protector-all" ]
85  cflags_cc = cflags
86
87  ldflags = [
88    "-Wl,-z,now",
89    "-Wl,-z,relro",
90    "-Wl,-z,noexecstack",
91  ]
92}
93
94config("exceptions") {
95  cflags_cc = [ "-fexceptions" ]
96  cflags_objcc = cflags_cc
97}
98
99config("no_exceptions") {
100  cflags_cc = [ "-fno-exceptions" ]
101  cflags_objcc = cflags_cc
102  ldflags = cflags_cc
103}
104
105config("stack_protector") {
106  cflags = [ "-fstack-protector-all" ]
107  cflags_cc = cflags
108}
109
110config("static_pie_config") {
111  cflags = [ "-fPIE" ]
112  cflags_cc = cflags
113}
114
115config("shared_library_config") {
116  cflags = [ "-fPIC" ]
117  cflags_cc = cflags
118}
119
120config("pie_executable_config") {
121  ldflags = [ "-pie" ]
122}
123
124config("ohos_clang") {
125  if (ohos_kernel_type == "linux") {
126    defines = [
127      "_LIBCPP_HAS_MUSL_LIBC",
128      "__BUILD_LINUX_WITH_CLANG",
129    ]
130  }
131  ldflags = [
132    "-fuse-ld=lld",
133    "--rtlib=compiler-rt",
134  ]
135}
136
137config("release") {
138  defines = [ "OHOS_RELEASE" ]
139}
140
141config("debug") {
142  defines = [ "OHOS_DEBUG" ]
143}
144
145config("clang_opt") {
146  cflags = [
147    "-Oz",
148    "-flto",
149  ]
150  cflags_cc = cflags
151}
152
153config("gcc_opt") {
154  cflags = [ "-Os" ]
155  cflags_cc = cflags
156}
157
158config("default_link_path") {
159  ldflags = [
160    "-L.",
161    "-Wl,-rpath-link=.",
162  ]
163}
164
165config("board_config") {
166  cflags = []
167  cflags_cc = []
168  ldflags = []
169  include_dirs = []
170  defines = []
171  asmflags = []
172  cflags += board_cflags
173  cflags_cc += board_cxx_flags
174  ldflags += board_ld_flags
175  include_dirs += board_include_dirs
176  if (defined(board_macro_defines)) {
177    defines += board_macro_defines
178  }
179  if (defined(board_asmflags)) {
180    asmflags += board_asmflags
181  }
182}
183
184config("board_exe_ld_flags") {
185  ldflags = []
186  if (defined(board_exe_ld_flags)) {
187    ldflags += board_exe_ld_flags
188  }
189}
190