mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
88c980218f
We need to add the `oss-internship-2020` and `examples/hello_sapi` directories to `.bazelignore`, so that `bazel build ...` works on a clean working copy. This is because the Bazel builds in these directories use their own `WORKSPACE.bazel` and this does not nest well, leading to all kinds of hard to debug errors. PiperOrigin-RevId: 333728800 Change-Id: Ie2e68dd39bf6f8eb21af29d8ae3ae12971b408db
59 lines
1.6 KiB
Python
59 lines
1.6 KiB
Python
# Copyright 2020 Google LLC
|
|
#
|
|
# 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.
|
|
|
|
load(
|
|
"@com_google_sandboxed_api//sandboxed_api/bazel:sapi.bzl",
|
|
"sapi_library",
|
|
)
|
|
|
|
# Library with code that should be sandboxed
|
|
cc_library(
|
|
name = "hello_lib",
|
|
srcs = ["hello_lib.cc"],
|
|
alwayslink = 1,
|
|
)
|
|
|
|
# Sandboxed API for the library above
|
|
sapi_library(
|
|
name = "hello_sapi",
|
|
functions = [
|
|
"AddTwoIntegers",
|
|
],
|
|
input_files = ["hello_lib.cc"],
|
|
lib = ":hello_lib",
|
|
lib_name = "Hello",
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
# Main executable demonstrating how the sandboxed library is used
|
|
cc_binary(
|
|
name = "hello",
|
|
srcs = ["hello_main.cc"],
|
|
deps = [":hello_sapi"],
|
|
)
|
|
|
|
# Another example using the same library, but using the Transaction API that
|
|
# automatically retries sandbox operations. Also demonstates error handling
|
|
# and a custom security policy.
|
|
cc_binary(
|
|
name = "hello_transacted",
|
|
srcs = ["hello_transacted.cc"],
|
|
deps = [
|
|
":hello_sapi",
|
|
"@com_google_absl//absl/memory",
|
|
"@com_google_absl//absl/status",
|
|
"@com_google_sandboxed_api//sandboxed_api/util:status",
|
|
],
|
|
)
|