Skip to content

Commit

Permalink
refactor: put top-level binding code in its own dir
Browse files Browse the repository at this point in the history
  • Loading branch information
c-dilks committed Jul 22, 2024
1 parent 7aa0204 commit 81918b1
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 23 deletions.
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/chameleon/meson.build
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 2 additions & 2 deletions src/chameleon/src/bind_c.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
23 changes: 4 additions & 19 deletions src/iguana/algorithms/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "Algorithm.h"
#include "iguana/algorithms/Algorithm.h"

namespace iguana::bindings {
extern "C" {
Expand Down
22 changes: 22 additions & 0 deletions src/iguana/bindings/meson.build
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 81918b1

Please sign in to comment.