diff --git a/gucc/meson.build b/gucc/meson.build new file mode 100644 index 0000000..c0a5c68 --- /dev/null +++ b/gucc/meson.build @@ -0,0 +1,15 @@ +gucc_lib = library('gucc', + sources : [ + 'src/file_utils.cpp', + 'src/string_utils.cpp', + 'src/cpu.cpp', + 'src/pacmanconf_repo.cpp', + 'src/initcpio.cpp', + ], + include_directories : [include_directories('src')], + dependencies: deps +) + +if is_tests_build + subdir('tests') +endif diff --git a/gucc/tests/meson.build b/gucc/tests/meson.build index 9ee9e9a..85e09d4 100644 --- a/gucc/tests/meson.build +++ b/gucc/tests/meson.build @@ -1,28 +1,15 @@ -source_path = '../src/' - -test_libreq = shared_library('test_libreq', - sources : [ - source_path + 'file_utils.cpp', - source_path + 'cpu.cpp', - source_path + 'pacmanconf_repo.cpp', - source_path + 'initcpio.cpp', - ], - include_directories : [include_directories(source_path)], - dependencies: deps -) - executable( 'test-initcpio', files('unit-initcpio.cpp'), dependencies: deps, - link_with: [test_libreq], - include_directories: [include_directories(source_path)], + link_with: [gucc_lib], + include_directories: [include_directories('../src')], install: false) executable( 'test-pacmanconf', files('unit-pacmanconf.cpp'), dependencies: deps, - link_with: [test_libreq], - include_directories: [include_directories(source_path)], + link_with: [gucc_lib], + include_directories: [include_directories('../src')], install: false) diff --git a/meson.build b/meson.build index 8e9562e..6d6d74b 100644 --- a/meson.build +++ b/meson.build @@ -11,6 +11,7 @@ project('cachyos-installer', 'cpp', is_debug_build = get_option('buildtype').startswith('debug') is_dev_environment = get_option('devenv') is_tests_build = get_option('build_tests') +do_build_static = get_option('build_static') cc = meson.get_compiler('cpp') if cc.get_id() == 'clang' specific_cc_flags = [ @@ -68,9 +69,6 @@ src_files = files( 'src/definitions.hpp', 'src/config.cpp', 'src/config.hpp', 'src/utils.cpp', 'src/utils.hpp', - 'src/cpu.cpp', 'src/cpu.hpp', - 'src/pacmanconf_repo.cpp', 'src/pacmanconf_repo.hpp', - 'src/initcpio.cpp', 'src/initcpio.hpp', 'src/chwd_profiles.cpp', 'src/chwd_profiles.hpp', 'src/disk.cpp', 'src/disk.hpp', 'src/drivers.cpp', 'src/drivers.hpp', @@ -152,7 +150,9 @@ if not is_debug_build endif possible_cc_flags += ['-fdata-sections', '-ffunction-sections'] - possible_link_flags = ['-Wl,--gc-sections', '-static-libgcc', '-static-libstdc++'] + if do_build_static + possible_link_flags = ['-Wl,--gc-sections', '-static-libgcc', '-static-libstdc++'] + endif add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'cpp') endif @@ -163,11 +163,14 @@ if not is_dev_environment deps += [cpr] endif +subdir('gucc') + executable( 'cachyos-installer', src_files, dependencies: deps, - include_directories: [include_directories('src')], + link_with: gucc_lib, + include_directories: [include_directories('src'), include_directories('gucc/src')], install: true) install_data( diff --git a/meson_options.txt b/meson_options.txt index 7654afb..8ec8e2f 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,2 +1,3 @@ option('devenv', type: 'boolean', value: true, description: 'enable dev environment') option('build_tests', type: 'boolean', value: false, description: 'enable tests') +option('build_static', type: 'boolean', value: false, description: 'build all static') diff --git a/tests/meson.build b/tests/meson.build index c0b2930..0449b20 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -14,8 +14,9 @@ test_libreq = shared_library('test_libreq', source_path + 'simple_tui.cpp', source_path + 'tui.cpp', ], - include_directories : [include_directories(source_path)], - dependencies: deps + include_directories : [include_directories(source_path), include_directories('../gucc/src')], + dependencies: deps, + link_with: [gucc_lib] ) executable(