• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
64# sandboxed_api/sandbox2/util:pid_waiter
65add_library(sandbox2_util_pid_waiter ${SAPI_LIB_TYPE}
66  pid_waiter.cc
67  pid_waiter.h
68)
69add_library(sandbox2::pid_waiter ALIAS sandbox2_util_pid_waiter)
70target_link_libraries(sandbox2_util_pid_waiter
71  PUBLIC absl::core_headers
72         absl::cleanup
73         absl::synchronization
74         absl::time
75         sandbox2::deadline_manager
76  PRIVATE sapi::base
77)
78
79
80# sandboxed_api/sandbox2/util:deadline_manager
81add_library(sandbox2_util_deadline_manager ${SAPI_LIB_TYPE}
82  deadline_manager.cc
83  deadline_manager.h
84)
85add_library(sandbox2::deadline_manager ALIAS sandbox2_util_deadline_manager)
86target_link_libraries(sandbox2_util_deadline_manager
87  PUBLIC absl::btree
88         absl::core_headers
89         absl::flags
90         absl::function_ref
91         absl::no_destructor
92         absl::strings
93         absl::synchronization
94         absl::time
95         sapi::thread
96  PRIVATE absl::base
97          absl::check
98          absl::log
99          absl::strings
100          sandbox2::util
101          sapi::base
102)
103
104if(BUILD_TESTING AND SAPI_BUILD_TESTING)
105  # sandboxed_api/sandbox2/util:minielf_test
106  add_executable(sandbox2_minielf_test
107    minielf_test.cc
108  )
109  set_target_properties(sandbox2_minielf_test PROPERTIES
110    OUTPUT_NAME minielf_test
111  )
112  configure_file(testdata/hello_world
113                 testdata/hello_world COPYONLY)
114  configure_file(testdata/chrome_grte_header
115                 testdata/chrome_grte_header COPYONLY)
116  target_link_libraries(sandbox2_minielf_test
117    PRIVATE absl::algorithm_container
118            absl::statusor
119            sapi::file_helpers
120            sandbox2::maps_parser
121            sandbox2::minielf
122            sapi::testing
123            sapi::status_matchers
124            sapi::test_main
125    PUBLIC absl::statusor
126  )
127  gtest_discover_tests_xcompile(sandbox2_minielf_test PROPERTIES
128    ENVIRONMENT "TEST_TMPDIR=/tmp"
129    ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
130  )
131
132  # sandboxed_api/sandbox2/util:maps_parser_test
133  add_executable(sandbox2_maps_parser_test
134    maps_parser_test.cc
135  )
136  set_target_properties(sandbox2_maps_parser_test PROPERTIES
137    OUTPUT_NAME maps_parser_test
138  )
139  target_link_libraries(sandbox2_maps_parser_test PRIVATE
140    absl::statusor
141    sandbox2::maps_parser
142    sapi::status_matchers
143    sapi::test_main
144  )
145  gtest_discover_tests_xcompile(sandbox2_maps_parser_test)
146
147  # sandboxed_api/sandbox2/util:bpf_helper_test
148  add_executable(sandbox2_bpf_helper_test
149    bpf_helper_test.cc
150  )
151  set_target_properties(sandbox2_bpf_helper_test PROPERTIES
152    OUTPUT_NAME bpf_helper_test
153  )
154  target_link_libraries(sandbox2_bpf_helper_test PRIVATE
155    absl::strings
156    sandbox2::bpf_helper
157    sapi::test_main
158  )
159  gtest_discover_tests_xcompile(sandbox2_bpf_helper_test)
160
161  # sandboxed_api/sandbox2/util:pid_waiter_test
162  add_executable(sandbox2_pid_waiter_test
163    pid_waiter_test.cc
164  )
165  set_target_properties(sandbox2_pid_waiter_test PROPERTIES
166    OUTPUT_NAME pid_waiter_test
167  )
168  target_link_libraries(sandbox2_pid_waiter_test PRIVATE
169    absl::time
170    sandbox2::pid_waiter
171    sapi::test_main
172    sapi::thread
173  )
174
175  # sandboxed_api/sandbox2/util:deadline_manager_test
176  add_executable(sandbox2_deadline_manager_test
177    deadline_manager_test.cc
178  )
179  set_target_properties(sandbox2_deadline_manager_test PROPERTIES
180    OUTPUT_NAME deadline_manager_test
181  )
182  target_link_libraries(sandbox2_deadline_manager_test PRIVATE
183    absl::check
184    absl::flags
185    absl::time
186    sandbox2::deadline_manager
187    sapi::test_main
188    sapi::thread
189  )
190  gtest_discover_tests_xcompile(sandbox2_deadline_manager_test)
191endif()
192