xref: /aosp_15_r20/external/sandboxed-api/sandboxed_api/sandbox2/util/CMakeLists.txt (revision ec63e07ab9515d95e79c211197c445ef84cefa6a)
1# Copyright 2019 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# sandboxed_api/sandbox2/util:bpf_helper
16add_library(sandbox2_util_bpf_helper ${SAPI_LIB_TYPE}
17  bpf_helper.c
18  bpf_helper.h
19)
20add_library(sandbox2::bpf_helper ALIAS sandbox2_util_bpf_helper)
21target_link_libraries(sandbox2_util_bpf_helper PRIVATE
22  sapi::base
23)
24
25# sandboxed_api/sandbox2/util:minielf
26add_library(sandbox2_util_minielf ${SAPI_LIB_TYPE}
27  minielf.cc
28  minielf.h
29)
30add_library(sandbox2::minielf ALIAS sandbox2_util_minielf)
31target_link_libraries(sandbox2_util_minielf PRIVATE
32  absl::status
33  absl::strings
34  sandbox2::util
35  sapi::base
36  sapi::raw_logging
37)
38
39# sandboxed_api/sandbox2/util:maps_parser
40add_library(sandbox2_util_maps_parser ${SAPI_LIB_TYPE}
41  maps_parser.cc
42  maps_parser.h
43)
44add_library(sandbox2::maps_parser ALIAS sandbox2_util_maps_parser)
45target_link_libraries(sandbox2_util_maps_parser
46  PRIVATE absl::status
47          absl::strings
48          sapi::base
49  PUBLIC absl::statusor
50)
51
52# sandboxed_api/sandbox2/util:syscall_trap
53add_library(sandbox2_util_syscall_trap ${SAPI_LIB_TYPE}
54  syscall_trap.cc
55  syscall_trap.h
56)
57add_library(sandbox2::syscall_trap ALIAS sandbox2_util_syscall_trap)
58target_link_libraries(sandbox2_util_syscall_trap
59  PRIVATE absl::check
60          sapi::base
61          sapi::config
62)
63
64if(BUILD_TESTING AND SAPI_BUILD_TESTING)
65  # sandboxed_api/sandbox2/util:minielf_test
66  add_executable(sandbox2_minielf_test
67    minielf_test.cc
68  )
69  set_target_properties(sandbox2_minielf_test PROPERTIES
70    OUTPUT_NAME minielf_test
71  )
72  configure_file(testdata/hello_world
73                 testdata/hello_world COPYONLY)
74  configure_file(testdata/chrome_grte_header
75                 testdata/chrome_grte_header COPYONLY)
76  target_link_libraries(sandbox2_minielf_test
77    PRIVATE absl::algorithm_container
78            absl::statusor
79            sapi::file_helpers
80            sandbox2::maps_parser
81            sandbox2::minielf
82            sapi::testing
83            sapi::status_matchers
84            sapi::test_main
85    PUBLIC absl::statusor
86  )
87  gtest_discover_tests_xcompile(sandbox2_minielf_test PROPERTIES
88    ENVIRONMENT "TEST_TMPDIR=/tmp"
89    ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
90  )
91
92  # sandboxed_api/sandbox2/util:maps_parser_test
93  add_executable(sandbox2_maps_parser_test
94    maps_parser_test.cc
95  )
96  set_target_properties(sandbox2_maps_parser_test PROPERTIES
97    OUTPUT_NAME maps_parser_test
98  )
99  target_link_libraries(sandbox2_maps_parser_test PRIVATE
100    absl::statusor
101    sandbox2::maps_parser
102    sapi::status_matchers
103    sapi::test_main
104  )
105  gtest_discover_tests_xcompile(sandbox2_maps_parser_test)
106endif()
107