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