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_UNLIMITED", 133 "-DMKSH_BUILD_R=593", 134 ] 135 136 ldflags = [ 137 "-pie", 138 "-Wl,-z,relro", 139 "-Wl,-z,now", 140 "-Wl,-z,noexecstack", 141 ] 142 } 143} else { 144 import("//build/config/ohos/config.gni") 145 import("//build/ohos.gni") 146 ohos_executable("sh") { 147 sources = [ 148 "edit.c", 149 "eval.c", 150 "exec.c", 151 "expr.c", 152 "funcs.c", 153 "histrap.c", 154 "jobs.c", 155 "lalloc.c", 156 "lex.c", 157 "main.c", 158 "misc.c", 159 "shf.c", 160 "strlcpy.c", 161 "syn.c", 162 "tree.c", 163 "var.c", 164 ] 165 166 include_dirs = [ "./" ] 167 168 cflags = [ 169 "-Wall", 170 "-Wno-deprecated-declarations", 171 "-fno-asynchronous-unwind-tables", 172 "-fwrapv", 173 "-fstack-protector-all", 174 "-fPIE", 175 176 # various options we choose 177 "-DDEBUG_LEAKS", 178 "-DMKSH_ASSUME_UTF8", 179 "-DMKSH_DONT_EMIT_IDSTRING", 180 181 # and the defines from middleware file Rebuild.sh. 182 "-DMKSH_BUILDSH", 183 "-D_GNU_SOURCE", 184 "-DSETUID_CAN_FAIL_WITH_EAGAIN", 185 "-DHAVE_STRING_POOLING=2", 186 "-DHAVE_ATTRIBUTE_BOUNDED=0", 187 "-DHAVE_ATTRIBUTE_FORMAT=1", 188 "-DHAVE_ATTRIBUTE_NORETURN=1", 189 "-DHAVE_ATTRIBUTE_PURE=1", 190 "-DHAVE_ATTRIBUTE_UNUSED=1", 191 "-DHAVE_ATTRIBUTE_USED=1", 192 "-DHAVE_SYS_TIME_H=1", 193 "-DHAVE_TIME_H=1", 194 "-DHAVE_BOTH_TIME_H=1", 195 "-DHAVE_SYS_BSDTYPES_H=0", 196 "-DHAVE_SYS_FILE_H=1", 197 "-DHAVE_SYS_MKDEV_H=0", 198 "-DHAVE_SYS_MMAN_H=1", 199 "-DHAVE_SYS_PARAM_H=1", 200 "-DHAVE_SYS_RESOURCE_H=1", 201 "-DHAVE_SYS_SELECT_H=1", 202 "-DHAVE_SYS_SYSMACROS_H=1", 203 "-DHAVE_BSTRING_H=0", 204 "-DHAVE_GRP_H=1", 205 "-DHAVE_IO_H=0", 206 "-DHAVE_LIBGEN_H=1", 207 "-DHAVE_LIBUTIL_H=0", 208 "-DHAVE_PATHS_H=1", 209 "-DHAVE_STDINT_H=1", 210 "-DHAVE_STRINGS_H=1", 211 "-DHAVE_TERMIOS_H=1", 212 "-DHAVE_VALUES_H=1", 213 "-DHAVE_CAN_INTTYPES=1", 214 "-DHAVE_CAN_UCBINTS=1", 215 "-DHAVE_CAN_INT8TYPE=1", 216 "-DHAVE_CAN_UCBINT8=1", 217 "-DHAVE_RLIM_T=1", 218 "-DHAVE_SIG_T=1", 219 "-DHAVE_SYS_ERRLIST=1", 220 "-DHAVE_FLOCK=1", 221 "-DHAVE_LOCK_FCNTL=1", 222 "-DHAVE_GETRUSAGE=1", 223 "-DHAVE_GETSID=1", 224 "-DHAVE_GETTIMEOFDAY=1", 225 "-DHAVE_KILLPG=1", 226 "-DHAVE_MEMMOVE=1", 227 "-DHAVE_MKNOD=0", 228 "-DHAVE_MMAP=1", 229 "-DHAVE_FTRUNCATE=1", 230 "-DHAVE_NICE=1", 231 "-DHAVE_REVOKE=0", 232 "-DHAVE_SETLOCALE_CTYPE=1", 233 "-DHAVE_LANGINFO_CODESET=1", 234 "-DHAVE_SELECT=1", 235 "-DHAVE_SETRESUGID=1", 236 "-DHAVE_SETGROUPS=1", 237 "-DHAVE_STRERROR=1", 238 "-DHAVE_STRSIGNAL=0", 239 "-DHAVE_STRLCPY=0", 240 "-DHAVE_FLOCK_DECL=1", 241 "-DHAVE_REVOKE_DECL=1", 242 "-DHAVE_SYS_ERRLIST_DECL=1", 243 "-DHAVE_SYS_SIGLIST_DECL=1", 244 "-DHAVE_PERSISTENT_HISTORY=1", 245 "-DMKSH_UNLIMITED", 246 "-DMKSH_BUILD_R=593", 247 ] 248 ldflags = [ 249 "-pie", 250 "-Wl,-z,relro", 251 "-Wl,-z,now", 252 "-Wl,-z,noexecstack", 253 ] 254 install_images = [ 255 "system", 256 "ramdisk", 257 "updater", 258 ] 259 part_name = "init" 260 install_enable = true 261 } 262} 263