• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_m/liteos.gni")
31import("//third_party/optimized-routines/optimized-routines.gni")
32import("musl.gni")
33
34libc = "musl-c"
35libm = "musl-m"
36
37LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
38
39config("include") {
40  include_dirs = [ "include" ]
41}
42
43static_library(libc) {
44  sources = MUSL_LIBC_SRC
45
46  include_dirs = [
47    "src/include",
48    "src/internal",
49  ]
50
51  include_dirs += [
52    "//kernel/liteos_m/kernel/arch/include",
53    "//kernel/liteos_m/kernel/include",
54    "//kernel/liteos_m/utils",
55  ]
56
57  cflags = [
58    "-imacros",
59    "$LITEOS_MENUCONFIG_H",
60  ]
61
62  if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
63    sources += MUSL_LIBC_OPT_SRC_FOR_ARM
64    if (LOSCFG_ARCH_ARM_VER == "armv7-m" || LOSCFG_ARCH_ARM_VER == "armv8-m") {
65      sources -= [
66        "$MUSLPORTINGDIR/src/string/strcpy.c",
67        "$MUSLPORTINGDIR/src/string/strlen.c",
68      ]
69      sources += OPTRT_STRING_ARM_SRC_FILES_FOR_ARMV7_M
70      asmflags = [ "-D__strlen_armv6t2=strlen" ]
71      if (defined(LOSCFG_KERNEL_LMS)) {
72        asmflags += [ "-D__strcpy_arm=__strcpy" ]
73      } else {
74        asmflags += [ "-D__strcpy_arm=strcpy" ]
75      }
76
77      if (LOSCFG_ARCH_ARM_VER == "armv8-m") {
78        sources -= [
79          "$MUSLPORTINGDIR/src/string/memcmp.c",
80          "$MUSLPORTINGDIR/src/string/memset.c",
81        ]
82        sources += MUSL_LIBC_OPT_SRC_FOR_ARMV8_M
83      }
84
85      cflags += asmflags
86    }
87  }
88
89  public_configs = [ ":include" ]
90}
91
92static_library(libm) {
93  sources = MUSL_LIBM_SRC
94
95  include_dirs = [
96    "src/include",
97    "src/internal",
98  ]
99
100  public_configs = [ ":include" ]
101}
102
103group("kernel") {
104  public_deps = [
105    ":$libc",
106    ":$libm",
107  ]
108}
109