• 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("language_c") {
22  cflags_c = [ "-std=c99" ]
23}
24
25config("language_cpp") {
26  cflags_cc = [ "-std=c++11" ]
27}
28
29config("kernel_macros") {
30  if (ohos_kernel_type == "liteos_a") {
31    defines = [
32      "__LITEOS__",
33      "__LITEOS_A__",
34    ]
35  } else if (ohos_kernel_type == "liteos_m") {
36    defines = [
37      "__LITEOS__",
38      "__LITEOS_M__",
39    ]
40  } else if (ohos_kernel_type == "uniproton") {
41    defines = [
42      "__uniproton__",
43      "__UNIPROTON__",
44    ]
45  } else if (ohos_kernel_type == "linux") {
46    defines = [
47      "__linux__",
48      "__LINUX__",
49    ]
50  }
51}
52
53config("werror") {
54  cflags = [ "-Werror" ]
55  cflags_cc = cflags
56}
57
58config("common") {
59  defines = [ "_XOPEN_SOURCE=700" ]
60  cflags = [
61    "-fno-common",
62    "-fno-builtin",
63    "-fno-strict-aliasing",
64    "-Wall",
65  ]
66  if (ohos_kernel_type == "linux") {
67    cflags += [
68      "-funwind-tables",
69      "-fasynchronous-unwind-tables",
70    ]
71  }
72  cflags_cc = cflags
73  cflags += [ "-fsigned-char" ]
74}
75
76config("security") {
77  # Need to support fortify ability first in musl libc, so disable the option temporarily
78  # defines = [ "_FORTIFY_SOURCE=2" ]
79
80  cflags = [ "-fstack-protector-all" ]
81  cflags_cc = cflags
82
83  ldflags = [
84    "-Wl,-z,now",
85    "-Wl,-z,relro",
86    "-Wl,-z,noexecstack",
87  ]
88}
89
90config("exceptions") {
91  cflags_cc = [ "-fexceptions" ]
92  cflags_objcc = cflags_cc
93}
94
95config("no_exceptions") {
96  cflags_cc = [ "-fno-exceptions" ]
97  cflags_objcc = cflags_cc
98  ldflags = cflags_cc
99}
100
101config("stack_protector") {
102  cflags = [ "-fstack-protector-all" ]
103  cflags_cc = cflags
104}
105
106config("static_pie_config") {
107  cflags = [ "-fPIE" ]
108  cflags_cc = cflags
109}
110
111config("shared_library_config") {
112  cflags = [ "-fPIC" ]
113  cflags_cc = cflags
114}
115
116config("pie_executable_config") {
117  ldflags = [ "-pie" ]
118}
119
120config("ohos_clang") {
121  if (ohos_kernel_type == "linux") {
122    defines = [
123      "_LIBCPP_HAS_MUSL_LIBC",
124      "__BUILD_LINUX_WITH_CLANG",
125    ]
126  }
127  ldflags = [
128    "-fuse-ld=lld",
129    "--rtlib=compiler-rt",
130  ]
131}
132
133config("release") {
134  defines = [ "OHOS_RELEASE" ]
135}
136
137config("debug") {
138  defines = [ "OHOS_DEBUG" ]
139}
140
141config("clang_opt") {
142  cflags = [
143    "-Oz",
144    "-flto",
145  ]
146  cflags_cc = cflags
147}
148
149config("gcc_opt") {
150  cflags = [ "-Os" ]
151  cflags_cc = cflags
152}
153
154config("default_link_path") {
155  ldflags = [
156    "-L.",
157    "-Wl,-rpath-link=.",
158  ]
159}
160
161config("board_config") {
162  cflags = []
163  cflags_cc = []
164  ldflags = []
165  include_dirs = []
166  defines = []
167  asmflags = []
168  cflags += board_cflags
169  cflags_cc += board_cxx_flags
170  ldflags += board_ld_flags
171  include_dirs += board_include_dirs
172  if (defined(board_macro_defines)) {
173    defines += board_macro_defines
174  }
175  if (defined(board_asmflags)) {
176    asmflags += board_asmflags
177  }
178}
179
180config("board_exe_ld_flags") {
181  ldflags = []
182  if (defined(board_exe_ld_flags)) {
183    ldflags += board_exe_ld_flags
184  }
185}
186