diff --git a/meson.build b/meson.build index 9743232d..ba40cc0f 100644 --- a/meson.build +++ b/meson.build @@ -172,6 +172,7 @@ add_project_arguments( subdir('src/chameleon') subdir('src/iguana/services') subdir('src/iguana/algorithms') +subdir('src/iguana/bindings') subdir('src/iguana/tests') # build bindings diff --git a/src/chameleon/meson.build b/src/chameleon/meson.build index 8647146b..448782c2 100644 --- a/src/chameleon/meson.build +++ b/src/chameleon/meson.build @@ -1,6 +1,10 @@ +use_chameleon = get_option('bind_fortran') + chameleon_sources = files( 'chameleon', 'src' / 'generator.rb', 'src' / 'bind_c.rb', ) -chameleon_gen = find_program(chameleon_sources[0]) + +ruby = find_program('ruby', version: '>=3.0.0', required: use_chameleon) +chameleon_gen = find_program(chameleon_sources[0], required: use_chameleon) diff --git a/src/chameleon/src/bind_c.rb b/src/chameleon/src/bind_c.rb index 025fa24f..446459ce 100644 --- a/src/chameleon/src/bind_c.rb +++ b/src/chameleon/src/bind_c.rb @@ -12,8 +12,8 @@ def initialize(out_name='', algo_name='') #{deterrence_banner 'c'} - #include "#{@algo_header}" - #include "Bindings.h" + #include "iguana/algorithms/#{@algo_header}" + #include "iguana/bindings/Bindings.h" namespace iguana::bindings::#{@algo_name.split('::').first} { extern "C" { diff --git a/src/iguana/algorithms/meson.build b/src/iguana/algorithms/meson.build index 689611be..a430afee 100644 --- a/src/iguana/algorithms/meson.build +++ b/src/iguana/algorithms/meson.build @@ -91,8 +91,8 @@ algo_dict = [ ] # make lists of objects to build; inclusion depends on whether ROOT is needed or not, and if we have ROOT -algo_sources = [ 'Algorithm.cc', 'AlgorithmFactory.cc', 'AlgorithmSequence.cc', 'Bindings.cc' ] -algo_headers = [ 'Algorithm.h', 'AlgorithmBoilerplate.h', 'TypeDefs.h', 'AlgorithmSequence.h', 'Bindings.h' ] +algo_sources = [ 'Algorithm.cc', 'AlgorithmFactory.cc', 'AlgorithmSequence.cc' ] +algo_headers = [ 'Algorithm.h', 'AlgorithmBoilerplate.h', 'TypeDefs.h', 'AlgorithmSequence.h' ] vdor_sources = [ 'Validator.cc' ] vdor_headers = [ 'Validator.h' ] algo_configs = [] @@ -126,8 +126,8 @@ foreach algo : algo_dict algo_configs += algo_dir / 'Config.yaml' endif - # chameleon targets - if algo_has_action_yaml + # run chameleon + if use_chameleon and algo_has_action_yaml target_name = '_'.join([ 'chameleon', algo_name.split('::') ]) tgt = custom_target( target_name, @@ -195,21 +195,6 @@ vdor_lib = shared_library( ) install_headers(vdor_headers, subdir: meson.project_name() / 'algorithms', preserve_path: true) -# build C bindings -if get_option('bind_fortran') - algo_bind_c_lib = shared_library( - 'IguanaBindingsC', - algo_bind_c_sources, - include_directories: [ project_inc ] + ROOT_dep_inc_dirs, - dependencies: project_deps, - link_with: [ services_lib, algo_lib ], - link_args: ROOT_dep_link_args + ROOT_dep_link_args_for_validators, - install: true, - build_rpath: ROOT_dep_rpath, - ) - project_libs += algo_bind_c_lib -endif - # install config files foreach algo_config : algo_configs install_data(algo_config, install_dir: project_etc / 'algorithms', preserve_path: true) diff --git a/src/iguana/algorithms/Bindings.cc b/src/iguana/bindings/Bindings.cc similarity index 100% rename from src/iguana/algorithms/Bindings.cc rename to src/iguana/bindings/Bindings.cc diff --git a/src/iguana/algorithms/Bindings.h b/src/iguana/bindings/Bindings.h similarity index 99% rename from src/iguana/algorithms/Bindings.h rename to src/iguana/bindings/Bindings.h index 79e41a2f..75ec14d3 100644 --- a/src/iguana/algorithms/Bindings.h +++ b/src/iguana/bindings/Bindings.h @@ -1,6 +1,6 @@ #pragma once -#include "Algorithm.h" +#include "iguana/algorithms/Algorithm.h" namespace iguana::bindings { extern "C" { diff --git a/src/iguana/bindings/meson.build b/src/iguana/bindings/meson.build new file mode 100644 index 00000000..182b6c35 --- /dev/null +++ b/src/iguana/bindings/meson.build @@ -0,0 +1,22 @@ +if use_chameleon + + algo_bind_c_sources += [ 'Bindings.cc' ] + algo_bind_c_headers = [ 'Bindings.h' ] + + # build C bindings + if get_option('bind_fortran') + algo_bind_c_lib = shared_library( + 'IguanaBindingsC', + algo_bind_c_sources, + include_directories: [ project_inc ] + ROOT_dep_inc_dirs, + dependencies: project_deps, + link_with: [ services_lib, algo_lib ], + link_args: ROOT_dep_link_args + ROOT_dep_link_args_for_validators, + install: true, + build_rpath: ROOT_dep_rpath, + ) + project_libs += algo_bind_c_lib + endif + install_headers(algo_bind_c_headers, subdir: meson.project_name() / 'bindings', preserve_path: true) + +endif