From cb5ac274dc77b0d8a05381b0c85cd189c67ed68b Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Thu, 20 Mar 2025 14:29:43 -0400 Subject: [PATCH] build(build): updated build system to be compatible with resource manager The build system now passes compiler directives based on the mode being build. By default data is stored in the source root (and this is encoded into the compiled binary). However, if building in user mode then data is assumed to be at the meson install prefix data directory --- meson.build | 17 +++++++++++++++++ meson_options.txt | 1 + src/eos/meson.build | 15 +++++++++++++-- src/meshIO/meson.build | 12 ++++++++++-- src/meson.build | 23 +++++++++++++++-------- src/opatIO/meson.build | 4 ++++ tests/meson.build | 1 + 7 files changed, 61 insertions(+), 12 deletions(-) diff --git a/meson.build b/meson.build index f5476a9..bd29da1 100644 --- a/meson.build +++ b/meson.build @@ -2,11 +2,28 @@ project('4DSSE', 'cpp', version: '0.0.1a', default_options: ['cpp_std=c++23'], m # Add default visibility for all C++ targets add_project_arguments('-fvisibility=default', language: 'cpp') +# Determine the mode +mode = 1 +if get_option('user_mode') + mode = 0 +endif + +# Define DATA_DIR based on mode +if mode == 1 + data_dir = meson.project_source_root() + '/assets/dynamic' +else + data_dir = get_option('prefix') + '/' + get_option('datadir') + '/4DSSE' +endif + +# Pass the DATA_DIR definition to the compiler +add_project_arguments('-DDATA_DIR=' + data_dir, language : 'cpp') # Build external dependencies first so that all the embedded resources are available to the other targets subdir('build-config') subdir('subprojects/PicoSHA2') +subdir('assets/static') + # Build the main project subdir('src') if get_option('build_tests') diff --git a/meson_options.txt b/meson_options.txt index c3b5afd..56baeee 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1 +1,2 @@ option('build_tests', type: 'boolean', value: true, description: 'Build tests') +option('user_mode', type: 'boolean', value: false, description: 'Enable user mode (set mode = 0)') diff --git a/src/eos/meson.build b/src/eos/meson.build index ca3e18f..f9979b4 100644 --- a/src/eos/meson.build +++ b/src/eos/meson.build @@ -1,23 +1,34 @@ # Define the library eos_sources = files( 'private/helm.cpp', + 'private/eosIO.cpp' ) eos_headers = files( - 'public/helm.h' + 'public/helm.h', + 'public/eosIO.h' ) +dependencies = [ + const_dep, + quill_dep, + probe_dep, + config_dep, + mfem_dep, + macros_dep, +] # Define the libconst library so it can be linked against by other parts of the build system libeos = static_library('eos', eos_sources, include_directories: include_directories('public'), cpp_args: ['-fvisibility=default'], - dependencies: [const_dep, quill_dep, probe_dep, config_dep, mfem_dep], + dependencies: dependencies, install : true) eos_dep = declare_dependency( include_directories: include_directories('public'), link_with: libeos, + dependencies: dependencies ) # Make headers accessible install_headers(eos_headers, subdir : '4DSSE/eos') \ No newline at end of file diff --git a/src/meshIO/meson.build b/src/meshIO/meson.build index 1ea870a..a684138 100644 --- a/src/meshIO/meson.build +++ b/src/meshIO/meson.build @@ -6,14 +6,22 @@ meshIO_sources = files( meshIO_headers = files( 'public/meshIO.h' ) - +dependencies = [ + mfem_dep +] # Define the libmeshIO library so it can be linked against by other parts of the build system libmeshIO = static_library('meshIO', meshIO_sources, include_directories: include_directories('public'), cpp_args: ['-fvisibility=default'], - dependencies: [mfem_dep], + dependencies: dependencies, install : true) +meshio_dep = declare_dependency( + include_directories: include_directories('public'), + link_with: libmeshIO, + dependencies: dependencies +) + # Make headers accessible install_headers(meshIO_headers, subdir : '4DSSE/meshIO') \ No newline at end of file diff --git a/src/meson.build b/src/meson.build index 3547118..d2d2399 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,11 +1,18 @@ -# Build resources first so that all the embedded resources are available to the other targets -subdir('resources') +# Build the main source code in the correct order -# Build the main source code -subdir('dobj') -subdir('const') -subdir('opatIO') -subdir('meshIO') +# Utility Libraries +subdir('misc') subdir('config') subdir('probe') -subdir('eos') \ No newline at end of file +subdir('const') +subdir('dobj') + +# Asset Libraries +subdir('eos') +subdir('opatIO') +subdir('meshIO') + +# Resouce Manager Libraries +subdir('resource') + +# Physics Libraries \ No newline at end of file diff --git a/src/opatIO/meson.build b/src/opatIO/meson.build index c2229bc..238ee6f 100644 --- a/src/opatIO/meson.build +++ b/src/opatIO/meson.build @@ -16,5 +16,9 @@ libopatIO = library('opatIO', install : true, ) +opatio_dep = declare_dependency( + include_directories: include_directories('public'), + link_with: libopatIO, +) # Make headers accessible install_headers(opatIO_headers, subdir : '4DSSE/opatIO') \ No newline at end of file diff --git a/tests/meson.build b/tests/meson.build index e744e20..0d89e07 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -11,6 +11,7 @@ subdir('meshIO') subdir('config') subdir('probe') subdir('eos') +subdir('resource') # Subdirectories for sandbox tests subdir('dobj_sandbox')