1570af302Sopenharmony_ci# Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
2570af302Sopenharmony_ci#
3570af302Sopenharmony_ci# Redistribution and use in source and binary forms, with or without modification,
4570af302Sopenharmony_ci# are permitted provided that the following conditions are met:
5570af302Sopenharmony_ci#
6570af302Sopenharmony_ci# 1. Redistributions of source code must retain the above copyright notice, this list of
7570af302Sopenharmony_ci#    conditions and the following disclaimer.
8570af302Sopenharmony_ci#
9570af302Sopenharmony_ci# 2. Redistributions in binary form must reproduce the above copyright notice, this list
10570af302Sopenharmony_ci#    of conditions and the following disclaimer in the documentation and/or other materials
11570af302Sopenharmony_ci#    provided with the distribution.
12570af302Sopenharmony_ci#
13570af302Sopenharmony_ci# 3. Neither the name of the copyright holder nor the names of its contributors may be used
14570af302Sopenharmony_ci#    to endorse or promote products derived from this software without specific prior written
15570af302Sopenharmony_ci#    permission.
16570af302Sopenharmony_ci#
17570af302Sopenharmony_ci# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18570af302Sopenharmony_ci# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
19570af302Sopenharmony_ci# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20570af302Sopenharmony_ci# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21570af302Sopenharmony_ci# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22570af302Sopenharmony_ci# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23570af302Sopenharmony_ci# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24570af302Sopenharmony_ci# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25570af302Sopenharmony_ci# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26570af302Sopenharmony_ci# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27570af302Sopenharmony_ci# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28570af302Sopenharmony_ci
29570af302Sopenharmony_ciimport("//kernel/uniproton/uniproton.gni")
30570af302Sopenharmony_ciimport("//third_party/optimized-routines/optimized-routines.gni")
31570af302Sopenharmony_ciimport("musl.gni")
32570af302Sopenharmony_ci
33570af302Sopenharmony_cilibc = "musl-c"
34570af302Sopenharmony_cilibm = "musl-m"
35570af302Sopenharmony_ci
36570af302Sopenharmony_ciMENUCONFIG_H = rebase_path("$root_out_dir/config.h")
37570af302Sopenharmony_ci
38570af302Sopenharmony_ciconfig("include") {
39570af302Sopenharmony_ci  include_dirs = [ "include" ]
40570af302Sopenharmony_ci}
41570af302Sopenharmony_ci
42570af302Sopenharmony_cistatic_library(libc) {
43570af302Sopenharmony_ci  sources = MUSL_LIBC_SRC
44570af302Sopenharmony_ci
45570af302Sopenharmony_ci  include_dirs = [
46570af302Sopenharmony_ci    "src/include",
47570af302Sopenharmony_ci    "src/internal",
48570af302Sopenharmony_ci  ]
49570af302Sopenharmony_ci
50570af302Sopenharmony_ci  include_dirs += [
51570af302Sopenharmony_ci    "//kernel/uniproton/src/core/kernel/include",
52570af302Sopenharmony_ci    "//kernel/uniproton/src/utility/lib/include",
53570af302Sopenharmony_ci    "//kernel/uniproton/src/arch/include",
54570af302Sopenharmony_ci    "//kernel/uniproton/src/om/include",
55570af302Sopenharmony_ci    "//kernel/uniproton/src/mem/include",
56570af302Sopenharmony_ci  ]
57570af302Sopenharmony_ci
58570af302Sopenharmony_ci  cflags = [
59570af302Sopenharmony_ci    "-imacros",
60570af302Sopenharmony_ci    "$MENUCONFIG_H",
61570af302Sopenharmony_ci  ]
62570af302Sopenharmony_ci
63570af302Sopenharmony_ci  sources += MUSL_LIBC_OPT_SRC_FOR_ARM
64570af302Sopenharmony_ci  if (defined(OS_ARCH_ARMV7_M)) {
65570af302Sopenharmony_ci    sources -= [
66570af302Sopenharmony_ci      "$MUSLPORTINGDIR/src/string/strcpy.c",
67570af302Sopenharmony_ci      "$MUSLPORTINGDIR/src/string/strlen.c",
68570af302Sopenharmony_ci    ]
69570af302Sopenharmony_ci    sources += OPTRT_STRING_ARM_SRC_FILES_FOR_ARMV7_M
70570af302Sopenharmony_ci    asmflags = [
71570af302Sopenharmony_ci      "-D__strlen_armv6t2=strlen",
72570af302Sopenharmony_ci      "-D__strcpy_arm=strcpy",
73570af302Sopenharmony_ci    ]
74570af302Sopenharmony_ci    cflags += asmflags
75570af302Sopenharmony_ci  }
76570af302Sopenharmony_ci
77570af302Sopenharmony_ci  public_configs = [ ":include" ]
78570af302Sopenharmony_ci}
79570af302Sopenharmony_ci
80570af302Sopenharmony_cistatic_library(libm) {
81570af302Sopenharmony_ci  sources = MUSL_LIBM_SRC
82570af302Sopenharmony_ci
83570af302Sopenharmony_ci  include_dirs = [
84570af302Sopenharmony_ci    "src/include",
85570af302Sopenharmony_ci    "src/internal",
86570af302Sopenharmony_ci  ]
87570af302Sopenharmony_ci
88570af302Sopenharmony_ci  public_configs = [ ":include" ]
89570af302Sopenharmony_ci}
90570af302Sopenharmony_ci
91570af302Sopenharmony_cigroup("kernel") {
92570af302Sopenharmony_ci  public_deps = [
93570af302Sopenharmony_ci    ":$libc",
94570af302Sopenharmony_ci    ":$libm",
95570af302Sopenharmony_ci  ]
96570af302Sopenharmony_ci}
97