Browse Source

meson: various fixes/improvements to meson build

Mobin 1 year ago
parent
commit
1297fa8fc8
6 changed files with 49 additions and 51 deletions
  1. 2 2
      meson.build
  2. 4 4
      meson_options.txt
  3. 30 15
      src/igr-tests/meson.build
  4. 3 6
      src/meson.build
  5. 5 19
      src/tests/cptests/meson.build
  6. 5 5
      src/tests/meson.build

+ 2 - 2
meson.build

@@ -8,7 +8,7 @@ project(
     license : 'Apache-2.0',
     meson_version : '>= 0.47.0',
     default_options : [
-        'cpp_std = c++11',
+        'cpp_std=c++11',
         'optimization=s',
         'debug=false'
     ]
@@ -46,7 +46,7 @@ endif
 
 ## Use -lrt?
 # We need to pass -lrt to c++ linker on FreeBSD. see BUILD_MESON
-if platform == 'freebsd'
+if platform == 'freebsd' and compiler.has_link_argument('-lrt')
     add_project_link_arguments('-lrt', language : 'cpp')
 endif
 

+ 4 - 4
meson_options.txt

@@ -19,19 +19,19 @@ option(
 option(
     'unit-tests',
     type : 'boolean',
-    value : 'false',
+    value : false,
     description : 'Building Unit tests. by default its disabled.'
 )
 option(
     'igr-tests',
     type : 'boolean',
-    value : 'false',
+    value : false,
     description : 'Building Integration tests. by default its disabled.'
 )
 option(
     'fuzzer',
     type : 'boolean',
-    value : 'false',
+    value : false,
     description : 'Building fuzz target'
 )
 option(
@@ -49,7 +49,7 @@ option(
 option(
     'man-pages',
     type : 'boolean',
-    value : 'true',
+    value : true,
     description : 'Building & installing man-pages.'
 )
 

+ 30 - 15
src/igr-tests/meson.build

@@ -30,76 +30,91 @@ svcstartfail_test_script = files(meson.current_build_dir() + '/svc-start-fail/ru
 test(
      'basic',
      basic_test_script,
-     env : igr_tests_env
+     env : igr_tests_env,
+     suite : 'igr_tests'
 )
 test(
      'environ',
      environ_test_script,
      env : igr_tests_env,
-     is_parallel : false
+     is_parallel : false,
+     suite : 'igr_tests'
 )
 test(
      'ps-environ',
      psenviron_test_script,
-     env : igr_tests_env
+     env : igr_tests_env,
+     suite : 'igr_tests'
 )
 test(
      'chain-to',
      chainto_test_script,
-     env : igr_tests_env
+     env : igr_tests_env,
+     suite : 'igr_tests'
 )
 test(
      'force-stop',
      forcestop_test_script,
-     env : igr_tests_env
+     env : igr_tests_env,
+     suite : 'igr_tests'
 )
 test(
      'restart',
      restart_test_script,
-     env : igr_tests_env
+     env : igr_tests_env,
+     suite : 'igr_tests'
 )
 test(
      'check-basic',
      checkbasic_test_script,
-     env : igr_tests_env
+     env : igr_tests_env,
+     suite : 'igr_tests'
 )
 test(
      'check-cycle',
      checkcycle_test_script,
-     env : igr_tests_env
+     env : igr_tests_env,
+     suite : 'igr_tests'
 )
 test(
      'check-lint',
      checklint_test_script,
-     env : igr_tests_env
+     env : igr_tests_env,
+     suite : 'igr_tests'
 )
 test(
      'reload1',
      reload1_test_script,
-     env : igr_tests_env
+     env : igr_tests_env,
+     suite : 'igr_tests'
 )
 test(
      'reload2',
      reload2_test_script,
-     env : igr_tests_env
+     env : igr_tests_env,
+     suite : 'igr_tests'
 )
 test(
      'no-command-error',
      nocommanderror_test_script,
-     env : igr_tests_env
+     env : igr_tests_env,
+     suite : 'igr_tests'
 )
 test(
      'add-rm-dep',
      addrmdep_test_script,
-     env : igr_tests_env
+     env : igr_tests_env,
+     suite : 'igr_tests'
 )
 test(
      'var-subst',
      varsubst_test_script,
-     env : igr_tests_env
+     env : igr_tests_env,
+     suite : 'igr_tests'
 )
 test(
      'svc-start-fail',
      svcstartfail_test_script,
-     env : igr_tests_env
+     env : igr_tests_env,
+     suite : 'igr_tests'
 )

+ 3 - 6
src/meson.build

@@ -20,6 +20,9 @@ dinit_source_files = [
     'dinit-env.cc'
 ]
 
+## src/'s Defines
+shutdown_build = false
+
 ## src/'s defines for igr-tests/
 if igr_tests
     igr_tests_env = [
@@ -70,12 +73,6 @@ executable(
 # Shutdown/reboot/halt
 if build_shutdown.auto() and platform == 'linux' or build_shutdown.enabled()
     shutdown_build = true
-elif build_shutdown.auto() and platform != 'linux'
-    shutdown_build = false
-else
-    shutdown_build = false
-endif
-if shutdown_build
     foreach exec: ['shutdown', 'reboot', 'halt']
         executable(
             shutdown_prefix + exec,

+ 5 - 19
src/tests/cptests/meson.build

@@ -5,8 +5,8 @@ incdir = include_directories(
     'includes',
     '../../../dasynq/include/'
 )
-if fuzzer
-    fuzz_sources = [
+if fuzzer or unit_tests
+    sources = [
         '../test-bpsys.cc',
         '../test-dinit.cc',
         '../test-run-child-proc.cc',
@@ -19,20 +19,6 @@ if fuzzer
         '../../dinit-env.cc'
     ]
 endif
-if unit_tests
-    cptests_sources = [
-        '../../service.cc', 
-        '../../proc-service.cc',
-        '../../dinit-log.cc',
-        '../../load-service.cc',
-        '../../baseproc-service.cc',
-        '../../dinit-env.cc',
-        '../../control.cc',
-        '../test-dinit.cc',
-        '../test-bpsys.cc',
-        '../test-run-child-proc.cc'
-    ]
-endif
 
 ## dinit with libfuzzer can't be compiled without clang/clang++. For some reasons, Meson don't support set default compiler in default_options.
 if fuzzer and compiler.get_id() != 'clang'
@@ -51,17 +37,17 @@ if unit_tests
     cptests_exec = executable(
         'cptests',
         'cptests.cc',
-        cptests_sources,
+        sources,
         include_directories : incdir
     )
-    test('cptests', cptests_exec)
+    test('cptests', cptests_exec, suite : 'unit_tests')
 endif
 # LLVM's Libfuzzer
 if fuzzer
     executable(
         'fuzz',
         'fuzz.cc',
-        fuzz_sources,
+        sources,
         include_directories : incdir,
         install : false,
         cpp_args : '-fsanitize=address,undefined,fuzzer-no-link,leak',

+ 5 - 5
src/tests/meson.build

@@ -29,7 +29,7 @@ configure_file(
 run_command([
     'cp',
     '-r',
-    meson.current_source_dir() + 'test-services',
+    meson.current_source_dir() + '/test-services',
     meson.current_build_dir()
     ],
     check : true
@@ -65,8 +65,8 @@ envtests_exec = executable(
     for_tests_dinit_sources, 
     include_directories : for_tests_incdir
 )
-test('tests', tests_exec)
-test('proctests', proctests_exec)
-test('loadtests', loadtests_exec, workdir : meson.current_build_dir())
-test('envtests', envtests_exec)
+test('tests', tests_exec, suite : 'unit_tests')
+test('proctests', proctests_exec, suite : 'unit_tests')
+test('loadtests', loadtests_exec, workdir : meson.current_build_dir(), suite : 'unit_tests')
+test('envtests', envtests_exec, suite : 'unit_tests')
 subdir('cptests/')