[tepl/master.msvc: 36/36] meson: Try to streamline building libtepl
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tepl/master.msvc: 36/36] meson: Try to streamline building libtepl
- Date: Mon, 4 May 2020 07:17:05 +0000 (UTC)
commit bad1cb182dfb8e0b324812b371dae48171cec84e
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Thu Apr 30 11:01:53 2020 +0800
meson: Try to streamline building libtepl
Stop building a static tepl-core library, but instead build only the main
Tepl library and use extract_all_objects() on the main Tepl library in order to
build and link the test programs that use internal APIs
tepl/meson.build | 42 +++++++++++++++++-------------------------
tests/meson.build | 3 ++-
testsuite/meson.build | 5 +++--
3 files changed, 22 insertions(+), 28 deletions(-)
---
diff --git a/tepl/meson.build b/tepl/meson.build
index 583c1fd..89316b0 100644
--- a/tepl/meson.build
+++ b/tepl/meson.build
@@ -109,33 +109,12 @@ tepl_enum_types = GNOME.mkenums_simple(
)
tepl_c_args = [ '-DTEPL_COMPILATION' ]
-if CC.get_argument_syntax() == 'msvc'
- tepl_c_args += '-D_TEPL_EXTERN=__declspec(dllexport) extern'
-endif
-
-tepl_static_lib = static_library(
- 'tepl-static',
- [tepl_public_c_files,
- tepl_private_c_files,
- tepl_enum_types],
- pic: true, # tepl_static_lib is linked in a shared library.
- include_directories: ROOT_INCLUDE_DIR,
- dependencies: TEPL_DEPS,
- c_args: tepl_c_args
-)
-
-# For unit tests, to be able to test private functions.
-TEPL_STATIC_DEP = declare_dependency(
- include_directories: ROOT_INCLUDE_DIR,
- link_with: tepl_static_lib,
- sources: tepl_enum_types[1],
- dependencies: TEPL_DEPS
-)
-
tepl_link_args = []
tepl_link_depends = []
-if CC.get_argument_syntax() != 'msvc'
+if CC.get_argument_syntax() == 'msvc'
+ tepl_c_args += '-D_TEPL_EXTERN=__declspec(dllexport) extern'
+else
symbol_map = meson.current_source_dir() / 'symbol.map'
tepl_link_args = '-Wl,--version-script,' + symbol_map
tepl_link_depends = symbol_map
@@ -143,10 +122,14 @@ endif
tepl_lib = library(
'tepl-@0@'.format(TEPL_API_VERSION),
+ tepl_public_c_files,
+ tepl_private_c_files,
+ tepl_enum_types,
+ c_args: tepl_c_args,
dependencies: TEPL_DEPS,
+ include_directories: ROOT_INCLUDE_DIR,
link_args: tepl_link_args,
link_depends: tepl_link_depends,
- objects: tepl_static_lib.extract_all_objects(),
version: TEPL_LT_VERSION,
install: true
)
@@ -158,6 +141,15 @@ TEPL_LIB_DEP = declare_dependency(
dependencies: TEPL_DEPS
)
+# For unit tests (must use
+# tepl_lib.extract_all_objects() to test
+# private functions)
+TEPL_TESTS_DEP = declare_dependency(
+ include_directories: ROOT_INCLUDE_DIR,
+ sources: tepl_enum_types[1],
+ dependencies: TEPL_DEPS
+)
+
PKG_CONFIG.generate(tepl_lib,
filebase: 'tepl-@0@'.format(TEPL_API_VERSION),
name: 'Tepl',
diff --git a/tests/meson.build b/tests/meson.build
index ab9d15b..a3b1e14 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -11,6 +11,7 @@ interactive_tests = [
foreach test : interactive_tests
executable(
test[0], test[1],
- dependencies: TEPL_STATIC_DEP
+ dependencies: TEPL_TESTS_DEP,
+ objects: tepl_lib.extract_all_objects(),
)
endforeach
diff --git a/testsuite/meson.build b/testsuite/meson.build
index 0af9829..80437ef 100644
--- a/testsuite/meson.build
+++ b/testsuite/meson.build
@@ -17,8 +17,9 @@ foreach test_name : unit_tests
test_exe = executable(
test_name,
test_name + '.c',
- dependencies: TEPL_STATIC_DEP,
- c_args: '-DUNIT_TESTS_SOURCE_DIR="@0@"'.format(meson.current_source_dir())
+ c_args: '-DUNIT_TESTS_SOURCE_DIR="@0@"'.format(meson.current_source_dir()),
+ dependencies: TEPL_TESTS_DEP,
+ objects: tepl_lib.extract_all_objects(),
)
test(test_name, test_exe)
endforeach
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]