• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
2# Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without modification,
5# are permitted provided that the following conditions are met:
6#
7# 1. Redistributions of source code must retain the above copyright notice, this list of
8#    conditions and the following disclaimer.
9#
10# 2. Redistributions in binary form must reproduce the above copyright notice, this list
11#    of conditions and the following disclaimer in the documentation and/or other materials
12#    provided with the distribution.
13#
14# 3. Neither the name of the copyright holder nor the names of its contributors may be used
15#    to endorse or promote products derived from this software without specific prior written
16#    permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
22# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30# feature: sh
31if (defined(ohos_lite)) {
32  executable("mksh") {
33    sources = [
34      "edit.c",
35      "eval.c",
36      "exec.c",
37      "expr.c",
38      "funcs.c",
39      "histrap.c",
40      "jobs.c",
41      "lalloc.c",
42      "lex.c",
43      "main.c",
44      "misc.c",
45      "shf.c",
46      "strlcpy.c",
47      "syn.c",
48      "tree.c",
49      "var.c",
50    ]
51
52    include_dirs = [ "./" ]
53
54    cflags = [
55      "-Wall",
56      "-Wno-deprecated-declarations",
57      "-fno-asynchronous-unwind-tables",
58      "-fwrapv",
59      "-fstack-protector-all",
60      "-fPIE",
61
62      # various options we choose
63      "-DDEBUG_LEAKS",
64      "-DMKSH_ASSUME_UTF8",
65      "-DMKSH_DONT_EMIT_IDSTRING",
66
67      # and the defines from middleware file Rebuild.sh.
68      "-DMKSH_BUILDSH",
69      "-D_GNU_SOURCE",
70      "-DSETUID_CAN_FAIL_WITH_EAGAIN",
71      "-DHAVE_STRING_POOLING=2",
72      "-DHAVE_ATTRIBUTE_BOUNDED=0",
73      "-DHAVE_ATTRIBUTE_FORMAT=1",
74      "-DHAVE_ATTRIBUTE_NORETURN=1",
75      "-DHAVE_ATTRIBUTE_PURE=1",
76      "-DHAVE_ATTRIBUTE_UNUSED=1",
77      "-DHAVE_ATTRIBUTE_USED=1",
78      "-DHAVE_SYS_TIME_H=1",
79      "-DHAVE_TIME_H=1",
80      "-DHAVE_BOTH_TIME_H=1",
81      "-DHAVE_SYS_BSDTYPES_H=0",
82      "-DHAVE_SYS_FILE_H=1",
83      "-DHAVE_SYS_MKDEV_H=0",
84      "-DHAVE_SYS_MMAN_H=1",
85      "-DHAVE_SYS_PARAM_H=1",
86      "-DHAVE_SYS_RESOURCE_H=1",
87      "-DHAVE_SYS_SELECT_H=1",
88      "-DHAVE_SYS_SYSMACROS_H=1",
89      "-DHAVE_BSTRING_H=0",
90      "-DHAVE_GRP_H=1",
91      "-DHAVE_IO_H=0",
92      "-DHAVE_LIBGEN_H=1",
93      "-DHAVE_LIBUTIL_H=0",
94      "-DHAVE_PATHS_H=1",
95      "-DHAVE_STDINT_H=1",
96      "-DHAVE_STRINGS_H=1",
97      "-DHAVE_TERMIOS_H=1",
98      "-DHAVE_ULIMIT_H=1",
99      "-DHAVE_VALUES_H=1",
100      "-DHAVE_CAN_INTTYPES=1",
101      "-DHAVE_CAN_UCBINTS=1",
102      "-DHAVE_CAN_INT8TYPE=1",
103      "-DHAVE_CAN_UCBINT8=1",
104      "-DHAVE_RLIM_T=1",
105      "-DHAVE_SIG_T=1",
106      "-DHAVE_SYS_ERRLIST=1",
107      "-DHAVE_FLOCK=1",
108      "-DHAVE_LOCK_FCNTL=1",
109      "-DHAVE_GETRUSAGE=1",
110      "-DHAVE_GETSID=1",
111      "-DHAVE_GETTIMEOFDAY=1",
112      "-DHAVE_KILLPG=1",
113      "-DHAVE_MEMMOVE=1",
114      "-DHAVE_MKNOD=0",
115      "-DHAVE_MMAP=1",
116      "-DHAVE_FTRUNCATE=1",
117      "-DHAVE_NICE=1",
118      "-DHAVE_REVOKE=0",
119      "-DHAVE_SETLOCALE_CTYPE=1",
120      "-DHAVE_LANGINFO_CODESET=1",
121      "-DHAVE_SELECT=1",
122      "-DHAVE_SETRESUGID=1",
123      "-DHAVE_SETGROUPS=1",
124      "-DHAVE_STRERROR=1",
125      "-DHAVE_STRSIGNAL=0",
126      "-DHAVE_STRLCPY=0",
127      "-DHAVE_FLOCK_DECL=1",
128      "-DHAVE_REVOKE_DECL=1",
129      "-DHAVE_SYS_ERRLIST_DECL=1",
130      "-DHAVE_SYS_SIGLIST_DECL=1",
131      "-DHAVE_PERSISTENT_HISTORY=1",
132      "-DMKSH_BUILD_R=571",
133    ]
134
135    ldflags = [
136      "-pie",
137      "-Wl,-z,relro",
138      "-Wl,-z,now",
139      "-Wl,-z,noexecstack",
140    ]
141  }
142} else {
143  import("//build/config/ohos/config.gni")
144  import("//build/ohos.gni")
145  ohos_executable("sh") {
146    sources = [
147      "edit.c",
148      "eval.c",
149      "exec.c",
150      "expr.c",
151      "funcs.c",
152      "histrap.c",
153      "jobs.c",
154      "lalloc.c",
155      "lex.c",
156      "main.c",
157      "misc.c",
158      "shf.c",
159      "strlcpy.c",
160      "syn.c",
161      "tree.c",
162      "var.c",
163    ]
164
165    include_dirs = [ "./" ]
166
167    cflags = [
168      "-Wall",
169      "-Wno-deprecated-declarations",
170      "-fno-asynchronous-unwind-tables",
171      "-fwrapv",
172      "-fstack-protector-all",
173      "-fPIE",
174
175      # various options we choose
176      "-DDEBUG_LEAKS",
177      "-DMKSH_ASSUME_UTF8",
178      "-DMKSH_DONT_EMIT_IDSTRING",
179
180      # and the defines from middleware file Rebuild.sh.
181      "-DMKSH_BUILDSH",
182      "-D_GNU_SOURCE",
183      "-DSETUID_CAN_FAIL_WITH_EAGAIN",
184      "-DHAVE_STRING_POOLING=2",
185      "-DHAVE_ATTRIBUTE_BOUNDED=0",
186      "-DHAVE_ATTRIBUTE_FORMAT=1",
187      "-DHAVE_ATTRIBUTE_NORETURN=1",
188      "-DHAVE_ATTRIBUTE_PURE=1",
189      "-DHAVE_ATTRIBUTE_UNUSED=1",
190      "-DHAVE_ATTRIBUTE_USED=1",
191      "-DHAVE_SYS_TIME_H=1",
192      "-DHAVE_TIME_H=1",
193      "-DHAVE_BOTH_TIME_H=1",
194      "-DHAVE_SYS_BSDTYPES_H=0",
195      "-DHAVE_SYS_FILE_H=1",
196      "-DHAVE_SYS_MKDEV_H=0",
197      "-DHAVE_SYS_MMAN_H=1",
198      "-DHAVE_SYS_PARAM_H=1",
199      "-DHAVE_SYS_RESOURCE_H=1",
200      "-DHAVE_SYS_SELECT_H=1",
201      "-DHAVE_SYS_SYSMACROS_H=1",
202      "-DHAVE_BSTRING_H=0",
203      "-DHAVE_GRP_H=1",
204      "-DHAVE_IO_H=0",
205      "-DHAVE_LIBGEN_H=1",
206      "-DHAVE_LIBUTIL_H=0",
207      "-DHAVE_PATHS_H=1",
208      "-DHAVE_STDINT_H=1",
209      "-DHAVE_STRINGS_H=1",
210      "-DHAVE_TERMIOS_H=1",
211      "-DHAVE_VALUES_H=1",
212      "-DHAVE_CAN_INTTYPES=1",
213      "-DHAVE_CAN_UCBINTS=1",
214      "-DHAVE_CAN_INT8TYPE=1",
215      "-DHAVE_CAN_UCBINT8=1",
216      "-DHAVE_RLIM_T=1",
217      "-DHAVE_SIG_T=1",
218      "-DHAVE_SYS_ERRLIST=1",
219      "-DHAVE_FLOCK=1",
220      "-DHAVE_LOCK_FCNTL=1",
221      "-DHAVE_GETRUSAGE=1",
222      "-DHAVE_GETSID=1",
223      "-DHAVE_GETTIMEOFDAY=1",
224      "-DHAVE_KILLPG=1",
225      "-DHAVE_MEMMOVE=1",
226      "-DHAVE_MKNOD=0",
227      "-DHAVE_MMAP=1",
228      "-DHAVE_FTRUNCATE=1",
229      "-DHAVE_NICE=1",
230      "-DHAVE_REVOKE=0",
231      "-DHAVE_SETLOCALE_CTYPE=1",
232      "-DHAVE_LANGINFO_CODESET=1",
233      "-DHAVE_SELECT=1",
234      "-DHAVE_SETRESUGID=1",
235      "-DHAVE_SETGROUPS=1",
236      "-DHAVE_STRERROR=1",
237      "-DHAVE_STRSIGNAL=0",
238      "-DHAVE_STRLCPY=0",
239      "-DHAVE_FLOCK_DECL=1",
240      "-DHAVE_REVOKE_DECL=1",
241      "-DHAVE_SYS_ERRLIST_DECL=1",
242      "-DHAVE_SYS_SIGLIST_DECL=1",
243      "-DHAVE_PERSISTENT_HISTORY=1",
244      "-DMKSH_BUILD_R=571",
245    ]
246    ldflags = [
247      "-pie",
248      "-Wl,-z,relro",
249      "-Wl,-z,now",
250      "-Wl,-z,noexecstack",
251    ]
252    install_images = [
253      "system",
254      "updater",
255    ]
256    part_name = "init"
257    install_enable = true
258  }
259}
260