Skip to content

Commit 1227bbe

Browse files
Sandboxed API Teamcopybara-github
authored andcommitted
Remove Python-based SAPI generator (version 1).
This change removes the deprecated Python-based code generator (generator_version=1) and all related build rules, release configurations, and documentation. The generator_version=1 is no longer supported in Bazel and CMake build systems. PiperOrigin-RevId: 903825693 Change-Id: I1182c6fde69336300c31684dabee13f490f90474
1 parent ee5f82b commit 1227bbe

8 files changed

Lines changed: 37 additions & 2412 deletions

File tree

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ sudo apt-get install -qy
9191

9292
#### LLVM
9393

94-
SAPI offers two header generators, based on
95-
[Python](tools/python_generator/BUILD) and
94+
SAPI offers a header generator based on
9695
[LLVM Libtooling](tools/clang_generator/BUILD).
9796

9897
We aim to provide support for at least the latest three LLVM release and

cmake/SapiBuildDefs.cmake

Lines changed: 33 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,14 @@ function(add_sapi_library)
9898
"${_sapi_one_value}" "${_sapi_multi_value}")
9999
set(_sapi_NAME "${ARGV0}")
100100

101-
if(_sapi_GENERATOR_VERSION AND (_sapi_GENERATOR_VERSION VERSION_LESS "1" OR _sapi_GENERATOR_VERSION VERSION_GREATER "3"))
102-
message(FATAL_ERROR "GENERATOR_VERSION must be \"1\", \"2\" or \"3\"")
101+
if(_sapi_GENERATOR_VERSION AND (_sapi_GENERATOR_VERSION VERSION_LESS "2" OR _sapi_GENERATOR_VERSION VERSION_GREATER "3"))
102+
message(FATAL_ERROR "GENERATOR_VERSION must be \"2\" or \"3\"")
103103
endif()
104104

105105
if(_sapi_GENERATOR_VERSION)
106106
set(_sapi_use_generator_version ${_sapi_GENERATOR_VERSION})
107107
else()
108-
if(SAPI_ENABLE_CLANG_TOOL)
109-
set(_sapi_use_generator_version "2")
110-
else()
111-
set(_sapi_use_generator_version "1")
112-
endif()
108+
set(_sapi_use_generator_version "2")
113109
endif()
114110

115111
set(_sapi_gen_header "${_sapi_NAME}.sapi.h")
@@ -187,60 +183,39 @@ function(add_sapi_library)
187183
"--sapi_functions=${_sapi_funcs}"
188184
"--sapi_ns=${_sapi_NAMESPACE}"
189185
)
190-
if(_sapi_use_generator_version VERSION_GREATER_EQUAL "2")
191-
if(_sapi_API_VERSION)
192-
list(APPEND _sapi_generator_args "--sapi_api_version=${_sapi_API_VERSION}")
193-
endif()
194-
if(_sapi_use_generator_version VERSION_EQUAL "3")
195-
list(APPEND _sapi_generator_args
196-
"--sapi_sandboxee_src_out=${_sapi_gen_sandboxee_src}"
197-
)
198-
endif()
199-
set(_sapi_isystem_args ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
200-
list(TRANSFORM _sapi_isystem_args PREPEND --extra-arg-before=-isystem)
201-
if(SAPI_CLANG_TOOL_EXECUTABLE)
202-
list(APPEND _sapi_generator_command "${SAPI_CLANG_TOOL_EXECUTABLE}")
203-
else()
204-
list(APPEND _sapi_generator_command sapi_generator_tool)
205-
endif()
206-
list(APPEND _sapi_generator_command
207-
-p "${CMAKE_CURRENT_BINARY_DIR}"
208-
${_sapi_generator_args}
209-
${_sapi_isystem_args}
210-
${_sapi_full_inputs}
211-
)
212-
list(APPEND _sapi_custom_command_output "${_sapi_gen_header}")
213-
if (_sapi_use_generator_version VERSION_EQUAL "3")
214-
list(APPEND _sapi_custom_command_output "${_sapi_gen_sandboxee_src}")
215-
endif()
216-
add_custom_command(
217-
OUTPUT ${_sapi_custom_command_output}
218-
COMMAND ${_sapi_generator_command}
219-
COMMENT "Generating interface"
220-
DEPENDS ${_sapi_INPUTS}
221-
VERBATIM
186+
187+
if(_sapi_API_VERSION)
188+
list(APPEND _sapi_generator_args "--sapi_api_version=${_sapi_API_VERSION}")
189+
endif()
190+
if(_sapi_use_generator_version VERSION_EQUAL "3")
191+
list(APPEND _sapi_generator_args
192+
"--sapi_sandboxee_src_out=${_sapi_gen_sandboxee_src}"
222193
)
194+
endif()
195+
set(_sapi_isystem_args ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
196+
list(TRANSFORM _sapi_isystem_args PREPEND --extra-arg-before=-isystem)
197+
if(SAPI_CLANG_TOOL_EXECUTABLE)
198+
list(APPEND _sapi_generator_command "${SAPI_CLANG_TOOL_EXECUTABLE}")
223199
else()
224-
set(_sapi_isystem "${_sapi_NAME}.isystem")
225-
list(JOIN _sapi_full_inputs "," _sapi_full_inputs)
226-
list(APPEND _sapi_generator_command
227-
"${SAPI_PYTHON3_EXECUTABLE}" -B
228-
"${SAPI_SOURCE_DIR}/sandboxed_api/tools/python_generator/sapi_generator.py"
229-
${_sapi_generator_args}
230-
"--sapi_isystem=${_sapi_isystem}"
231-
"--sapi_in=${_sapi_full_inputs}"
232-
)
233-
add_custom_command(
234-
OUTPUT "${_sapi_gen_header}" "${_sapi_isystem}"
235-
COMMAND sh -c
236-
"printf '${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}' | \
237-
sed \"s/;/\\n/g\" > \"${_sapi_isystem}\""
238-
COMMAND ${_sapi_generator_command}
239-
COMMENT "Generating interface"
240-
DEPENDS ${_sapi_INPUTS}
241-
VERBATIM
242-
)
200+
list(APPEND _sapi_generator_command sapi_generator_tool)
243201
endif()
202+
list(APPEND _sapi_generator_command
203+
-p "${CMAKE_CURRENT_BINARY_DIR}"
204+
${_sapi_generator_args}
205+
${_sapi_isystem_args}
206+
${_sapi_full_inputs}
207+
)
208+
list(APPEND _sapi_custom_command_output "${_sapi_gen_header}")
209+
if (_sapi_use_generator_version VERSION_EQUAL "3")
210+
list(APPEND _sapi_custom_command_output "${_sapi_gen_sandboxee_src}")
211+
endif()
212+
add_custom_command(
213+
OUTPUT ${_sapi_custom_command_output}
214+
COMMAND ${_sapi_generator_command}
215+
COMMENT "Generating interface"
216+
DEPENDS ${_sapi_INPUTS}
217+
VERBATIM
218+
)
244219

245220
# Library with the interface
246221
if(NOT _sapi_SOURCES)

sandboxed_api/bazel/sapi.bzl

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ def make_exec_label(label):
5555

5656
# buildifier: disable=function-docstring
5757
def select_generator(ctx):
58-
if ctx.attr.generator_version == 1:
59-
return ctx.executable._generator_v1
6058
return ctx.executable._generator_v2
6159

6260
def sort_deps(deps):
@@ -149,12 +147,8 @@ def _clang_format_file(src, out, **kwargs):
149147
)
150148

151149
def _sapi_interface_impl(ctx):
152-
if ctx.attr.generator_version == 1 and ctx.label.package not in [
153-
"sandboxed_api/tools/python_generator",
154-
"sandboxed_api/examples/stringop",
155-
]:
156-
# TODO(b/500992305): Remove this temporary check once the python code generator is completely deleted.
157-
fail("generator_version=1 is deprecated and cannot be used outside of internal tests.")
150+
if ctx.attr.generator_version == 1:
151+
fail("generator_version=1 is no longer supported.")
158152

159153
cpp_toolchain = find_cpp_toolchain(ctx)
160154
generator = select_generator(ctx)
@@ -265,10 +259,7 @@ sapi_interface = rule(
265259
),
266260
"generator_version": attr.int(
267261
default = 2, # Note: always set by sapi_library
268-
values = [1, 2, 3],
269-
),
270-
"_generator_v1": make_exec_label(
271-
"//sandboxed_api/tools/python_generator:sapi_generator",
262+
values = [2, 3],
272263
),
273264
"sandbox_mode": attr.string(default = "sandbox2"),
274265
"symbol_list_gen": attr.bool(default = False),

sandboxed_api/tools/python_generator/BUILD

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)