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" 33 34import("//third_party/optimized-routines/optimized-routines.gni") 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 += OPTRT_STRING_ARM_SRC_FILES 58 asmflags = [ 59 "-D__strlen_armv6t2=strlen", 60 "-D__strcmp_arm=strcmp", 61 "-D__memchr_arm=memchr", 62 ] 63 if (defined(LOSCFG_KERNEL_LMS)) { 64 asmflags += [ 65 "-D__memcpy_arm=__memcpy", 66 "-D__strcpy_arm=__strcpy", 67 ] 68 } else { 69 asmflags += [ 70 "-D__memcpy_arm=memcpy", 71 "-D__strcpy_arm=strcpy", 72 ] 73 } 74 sources += [ 75 "src/arch/arm/memcmp.S", 76 "src/arch/arm/memset.S", 77 ] 78 } else { 79 sources += [ 80 "src/memcmp.c", 81 "src/memset.c", 82 ] 83 } 84 85 include_dirs = [ 86 "$MUSLPORTINGDIR/src/include", 87 "$MUSLPORTINGDIR/src/internal", 88 ] 89 90 public_configs = [ ":public" ] 91 configs += [ ":private" ] 92} 93 94config("public") { 95 cflags = [ 96 "-isystem", 97 rebase_path("$MUSLPORTINGDIR/include"), 98 ] 99} 100 101config("private") { 102 if (defined(LOSCFG_COMPILER_CLANG_LLVM)) { 103 cflags = [ 104 "-Wno-char-subscripts", 105 "-Wno-unknown-pragmas", 106 ] 107 } else { 108 cflags = [ 109 "-frounding-math", 110 "-Wno-unused-but-set-variable", 111 "-Wno-unknown-pragmas", 112 ] 113 } 114 115 cflags += [ 116 "-Wno-shift-op-parentheses", 117 "-Wno-logical-op-parentheses", 118 "-Wno-bitwise-op-parentheses", 119 ] 120} 121