[tepl/master.msvc: 8/9] meson: Try to streamline building libtepl



commit 7ba1054c31d9a76cba85ca7ce2a14a76e6bd5137
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      | 36 +++++++++---------------------------
 tests/meson.build     |  6 ++++--
 testsuite/meson.build |  8 +++++---
 3 files changed, 18 insertions(+), 32 deletions(-)
---
diff --git a/tepl/meson.build b/tepl/meson.build
index 7b03c3b..99381b4 100644
--- a/tepl/meson.build
+++ b/tepl/meson.build
@@ -104,47 +104,29 @@ tepl_enum_types = GNOME.mkenums_simple(
   install_dir: headers_install_dir
 )
 
-tepl_c_args = [ '-DTEPL_COMPILATION' ]
-if c_compiler.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
-)
-
 symbol_map = []
+tepl_c_args = [ '-DTEPL_COMPILATION' ]
 tepl_link_args = []
 tepl_link_depends = []
 
-if c_compiler.get_argument_syntax() != 'msvc'
+if c_compiler.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
 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
 )
diff --git a/tests/meson.build b/tests/meson.build
index ab9d15b..c1bafb9 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -10,7 +10,9 @@ interactive_tests = [
 
 foreach test : interactive_tests
   executable(
-    test[0], test[1],
-    dependencies: TEPL_STATIC_DEP
+    test[0], test[1], tepl_enum_types[1],
+    dependencies: TEPL_DEPS,
+    include_directories: ROOT_INCLUDE_DIR,
+    objects: tepl_lib.extract_all_objects(),
   )
 endforeach
diff --git a/testsuite/meson.build b/testsuite/meson.build
index 0af9829..e0aed69 100644
--- a/testsuite/meson.build
+++ b/testsuite/meson.build
@@ -16,9 +16,11 @@ unit_tests = [
 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())
+    test_name + '.c', tepl_enum_types[1],
+    c_args: '-DUNIT_TESTS_SOURCE_DIR="@0@"'.format(meson.current_source_dir()),
+    dependencies: TEPL_DEPS,
+    include_directories: ROOT_INCLUDE_DIR,
+    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]