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 30import("//kernel/liteos_a/liteos.gni") 31 32MUSLDIR = "$LITEOSTHIRDPARTY/musl" 33 34import("//third_party/optimized-routines/optimized-routines.gni") 35import("$MUSLDIR/porting/liteos_a/kernel/musl.gni") 36 37module_switch = defined(LOSCFG_LIBC_MUSL) 38module_name = get_path_info(rebase_path("."), "name") 39kernel_module(module_name) { 40 sources = MUSL_SRC_COMMON 41 42 if (defined(LOSCFG_ARCH_ARM_AARCH32)) { 43 sources += MUSL_SRC_ARM 44 foreach(f, MUSL_SRC_ARM) { 45 sources -= [ string_replace(f, "/arm/", "/") ] 46 } 47 } 48 49 if (LOSCFG_ARCH_ARM_VER == "armv7-a") { 50 sources -= [ 51 "$MUSLPORTINGDIR/src/string/memchr.c", 52 "$MUSLPORTINGDIR/src/string/memcpy.c", 53 "$MUSLPORTINGDIR/src/string/strcmp.c", 54 "$MUSLPORTINGDIR/src/string/strcpy.c", 55 "$MUSLPORTINGDIR/src/string/strlen.c", 56 ] 57 sources += [ 58 "src/arch/arm/memcmp.S", 59 "src/arch/arm/memset.S", 60 ] 61 sources += OPTRT_STRING_ARM_SRC_FILES_FOR_ARMV7_A 62 asmflags = [ 63 "-D__strlen_armv6t2=strlen", 64 "-D__strcmp_arm=strcmp", 65 "-D__memchr_arm=memchr", 66 ] 67 if (defined(LOSCFG_KERNEL_LMS)) { 68 asmflags += [ 69 "-D__memcpy_arm=__memcpy", 70 "-D__strcpy_arm=__strcpy", 71 ] 72 } else { 73 asmflags += [ 74 "-D__memcpy_arm=memcpy", 75 "-D__strcpy_arm=strcpy", 76 ] 77 } 78 } else { 79 # arch is not armv7-a 80 sources += [ 81 "src/memcmp.c", 82 "src/memset.c", 83 ] 84 } 85 86 include_dirs = [ 87 "$MUSLPORTINGDIR/src/include", 88 "$MUSLPORTINGDIR/src/internal", 89 ] 90 91 public_configs = [ ":public" ] 92 configs += [ ":private" ] 93} 94 95config("public") { 96 cflags = [ 97 "-isystem", 98 rebase_path("$MUSLPORTINGDIR/include"), 99 ] 100} 101 102config("private") { 103 if (defined(LOSCFG_COMPILER_CLANG_LLVM)) { 104 cflags = [ 105 "-Wno-char-subscripts", 106 "-Wno-ignored-pragmas", 107 "-Wno-strict-prototypes", 108 ] 109 } else { 110 cflags = [ 111 "-frounding-math", 112 "-Wno-unused-but-set-variable", 113 ] 114 } 115 116 cflags += [ 117 "-Wno-shift-op-parentheses", 118 "-Wno-logical-op-parentheses", 119 "-Wno-bitwise-op-parentheses", 120 "-Wno-unknown-pragmas", 121 ] 122} 123