diff --git a/src/xrt/auxiliary/CMakeLists.txt b/src/xrt/auxiliary/CMakeLists.txt index e68ec6077..56f1f7875 100644 --- a/src/xrt/auxiliary/CMakeLists.txt +++ b/src/xrt/auxiliary/CMakeLists.txt @@ -1,36 +1,6 @@ # Copyright 2019-2020, Collabora, Ltd. # SPDX-License-Identifier: BSL-1.0 -### -# Binding generation -# - -function(bindings_gen output custom_target) - add_custom_command(OUTPUT ${output} - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/bindings/bindings.py - ${CMAKE_CURRENT_SOURCE_DIR}/bindings/bindings.json - ${output} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bindings/bindings.py - ${CMAKE_CURRENT_SOURCE_DIR}/bindings/bindings.json - ) - add_custom_target(${custom_target} DEPENDS ${output}) -endfunction(bindings_gen) - -bindings_gen(${CMAKE_CURRENT_BINARY_DIR}/b_generated_bindings.h generated_bindings_h) -bindings_gen(${CMAKE_CURRENT_BINARY_DIR}/b_generated_bindings.c generated_bindings_c) - -# Bindings library. -add_library(aux_generated_bindings STATIC ${CMAKE_CURRENT_BINARY_DIR}/b_generated_bindings.c) -add_dependencies(aux_generated_bindings generated_bindings_h) - -# needed globally for steamvr input profile generation in steamvr target -set_property(GLOBAL PROPERTY AUX_BINDINGS_DIR_PROP "${CMAKE_CURRENT_SOURCE_DIR}/bindings") - -target_include_directories(aux_generated_bindings PUBLIC "${CMAKE_CURRENT_BINARY_DIR}" ".") -target_link_libraries(aux_generated_bindings INTERFACE xrt-interfaces aux_util) -# HACK: linking xrt-interfaces doesn't work for some reason -target_include_directories(aux_generated_bindings PUBLIC "../include") - set(ANDROID_SOURCE_FILES android/android_ahardwarebuffer_allocator.c android/android_ahardwarebuffer_allocator.h @@ -188,7 +158,7 @@ set(VK_SOURCE_FILES # Common includes add_library(aux-includes INTERFACE) -target_include_directories(aux-includes INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(aux-includes INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(aux-includes INTERFACE xrt-interfaces) if(XRT_HAVE_OPENGL OR XRT_HAVE_OPENGLES) @@ -288,3 +258,5 @@ if(ANDROID) CXX_STANDARD_REQUIRED ON) target_link_libraries(aux_vk PUBLIC aux_android) endif() + +add_subdirectory(bindings) diff --git a/src/xrt/auxiliary/bindings/CMakeLists.txt b/src/xrt/auxiliary/bindings/CMakeLists.txt new file mode 100644 index 000000000..661e765d8 --- /dev/null +++ b/src/xrt/auxiliary/bindings/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright 2019-2020, Collabora, Ltd. +# SPDX-License-Identifier: BSL-1.0 + +### +# Binding generation +# + +function(bindings_gen output custom_target) + add_custom_command(OUTPUT ${output} + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/bindings.py + ${CMAKE_CURRENT_SOURCE_DIR}/bindings.json + ${output} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bindings.py + ${CMAKE_CURRENT_SOURCE_DIR}/bindings.json + ) + add_custom_target(${custom_target} DEPENDS ${output}) +endfunction(bindings_gen) + +bindings_gen(${CMAKE_CURRENT_BINARY_DIR}/b_generated_bindings.h generated_bindings_h) +bindings_gen(${CMAKE_CURRENT_BINARY_DIR}/b_generated_bindings.c generated_bindings_c) + +# Bindings library. +add_library(aux_generated_bindings STATIC ${CMAKE_CURRENT_BINARY_DIR}/b_generated_bindings.c) +add_dependencies(aux_generated_bindings generated_bindings_h) + +# needed globally for steamvr input profile generation in steamvr target +set_property(GLOBAL PROPERTY AUX_BINDINGS_DIR_PROP "${CMAKE_CURRENT_SOURCE_DIR}") + +target_include_directories(aux_generated_bindings PRIVATE aux-includes xrt-interfaces) +target_link_libraries(aux_generated_bindings PRIVATE xrt-interfaces aux_util) diff --git a/src/xrt/auxiliary/bindings/meson.build b/src/xrt/auxiliary/bindings/meson.build new file mode 100644 index 000000000..f1a331926 --- /dev/null +++ b/src/xrt/auxiliary/bindings/meson.build @@ -0,0 +1,39 @@ +# Copyright 2019-2020, Collabora, Ltd. +# SPDX-License-Identifier: BSL-1.0 + +### +# Binding generation +# + +aux_bindings_dir = meson.current_source_dir() + +prog_python = import('python').find_installation('python3') + +generated_bindings = custom_target('bindings code', + command: [prog_python, '@INPUT@', '@OUTPUT@'], + input: ['bindings.py', 'bindings.json'], + output: [ + 'b_generated_bindings.h', + 'b_generated_bindings.c', + ] +) + +generated_bindings_h = generated_bindings[0] +generated_bindings_c = generated_bindings[1] + +lib_aux_generated_bindings = static_library( + 'aux_generated_bindings', + generated_bindings_c, + include_directories: [ + xrt_include, + aux_include, + ], + dependencies: [ + xrt_config_have, + ] +) + +aux_generated_bindings = declare_dependency( + include_directories: aux_include, + link_with: lib_aux_generated_bindings, +) diff --git a/src/xrt/auxiliary/meson.build b/src/xrt/auxiliary/meson.build index 858fa30c9..2ced9ea8e 100644 --- a/src/xrt/auxiliary/meson.build +++ b/src/xrt/auxiliary/meson.build @@ -3,48 +3,14 @@ aux_include = include_directories('.') +subdir('bindings') + u_git_tag_c = vcs_tag( input: 'util/u_git_tag.c.in', output: 'u_git_tag.c', replace_string: '@GIT_DESC@', ) -### -# Binding generation -# - -aux_bindings_dir = join_paths(meson.current_source_dir(), 'bindings') - -prog_python = import('python').find_installation('python3') - -generated_bindings = custom_target('bindings code', - command: [prog_python, '@INPUT@', '@OUTPUT@'], - input: ['bindings/bindings.py', 'bindings/bindings.json'], - output: [ - 'b_generated_bindings.h', - 'b_generated_bindings.c', - ] -) - -generated_bindings_h = generated_bindings[0] -generated_bindings_c = generated_bindings[1] - -lib_aux_generated_bindings = static_library( - 'aux_generated_bindings', - generated_bindings_c, - include_directories: [ - xrt_include, - ], - dependencies: [ - xrt_config_have, - ] -) - -aux_generated_bindings = declare_dependency( - include_directories: aux_include, - link_with: lib_aux_generated_bindings, -) - lib_aux_util = static_library( 'aux_util', files( diff --git a/src/xrt/state_trackers/oxr/CMakeLists.txt b/src/xrt/state_trackers/oxr/CMakeLists.txt index 00779d53f..13accff35 100644 --- a/src/xrt/state_trackers/oxr/CMakeLists.txt +++ b/src/xrt/state_trackers/oxr/CMakeLists.txt @@ -84,6 +84,7 @@ target_link_libraries(st_oxr PRIVATE aux_math aux_generated_bindings comp_client + aux-includes PUBLIC aux_os Vulkan::Vulkan diff --git a/src/xrt/state_trackers/oxr/oxr_api_action.c b/src/xrt/state_trackers/oxr/oxr_api_action.c index 822000d86..6eff16dcd 100644 --- a/src/xrt/state_trackers/oxr/oxr_api_action.c +++ b/src/xrt/state_trackers/oxr/oxr_api_action.c @@ -20,7 +20,7 @@ #include #include -#include "b_generated_bindings.h" +#include "bindings/b_generated_bindings.h" /* * diff --git a/src/xrt/state_trackers/oxr/oxr_binding.c b/src/xrt/state_trackers/oxr/oxr_binding.c index e60a2f4fb..168c8b1fc 100644 --- a/src/xrt/state_trackers/oxr/oxr_binding.c +++ b/src/xrt/state_trackers/oxr/oxr_binding.c @@ -10,7 +10,7 @@ #include "util/u_misc.h" #include "xrt/xrt_compiler.h" -#include "b_generated_bindings.h" +#include "bindings/b_generated_bindings.h" #include "oxr_objects.h" #include "oxr_logger.h" diff --git a/src/xrt/state_trackers/steamvr_drv/ovrd_driver.cpp b/src/xrt/state_trackers/steamvr_drv/ovrd_driver.cpp index 7a0b171d6..1fa4274e3 100644 --- a/src/xrt/state_trackers/steamvr_drv/ovrd_driver.cpp +++ b/src/xrt/state_trackers/steamvr_drv/ovrd_driver.cpp @@ -29,7 +29,7 @@ extern "C" { #include "xrt/xrt_device.h" #include "xrt/xrt_instance.h" -#include "b_generated_bindings.h" +#include "bindings/b_generated_bindings.h" } #pragma GCC diagnostic push