mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Implement system include detection for CMake build
The Bazel build already queries the current toolchain for its system include directories. This change brings feature parity and is necessary for systems with unusual include locations. PiperOrigin-RevId: 332195812 Change-Id: Ie81d614d21e90b4bd9edf2084ef80bf0d85dd750
This commit is contained in:
parent
a68b851c2c
commit
13c28403a6
|
@ -132,7 +132,6 @@ function(add_sapi_library)
|
||||||
set(_sapi_embed_dir "${CMAKE_CURRENT_BINARY_DIR}")
|
set(_sapi_embed_dir "${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
set(_sapi_embed_name "${_sapi_NAME}")
|
set(_sapi_embed_name "${_sapi_NAME}")
|
||||||
endif()
|
endif()
|
||||||
# TODO(cblichmann): Implement sapi_isystem
|
|
||||||
if(SAPI_ENABLE_GENERATOR)
|
if(SAPI_ENABLE_GENERATOR)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${_sapi_gen_header}"
|
OUTPUT "${_sapi_gen_header}"
|
||||||
|
@ -149,9 +148,14 @@ function(add_sapi_library)
|
||||||
VERBATIM
|
VERBATIM
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
|
set(_sapi_isystem "${_sapi_NAME}.isystem")
|
||||||
list_join(_sapi_full_inputs "," _sapi_full_inputs)
|
list_join(_sapi_full_inputs "," _sapi_full_inputs)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${_sapi_gen_header}"
|
OUTPUT "${_sapi_gen_header}" "${_sapi_isystem}"
|
||||||
|
COMMAND sh -c
|
||||||
|
"${CMAKE_CXX_COMPILER} -E -x c++ -v /dev/null 2>&1 | \
|
||||||
|
awk '/> search starts here:/{f=1;next}/^End of search/{f=0}f{print $1}' \
|
||||||
|
> \"${_sapi_isystem}\""
|
||||||
COMMAND "${SAPI_PYTHON3_EXECUTABLE}" -B
|
COMMAND "${SAPI_PYTHON3_EXECUTABLE}" -B
|
||||||
"${SAPI_SOURCE_DIR}/sandboxed_api/tools/generator2/sapi_generator.py"
|
"${SAPI_SOURCE_DIR}/sandboxed_api/tools/generator2/sapi_generator.py"
|
||||||
"--sapi_name=${_sapi_LIBRARY_NAME}"
|
"--sapi_name=${_sapi_LIBRARY_NAME}"
|
||||||
|
@ -160,8 +164,10 @@ function(add_sapi_library)
|
||||||
"--sapi_embed_name=${_sapi_embed_name}"
|
"--sapi_embed_name=${_sapi_embed_name}"
|
||||||
"--sapi_functions=${_sapi_funcs}"
|
"--sapi_functions=${_sapi_funcs}"
|
||||||
"--sapi_ns=${_sapi_NAMESPACE}"
|
"--sapi_ns=${_sapi_NAMESPACE}"
|
||||||
|
"--sapi_isystem=${_sapi_isystem}"
|
||||||
"--sapi_in=${_sapi_full_inputs}"
|
"--sapi_in=${_sapi_full_inputs}"
|
||||||
COMMENT "Generating interface"
|
COMMENT "Generating interface"
|
||||||
|
VERBATIM
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -254,9 +254,8 @@ def sapi_library(
|
||||||
native.genrule(
|
native.genrule(
|
||||||
name = name + ".isystem",
|
name = name + ".isystem",
|
||||||
outs = [name + ".isystem.list"],
|
outs = [name + ".isystem.list"],
|
||||||
cmd = """echo |
|
cmd = """$(CC) -E -x c++ -v /dev/null 2>&1 |
|
||||||
$(CC) -E -x c++ - -v 2>&1 |
|
awk '/> search starts here:/{f=1;next}/^End of search/{f=0}f{print $$1}' > $@
|
||||||
awk '/> search starts here:/{flag=1;next}/End of search/{flag=0}flag' > $@
|
|
||||||
""",
|
""",
|
||||||
toolchains = ["@bazel_tools//tools/cpp:current_cc_toolchain"],
|
toolchains = ["@bazel_tools//tools/cpp:current_cc_toolchain"],
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user