@@ -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)
0 commit comments