@@ -30,6 +30,7 @@ include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/linux.cmake)
3030include ( ${CMAKE_CURRENT_SOURCE_DIR} /cmake/macos.cmake)
3131include ( ${CMAKE_CURRENT_SOURCE_DIR} /cmake/web.cmake)
3232include ( ${CMAKE_CURRENT_SOURCE_DIR} /cmake/windows.cmake)
33+ include ( ${CMAKE_CURRENT_SOURCE_DIR} /cmake/python_callouts.cmake)
3334
3435# Detect number of processors 
3536include (ProcessorCount)
@@ -109,7 +110,9 @@ function( godotcpp_options )
109110 #TODO threads 
110111 #TODO compiledb 
111112 #TODO compiledb_file 
112-  #TODO build_profile 
113+ 
114+  set ( GODOT_BUILD_PROFILE ""  CACHE  PATH 
115+  "Path to a file containing a feature build profile"  )
113116
114117 set (GODOT_USE_HOT_RELOAD ""  CACHE  BOOL 
115118 "Enable the extra accounting required to support hot reload. (ON|OFF)" )
@@ -193,40 +196,47 @@ function( godotcpp_generate )
193196 set (GODOT_SYSTEM_HEADERS_ATTRIBUTE SYSTEM )
194197 endif  ()
195198
196-  #[[ Generate Bindings ]] 
197-  if (NOT  DEFINED  BITS)
198-  set (BITS 32)
199-  if (CMAKE_SIZEOF_VOID_P  EQUAL  8)
200-  set (BITS 64)
201-  endif (CMAKE_SIZEOF_VOID_P  EQUAL  8)
199+  #[[ Configure Binding Variables ]] 
200+  # Generate Binding Parameters (True|False) 
201+  set ( USE_TEMPLATE_GET_NODE "False"  )
202+  if ( GODOT_GENERATE_TEMPLATE_GET_NODE )
203+  set ( USE_TEMPLATE_GET_NODE "True"  )
202204 endif ()
203205
206+  # Bits (32|64) 
207+  math ( EXPR  BITS "${CMAKE_SIZEOF_VOID_P}  * 8"  ) # CMAKE_SIZEOF_VOID_P refers to target architecture. 
208+ 
209+  # API json File 
204210 set (GODOT_GDEXTENSION_API_FILE "${GODOT_GDEXTENSION_DIR} /extension_api.json" )
205-  if  ( NOT   " ${ GODOT_CUSTOM_API_FILE} "   STREQUAL   "" ) # User-defined override. 
211+  if (  GODOT_CUSTOM_API_FILE  ) # User-defined override. 
206212 set (GODOT_GDEXTENSION_API_FILE "${GODOT_CUSTOM_API_FILE} " )
207213 endif ()
208214
209-  # Code Generation option 
210-  if (GODOT_GENERATE_TEMPLATE_GET_NODE)
211-  set (GENERATE_BINDING_PARAMETERS "True" )
212-  else ()
213-  set (GENERATE_BINDING_PARAMETERS "False" )
215+  # Build Profile 
216+  if ( GODOT_BUILD_PROFILE )
217+  message ( STATUS  "Using build profile to trim api file" )
218+  message ( "\t BUILD_PROFILE = '${GODOT_BUILD_PROFILE} '" )
219+  message ( "\t API_SOURCE = '${GODOT_GDEXTENSION_API_FILE} '" )
220+  build_profile_generate_trimmed_api(
221+  "${GODOT_BUILD_PROFILE} " 
222+  "${GODOT_GDEXTENSION_API_FILE} " 
223+  "${CMAKE_CURRENT_BINARY_DIR} /extension_api.json"  )
224+  set ( GODOT_GDEXTENSION_API_FILE "${CMAKE_CURRENT_BINARY_DIR} /extension_api.json"  )
214225 endif ()
215226
216-  execute_process (COMMAND  "${Python3_EXECUTABLE} "  "-c"  "import binding_generator; binding_generator.print_file_list('${GODOT_GDEXTENSION_API_FILE} ', '${CMAKE_CURRENT_BINARY_DIR} ', headers=True, sources=True)" 
217-  WORKING_DIRECTORY  ${CMAKE_CURRENT_SOURCE_DIR} 
218-  OUTPUT_VARIABLE  GENERATED_FILES_LIST
219-  OUTPUT_STRIP_TRAILING_WHITESPACE
220-  )
227+  message ( STATUS  "GODOT_GDEXTENSION_API_FILE = '${GODOT_GDEXTENSION_API_FILE} '" )
221228
222-  add_custom_command (OUTPUT  ${GENERATED_FILES_LIST} 
223-  COMMAND  "${Python3_EXECUTABLE} "  "-c"  "import binding_generator; binding_generator.generate_bindings('${GODOT_GDEXTENSION_API_FILE} ', '${GENERATE_BINDING_PARAMETERS} ', '${BITS} ', '${GODOT_PRECISION} ', '${CMAKE_CURRENT_BINARY_DIR} ')" 
224-  VERBATIM 
225-  WORKING_DIRECTORY  ${CMAKE_CURRENT_SOURCE_DIR} 
226-  MAIN_DEPENDENCY  ${GODOT_GDEXTENSION_API_FILE} 
227-  DEPENDS  ${CMAKE_CURRENT_SOURCE_DIR} /binding_generator.py
228-  COMMENT  "Generating bindings" 
229-  )
229+  # generate the file list to use 
230+  binding_generator_get_file_list( GENERATED_FILES_LIST
231+  "${GODOT_GDEXTENSION_API_FILE} " 
232+  "${CMAKE_CURRENT_BINARY_DIR} "  )
233+ 
234+  binding_generator_generate_bindings(
235+  "${GODOT_GDEXTENSION_API_FILE} " 
236+  "${USE_TEMPLATE_GET_NODE} " 
237+  "${BITS} " 
238+  "${GODOT_PRECISION} " 
239+  "${CMAKE_CURRENT_BINARY_DIR} "  )
230240
231241 ### Platform is derived from the toolchain target 
232242 # See GeneratorExpressions PLATFORM_ID and CMAKE_SYSTEM_NAME 
0 commit comments