Add CMake builds for the examples

PiperOrigin-RevId: 252045309
Change-Id: I57ffc3debbe64010b1f20b2e6df900b9916fa37f
This commit is contained in:
Christian Blichmann 2019-06-07 07:27:06 -07:00 committed by Copybara-Service
parent f2c7f976cf
commit dfbfb5cc43
9 changed files with 228 additions and 5 deletions

View File

@ -65,6 +65,7 @@ find_package(gflags REQUIRED)
find_package(glog REQUIRED)
find_package(Protobuf REQUIRED)
find_package(Libcap REQUIRED)
find_package(ZLIB REQUIRED)
# Make Bazel-like includes work
configure_file(cmake/libcap_capability.h.in

View File

@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
add_subdirectory(examples)
add_subdirectory(testcases)
add_subdirectory(unwind)
add_subdirectory(util)
@ -467,11 +468,11 @@ add_library(sandbox2_forkingclient STATIC
forkingclient.h
)
add_library(sandbox2::forkingclient ALIAS sandbox2_forkingclient)
target_link_libraries(sandbox2_forkingclient PRIVATE
absl::memory
sandbox2::client
sandbox2::forkserver
sapi::base
target_link_libraries(sandbox2_forkingclient
PRIVATE absl::memory
sandbox2::forkserver
sapi::base
PUBLIC sandbox2::client
)
# sandboxed_api/sandbox2:util

View File

@ -0,0 +1,19 @@
# Copyright 2019 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
add_subdirectory(crc4)
add_subdirectory(custom_fork)
add_subdirectory(static)
add_subdirectory(tool)
add_subdirectory(zlib)

View File

@ -0,0 +1,45 @@
# Copyright 2019 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# sandboxed_api/sandbox2/examples/crc4:crc4sandbox
add_executable(sandbox2_crc4sandbox
crc4sandbox.cc
)
add_executable(sandbox2::crc4sandbox ALIAS sandbox2_crc4sandbox)
add_dependencies(sandbox2_crc4sandbox
sandbox2::crc4bin
)
target_link_libraries(sandbox2_crc4sandbox PRIVATE
absl::memory
sandbox2::bpf_helper
sandbox2::comms
sandbox2::runfiles
sandbox2::sandbox2
sapi::base
sapi::flags
)
# sandboxed_api/sandbox2/examples/crc4:crc4bin
add_executable(crc4bin
crc4bin.cc
)
add_executable(sandbox2::crc4bin ALIAS crc4bin)
target_link_libraries(crc4bin PRIVATE
absl::core_headers
sandbox2::client
sandbox2::comms
sandbox2::util
sapi::base
sapi::flags
)

View File

@ -0,0 +1,47 @@
# Copyright 2019 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# sandboxed_api/sandbox2/examples/custom_fork:custom_fork_sandbox
add_executable(sandbox2_custom_fork_sandbox
custom_fork_sandbox.cc
)
add_executable(sandbox2::custom_fork_sandbox ALIAS sandbox2_custom_fork_sandbox)
add_dependencies(sandbox2_custom_fork_sandbox
sandbox2::custom_fork_bin
)
target_link_libraries(sandbox2_custom_fork_sandbox PRIVATE
absl::core_headers
absl::memory
sandbox2::comms
sandbox2::forkserver
sandbox2::runfiles
sandbox2::sandbox2
sapi::base
sapi::flags
sapi::raw_logging
)
# sandboxed_api/sandbox2/examples/custom_fork:custom_fork_bin
add_executable(custom_fork_bin
custom_fork_bin.cc
)
add_executable(sandbox2::custom_fork_bin ALIAS custom_fork_bin)
target_link_libraries(custom_fork_bin PRIVATE
sandbox2::comms
sandbox2::forkingclient
sandbox2::util
sapi::base
sapi::flags
sapi::raw_logging
)

View File

@ -0,0 +1,40 @@
# Copyright 2019 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# sandboxed_api/sandbox2/examples/static:static_sandbox
add_executable(sandbox2_static_sandbox
static_sandbox.cc
)
add_executable(sandbox2::static_sandbox ALIAS sandbox2_static_sandbox)
add_dependencies(sandbox2_static_sandbox
sandbox2::static_bin
)
target_link_libraries(sandbox2_static_sandbox PRIVATE
absl::memory
sandbox2::bpf_helper
sandbox2::runfiles
sandbox2::sandbox2
sapi::base
sapi::flags
)
# sandboxed_api/sandbox2/examples/static:static_bin
add_executable(static_bin
static_bin.cc
)
add_executable(sandbox2::static_bin ALIAS static_bin)
target_link_libraries(static_bin PRIVATE
sapi::base
-static # Fully static link
)

View File

@ -0,0 +1,28 @@
# Copyright 2019 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# sandboxed_api/sandbox2/examples/tools:sandbox2tool
add_executable(sandbox2_sandbox2tool
sandbox2tool.cc
)
add_executable(sandbox2::sandbox2tool ALIAS sandbox2_sandbox2tool)
target_link_libraries(sandbox2_sandbox2tool PRIVATE
absl::memory
absl::strings
sandbox2::bpf_helper
sandbox2::sandbox2
sandbox2::util
sapi::base
sapi::flags
)

View File

@ -0,0 +1,41 @@
# Copyright 2019 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# sandboxed_api/sandbox2/examples/zlib:zpipe_sandbox
add_executable(sandbox2_zpipe_sandbox
zpipe_sandbox.cc
)
add_executable(sandbox2::zpipe_sandbox ALIAS sandbox2_zpipe_sandbox)
add_dependencies(sandbox2_zpipe_sandbox
sandbox2::zpipe
)
target_link_libraries(sandbox2_zpipe_sandbox PRIVATE
absl::memory
sandbox2::bpf_helper
sandbox2::comms
sandbox2::runfiles
sandbox2::sandbox2
sapi::base
sapi::flags
)
# sandboxed_api/sandbox2/examples/zlib:zpipe
add_executable(zpipe
zpipe.c
)
add_executable(sandbox2::zpipe ALIAS zpipe)
target_link_libraries(zpipe PRIVATE
ZLIB::ZLIB
-static # Fully static link
)

View File

@ -58,6 +58,7 @@ std::unique_ptr<sandbox2::Policy> GetPolicy() {
.AllowSystemMalloc()
.AllowExit()
.EnableNamespaces()
.BlockSyscallWithErrno(__NR_access, ENOENT)
.BuildOrDie();
}