| // Copyright © 2010, 2013 | |
| // Thorsten Glaser <t.glaser@tarent.de> | |
| // This file is provided under the same terms as mksh. | |
| package { | |
| default_applicable_licenses: ["external_mksh_license"], | |
| } | |
| license { | |
| name: "external_mksh_license", | |
| visibility: [":__subpackages__"], | |
| license_kinds: [ | |
| "SPDX-license-identifier-BSD", | |
| "SPDX-license-identifier-MIT", | |
| "SPDX-license-identifier-Unicode-DFS", | |
| "legacy_notice", | |
| ], | |
| license_text: [ | |
| "NOTICE", | |
| ], | |
| } | |
| cc_defaults { | |
| name: "mksh_defaults", | |
| srcs: [ | |
| "src/lalloc.c", | |
| "src/edit.c", | |
| "src/eval.c", | |
| "src/exec.c", | |
| "src/expr.c", | |
| "src/funcs.c", | |
| "src/histrap.c", | |
| "src/jobs.c", | |
| "src/lex.c", | |
| "src/main.c", | |
| "src/misc.c", | |
| "src/shf.c", | |
| "src/syn.c", | |
| "src/tree.c", | |
| "src/ulimit.c", | |
| "src/var.c", | |
| ], | |
| local_include_dirs: ["src"], | |
| cflags: [ | |
| // Compiler flags... | |
| "-Wall", | |
| "-Werror", | |
| "-Wno-deprecated-declarations", | |
| "-fno-asynchronous-unwind-tables", | |
| "-fno-strict-aliasing", | |
| "-fwrapv", | |
| // ...various options we choose | |
| "-DDEBUG_LEAKS", | |
| "-DMKSH_ASSUME_UTF8", | |
| "-DMKSH_DONT_EMIT_IDSTRING", | |
| "-DKSH_VERSIONNAME_VENDOR_EXT=\" Android\"", | |
| ], | |
| stl: "none", | |
| target: { | |
| android: { | |
| system_shared_libs: ["libc"], | |
| cflags: [ | |
| // the defines from src/Rebuild.sh after running src/Build.sh on linux, with | |
| // manual edits for android. | |
| "-DMKSH_BUILDSH", | |
| "-D_GNU_SOURCE", | |
| "-DSETUID_CAN_FAIL_WITH_EAGAIN", | |
| "-DHAVE_STRING_POOLING=2", | |
| "-DHAVE_ATTRIBUTE_BOUNDED=1", | |
| "-DHAVE_ATTRIBUTE_FORMAT=1", | |
| "-DHAVE_ATTRIBUTE_NORETURN=1", | |
| "-DHAVE_ATTRIBUTE_PURE=1", | |
| "-DHAVE_ATTRIBUTE_UNUSED=1", | |
| "-DHAVE_ATTRIBUTE_USED=1", | |
| "-DHAVE_SYS_TIME_H=1", | |
| "-DHAVE_TIME_H=1", | |
| "-DHAVE_BOTH_TIME_H=1", | |
| "-DHAVE_SYS_BSDTYPES_H=0", | |
| "-DHAVE_SYS_FILE_H=1", | |
| "-DHAVE_SYS_MKDEV_H=0", | |
| "-DHAVE_SYS_MMAN_H=1", | |
| "-DHAVE_SYS_PARAM_H=1", | |
| "-DHAVE_SYS_RESOURCE_H=1", | |
| "-DHAVE_SYS_SELECT_H=1", | |
| "-DHAVE_SYS_SYSMACROS_H=1", | |
| "-DHAVE_BSTRING_H=0", | |
| "-DHAVE_GRP_H=1", | |
| "-DHAVE_IO_H=0", | |
| "-DHAVE_LIBGEN_H=1", | |
| "-DHAVE_LIBUTIL_H=0", | |
| "-DHAVE_PATHS_H=1", | |
| "-DHAVE_STDINT_H=1", | |
| "-DHAVE_STRINGS_H=1", | |
| "-DHAVE_TERMIOS_H=1", | |
| "-DHAVE_ULIMIT_H=0", | |
| "-DHAVE_VALUES_H=0", | |
| "-DHAVE_CAN_INTTYPES=1", | |
| "-DHAVE_CAN_UCBINTS=1", | |
| "-DHAVE_CAN_INT8TYPE=1", | |
| "-DHAVE_CAN_UCBINT8=1", | |
| "-DHAVE_SIG_T=1", | |
| "-DHAVE_SYS_ERRLIST=0", | |
| "-DHAVE_SYS_SIGNAME=1", | |
| "-DHAVE_SYS_SIGLIST=1", | |
| "-DHAVE_FLOCK=1", | |
| "-DHAVE_LOCK_FCNTL=1", | |
| "-DHAVE_RLIMIT=1", | |
| "-DHAVE_RLIM_T=1", | |
| "-DHAVE_GETRUSAGE=1", | |
| "-DHAVE_GETSID=1", | |
| "-DHAVE_GETTIMEOFDAY=1", | |
| "-DHAVE_KILLPG=1", | |
| "-DHAVE_MEMMOVE=1", | |
| "-DHAVE_MKNOD=0", | |
| "-DHAVE_MMAP=1", | |
| "-DHAVE_FTRUNCATE=1", | |
| "-DHAVE_NICE=1", | |
| "-DHAVE_REVOKE=0", | |
| "-DHAVE_SETLOCALE_CTYPE=1", | |
| "-DHAVE_LANGINFO_CODESET=1", | |
| "-DHAVE_SELECT=1", | |
| "-DHAVE_SETRESUGID=1", | |
| "-DHAVE_SETGROUPS=1", | |
| "-DHAVE_STRERROR=1", | |
| "-DHAVE_STRSIGNAL=1", | |
| "-DHAVE_STRLCPY=1", | |
| "-DHAVE_FLOCK_DECL=1", | |
| "-DHAVE_REVOKE_DECL=1", | |
| "-DHAVE_SYS_ERRLIST_DECL=0", | |
| "-DHAVE_SYS_SIGLIST_DECL=1", | |
| "-DHAVE_ST_MTIM=1", | |
| "-DHAVE_ST_MTIMENSEC=0", | |
| "-DHAVE_PERSISTENT_HISTORY=0", | |
| "-DMKSH_BUILD_R=593", | |
| // Additional flags | |
| "-DMKSH_DEFAULT_PROFILEDIR=\"/system/etc\"", | |
| "-DMKSHRC_PATH=\"/system/etc/mkshrc\"", | |
| "-DMKSH_DEFAULT_EXECSHELL=\"/system/bin/sh\"", | |
| "-DMKSH_DEFAULT_TMPDIR=\"/data/local\"", | |
| ], | |
| }, | |
| host_linux: { | |
| // glibc 2.38 technically supports strlcpy, but requires linking with -lbsd which | |
| // is more complicated than just using this implementation. | |
| srcs: [ | |
| "src/strlcpy.c", | |
| ], | |
| // for signames.inc, generated by Build.sh normally but checked in to the tree | |
| // for the soong build. The android build uses HAVE_SYS_SIGLIST and HAVE_SYS_SIGNAME | |
| // and the corresponding sys_siglist/sys_signame variables from bionic, but glibc | |
| // doesn't have those. | |
| local_include_dirs: ["android/linux"], | |
| cflags: [ | |
| // the defines from src/Rebuild.sh after running src/Build.sh on linux, | |
| // except I changed HAVE_STRLCPY to 0 and added strlcpy.c above. | |
| "-DMKSH_BUILDSH", | |
| "-D_GNU_SOURCE", | |
| "-DSETUID_CAN_FAIL_WITH_EAGAIN", | |
| "-DHAVE_STRING_POOLING=2", | |
| "-DHAVE_ATTRIBUTE_BOUNDED=0", | |
| "-DHAVE_ATTRIBUTE_FORMAT=1", | |
| "-DHAVE_ATTRIBUTE_NORETURN=1", | |
| "-DHAVE_ATTRIBUTE_PURE=1", | |
| "-DHAVE_ATTRIBUTE_UNUSED=1", | |
| "-DHAVE_ATTRIBUTE_USED=1", | |
| "-DHAVE_SYS_TIME_H=1", | |
| "-DHAVE_TIME_H=1", | |
| "-DHAVE_BOTH_TIME_H=1", | |
| "-DHAVE_SYS_BSDTYPES_H=0", | |
| "-DHAVE_SYS_FILE_H=1", | |
| "-DHAVE_SYS_MKDEV_H=0", | |
| "-DHAVE_SYS_MMAN_H=1", | |
| "-DHAVE_SYS_PARAM_H=1", | |
| "-DHAVE_SYS_RESOURCE_H=1", | |
| "-DHAVE_SYS_SELECT_H=1", | |
| "-DHAVE_SYS_SYSMACROS_H=1", | |
| "-DHAVE_BSTRING_H=0", | |
| "-DHAVE_GRP_H=1", | |
| "-DHAVE_IO_H=0", | |
| "-DHAVE_LIBGEN_H=1", | |
| "-DHAVE_LIBUTIL_H=0", | |
| "-DHAVE_PATHS_H=1", | |
| "-DHAVE_STDINT_H=1", | |
| "-DHAVE_STRINGS_H=1", | |
| "-DHAVE_TERMIOS_H=1", | |
| "-DHAVE_ULIMIT_H=1", | |
| "-DHAVE_VALUES_H=1", | |
| "-DHAVE_CAN_INTTYPES=1", | |
| "-DHAVE_CAN_UCBINTS=1", | |
| "-DHAVE_CAN_INT8TYPE=1", | |
| "-DHAVE_CAN_UCBINT8=1", | |
| "-DHAVE_SIG_T=1", | |
| "-DHAVE_SYS_ERRLIST=0", | |
| "-DHAVE_SYS_SIGNAME=0", | |
| "-DHAVE_SYS_SIGLIST=0", | |
| "-DHAVE_FLOCK=1", | |
| "-DHAVE_LOCK_FCNTL=1", | |
| "-DHAVE_RLIMIT=1", | |
| "-DHAVE_RLIM_T=1", | |
| "-DHAVE_GETRUSAGE=1", | |
| "-DHAVE_GETSID=1", | |
| "-DHAVE_GETTIMEOFDAY=1", | |
| "-DHAVE_KILLPG=1", | |
| "-DHAVE_MEMMOVE=1", | |
| "-DHAVE_MKNOD=0", | |
| "-DHAVE_MMAP=1", | |
| "-DHAVE_FTRUNCATE=1", | |
| "-DHAVE_NICE=1", | |
| "-DHAVE_REVOKE=0", | |
| "-DHAVE_SETLOCALE_CTYPE=1", | |
| "-DHAVE_LANGINFO_CODESET=1", | |
| "-DHAVE_SELECT=1", | |
| "-DHAVE_SETRESUGID=1", | |
| "-DHAVE_SETGROUPS=1", | |
| "-DHAVE_STRERROR=1", | |
| "-DHAVE_STRSIGNAL=1", | |
| "-DHAVE_STRLCPY=0", | |
| "-DHAVE_FLOCK_DECL=1", | |
| "-DHAVE_REVOKE_DECL=1", | |
| "-DHAVE_SYS_ERRLIST_DECL=0", | |
| "-DHAVE_SYS_SIGLIST_DECL=0", | |
| "-DHAVE_ST_MTIM=1", | |
| "-DHAVE_ST_MTIMENSEC=0", | |
| "-DHAVE_PERSISTENT_HISTORY=1", | |
| "-DMKSH_BUILD_R=593", | |
| ], | |
| }, | |
| darwin: { | |
| cflags: [ | |
| // the defines from src/Rebuild.sh after running src/Build.sh on mac. | |
| "-DMKSH_BUILDSH", | |
| "-D_DARWIN_C_SOURCE", | |
| "-DHAVE_STRING_POOLING=1", | |
| "-DHAVE_ATTRIBUTE_BOUNDED=1", | |
| "-DHAVE_ATTRIBUTE_FORMAT=1", | |
| "-DHAVE_ATTRIBUTE_NORETURN=1", | |
| "-DHAVE_ATTRIBUTE_PURE=1", | |
| "-DHAVE_ATTRIBUTE_UNUSED=1", | |
| "-DHAVE_ATTRIBUTE_USED=1", | |
| "-DHAVE_SYS_TIME_H=1", | |
| "-DHAVE_TIME_H=1", | |
| "-DHAVE_BOTH_TIME_H=1", | |
| "-DHAVE_SYS_BSDTYPES_H=0", | |
| "-DHAVE_SYS_FILE_H=1", | |
| "-DHAVE_SYS_MKDEV_H=0", | |
| "-DHAVE_SYS_MMAN_H=1", | |
| "-DHAVE_SYS_PARAM_H=1", | |
| "-DHAVE_SYS_RESOURCE_H=1", | |
| "-DHAVE_SYS_SELECT_H=1", | |
| "-DHAVE_SYS_SYSMACROS_H=0", | |
| "-DHAVE_BSTRING_H=0", | |
| "-DHAVE_GRP_H=1", | |
| "-DHAVE_IO_H=0", | |
| "-DHAVE_LIBGEN_H=1", | |
| "-DHAVE_LIBUTIL_H=0", | |
| "-DHAVE_PATHS_H=1", | |
| "-DHAVE_STDINT_H=1", | |
| "-DHAVE_STRINGS_H=1", | |
| "-DHAVE_TERMIOS_H=1", | |
| "-DHAVE_ULIMIT_H=1", | |
| "-DHAVE_VALUES_H=0", | |
| "-DHAVE_CAN_INTTYPES=1", | |
| "-DHAVE_CAN_UCBINTS=1", | |
| "-DHAVE_CAN_INT8TYPE=1", | |
| "-DHAVE_CAN_UCBINT8=1", | |
| "-DHAVE_SIG_T=1", | |
| "-DHAVE_SYS_ERRLIST=1", | |
| "-DHAVE_SYS_SIGNAME=1", | |
| "-DHAVE_SYS_SIGLIST=1", | |
| "-DHAVE_FLOCK=1", | |
| "-DHAVE_LOCK_FCNTL=1", | |
| "-DHAVE_RLIMIT=1", | |
| "-DHAVE_RLIM_T=1", | |
| "-DHAVE_GETRUSAGE=1", | |
| "-DHAVE_GETSID=1", | |
| "-DHAVE_GETTIMEOFDAY=1", | |
| "-DHAVE_KILLPG=1", | |
| "-DHAVE_MEMMOVE=1", | |
| "-DHAVE_MKNOD=0", | |
| "-DHAVE_MMAP=1", | |
| "-DHAVE_FTRUNCATE=1", | |
| "-DHAVE_NICE=1", | |
| "-DHAVE_REVOKE=1", | |
| "-DHAVE_SETLOCALE_CTYPE=1", | |
| "-DHAVE_LANGINFO_CODESET=1", | |
| "-DHAVE_SELECT=1", | |
| "-DHAVE_SETRESUGID=0", | |
| "-DHAVE_SETGROUPS=0", | |
| "-DHAVE_STRERROR=0", | |
| "-DHAVE_STRSIGNAL=0", | |
| "-DHAVE_STRLCPY=1", | |
| "-DHAVE_FLOCK_DECL=1", | |
| "-DHAVE_REVOKE_DECL=1", | |
| "-DHAVE_SYS_ERRLIST_DECL=1", | |
| "-DHAVE_SYS_SIGLIST_DECL=1", | |
| "-DHAVE_ST_MTIM=0", | |
| "-DHAVE_ST_MTIMENSEC=0", | |
| "-DHAVE_PERSISTENT_HISTORY=1", | |
| "-DMKSH_BUILD_R=593", | |
| ], | |
| }, | |
| }, | |
| } | |
| cc_binary { | |
| name: "sh", | |
| defaults: ["mksh_defaults"], | |
| vendor_ramdisk_available: true, | |
| host_supported: true, | |
| } | |
| cc_binary { | |
| name: "sh.recovery", | |
| defaults: ["mksh_defaults"], | |
| recovery: true, | |
| stem: "sh", | |
| } | |
| cc_binary { | |
| name: "sh_vendor", | |
| defaults: ["mksh_defaults"], | |
| stem: "sh", | |
| vendor: true, | |
| // Even though sh_vendor is only built for device these flags need to be in a target: android: | |
| // for ordering reasons with the flags from the default modules. | |
| target: { | |
| android: { | |
| cflags: [ | |
| // Additional flags for vendor variant | |
| "-UMKSH_DEFAULT_PROFILEDIR", | |
| "-UMKSHRC_PATH", | |
| "-UMKSH_DEFAULT_EXECSHELL", | |
| "-DMKSH_DEFAULT_PROFILEDIR=\"/vendor/etc\"", | |
| "-DMKSHRC_PATH=\"/vendor/etc/mkshrc\"", | |
| "-DMKSH_DEFAULT_EXECSHELL=\"/vendor/bin/sh\"", | |
| "-DMKSH_DEFPATH_OVERRIDE=\"/vendor/bin:/vendor/xbin\"", | |
| ], | |
| }, | |
| }, | |
| } | |
| // /system/etc/mkshrc | |
| prebuilt_etc { | |
| name: "mkshrc", | |
| src: "mkshrc", | |
| } | |
| // /vendor/etc/mkshrc | |
| prebuilt_etc { | |
| name: "mkshrc_vendor", | |
| src: "mkshrc_vendor", | |
| filename: "mkshrc", | |
| soc_specific: true, | |
| } |