1570af302Sopenharmony_ci# Copyright (c) 2023 Huawei Device Co., Ltd.
2570af302Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
3570af302Sopenharmony_ci# you may not use this file except in compliance with the License.
4570af302Sopenharmony_ci# You may obtain a copy of the License at
5570af302Sopenharmony_ci#
6570af302Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
7570af302Sopenharmony_ci#
8570af302Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
9570af302Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
10570af302Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11570af302Sopenharmony_ci# See the License for the specific language governing permissions and
12570af302Sopenharmony_ci# limitations under the License.
13570af302Sopenharmony_ci
14570af302Sopenharmony_ciimport("../../../test_template.gni")
15570af302Sopenharmony_ci
16570af302Sopenharmony_cirpath_configs = [
17570af302Sopenharmony_ci  "absolute",
18570af302Sopenharmony_ci  "origin",
19570af302Sopenharmony_ci]
20570af302Sopenharmony_ci
21570af302Sopenharmony_cigroup("rpath_ns_test") {
22570af302Sopenharmony_ci  testonly = true
23570af302Sopenharmony_ci  deps = [
24570af302Sopenharmony_ci    ":lib_primary_multiple",
25570af302Sopenharmony_ci    ":lib_support_001",
26570af302Sopenharmony_ci    ":lib_support_002",
27570af302Sopenharmony_ci    ":rpath_test",
28570af302Sopenharmony_ci  ]
29570af302Sopenharmony_ci  foreach(rp, rpath_configs) {
30570af302Sopenharmony_ci    deps += [ ":lib_primary_${rp}" ]
31570af302Sopenharmony_ci  }
32570af302Sopenharmony_ci}
33570af302Sopenharmony_ci
34570af302Sopenharmony_ciohos_executable("rpath_test") {
35570af302Sopenharmony_ci  subsystem_name = "musl"
36570af302Sopenharmony_ci  part_name = "libc-test"
37570af302Sopenharmony_ci  sources = [ "rpath_test.c" ]
38570af302Sopenharmony_ci  include_dirs = [
39570af302Sopenharmony_ci    "../common",
40570af302Sopenharmony_ci    "//third_party/musl/porting/linux/user/include",
41570af302Sopenharmony_ci    "//third_party/musl/libc-test/src/common",
42570af302Sopenharmony_ci  ]
43570af302Sopenharmony_ci  ldflags = [ "-Wl,-rpath=/data/tests/libc-test/src/rpath_lib" ]
44570af302Sopenharmony_ci  configs = [ "//third_party/musl/libc-test/src/common:config_runtest" ]
45570af302Sopenharmony_ci}
46570af302Sopenharmony_ci
47570af302Sopenharmony_ciforeach(rp, rpath_configs) {
48570af302Sopenharmony_ci  ohos_shared_library("lib_primary_${rp}") {
49570af302Sopenharmony_ci    sources = [ "lib_primary.c" ]
50570af302Sopenharmony_ci    output_name = "libprimary_${rp}"
51570af302Sopenharmony_ci    output_extension = "so"
52570af302Sopenharmony_ci    deps = [ ":lib_support_001" ]
53570af302Sopenharmony_ci    if (rp == "absolute") {
54570af302Sopenharmony_ci      ldflags =
55570af302Sopenharmony_ci          [ "-Wl,-rpath=/data/tests/libc-test/src/rpath_lib/rpath_support_A" ]
56570af302Sopenharmony_ci    } else if (rp == "origin") {
57570af302Sopenharmony_ci      ldflags = [ "-Wl,-rpath=\$ORIGIN/rpath_support_B/../rpath_support_A" ]
58570af302Sopenharmony_ci    }
59570af302Sopenharmony_ci    subsystem_name = "musl"
60570af302Sopenharmony_ci    part_name = "libc-test-lib"
61570af302Sopenharmony_ci  }
62570af302Sopenharmony_ci}
63570af302Sopenharmony_ci
64570af302Sopenharmony_ciohos_shared_library("lib_primary_multiple") {
65570af302Sopenharmony_ci  sources = [ "lib_primary_multiple.c" ]
66570af302Sopenharmony_ci  output_name = "libprimary_multiple"
67570af302Sopenharmony_ci  output_extension = "so"
68570af302Sopenharmony_ci  deps = [
69570af302Sopenharmony_ci    ":lib_support_001",
70570af302Sopenharmony_ci    ":lib_support_002",
71570af302Sopenharmony_ci  ]
72570af302Sopenharmony_ci  ldflags = [ "-Wl,-rpath=/data/tests/libc-test/src/rpath_lib/rpath_support_A:\$ORIGIN/../rpath_support_C" ]
73570af302Sopenharmony_ci  subsystem_name = "musl"
74570af302Sopenharmony_ci  part_name = "libc-test-lib"
75570af302Sopenharmony_ci}
76570af302Sopenharmony_ci
77570af302Sopenharmony_ciohos_shared_library("lib_support_001") {
78570af302Sopenharmony_ci  sources = [ "lib_support_001.c" ]
79570af302Sopenharmony_ci  output_name = "libsupport_001"
80570af302Sopenharmony_ci  output_extension = "so"
81570af302Sopenharmony_ci  subsystem_name = "musl"
82570af302Sopenharmony_ci  part_name = "libc-test-lib"
83570af302Sopenharmony_ci}
84570af302Sopenharmony_ci
85570af302Sopenharmony_ciohos_shared_library("lib_support_002") {
86570af302Sopenharmony_ci  sources = [ "lib_support_002.c" ]
87570af302Sopenharmony_ci  output_name = "libsupport_002"
88570af302Sopenharmony_ci  output_extension = "so"
89570af302Sopenharmony_ci  subsystem_name = "musl"
90570af302Sopenharmony_ci  part_name = "libc-test-lib"
91570af302Sopenharmony_ci}
92