1# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. 2# Copyright (c) 2020-2021 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" 33OPTRTDIR = "$LITEOSTHIRDPARTY/optimized-routines" 34 35import("$MUSLDIR/porting/liteos_a/kernel/musl.gni") 36 37module_switch = defined(LOSCFG_LIB_LIBC) 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 "$OPTRTDIR/string/arm/memchr.S", 59 "$OPTRTDIR/string/arm/memcpy.S", 60 "$OPTRTDIR/string/arm/strcmp.S", 61 "$OPTRTDIR/string/arm/strcpy.c", 62 "$OPTRTDIR/string/arm/strlen-armv6t2.S", 63 ] 64 asmflags = [ 65 "-D__strlen_armv6t2=strlen", 66 "-D__strcpy_arm=strcpy", 67 "-D__strcmp_arm=strcmp", 68 "-D__memcpy_arm=memcpy", 69 "-D__memchr_arm=memchr", 70 ] 71 sources += [ 72 "src/arch/arm/memset.S", 73 "src/arch/arm/memcmp.S", 74 ] 75 } else { 76 sources += [ 77 "src/memset.c", 78 "src/memcmp.c", 79 ] 80 } 81 82 include_dirs = [ 83 "$MUSLPORTINGDIR/src/include", 84 "$MUSLPORTINGDIR/src/internal", 85 ] 86 87 public_configs = [ ":public" ] 88 configs += [ ":private" ] 89} 90 91config("public") { 92 cflags = [ 93 "-isystem", 94 rebase_path("$MUSLPORTINGDIR/include"), 95 ] 96} 97 98config("private") { 99 if (defined(LOSCFG_COMPILER_CLANG_LLVM)) { 100 cflags = [ 101 "-Wno-char-subscripts", 102 "-Wno-unknown-pragmas", 103 ] 104 } else { 105 cflags = [ 106 "-frounding-math", 107 "-Wno-unused-but-set-variable", 108 "-Wno-unknown-pragmas", 109 ] 110 } 111 112 cflags += [ 113 "-Wno-shift-op-parentheses", 114 "-Wno-logical-op-parentheses", 115 "-Wno-bitwise-op-parentheses", 116 ] 117} 118