From b79772f3c3762cf54eec878be0aab639faab7e2a Mon Sep 17 00:00:00 2001 From: Robert Izzard <r.izzard@surrey.ac.uk> Date: Sun, 10 Nov 2019 13:53:01 +0000 Subject: [PATCH] update meson build --- meson.build | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/meson.build b/meson.build index ee348ce9e..f9ce1a794 100644 --- a/meson.build +++ b/meson.build @@ -18,7 +18,13 @@ # build with various old compilers # ############################################################ - +# +# A typical clean build with gcc and "time make" gives +# 95.23user 21.08system 0:34.64elapsed 335%CPU (0avgtext+0avgdata 425420maxresident)k +# +# While with ninja (no ccache) we get +# 54.94user 17.08system 0:20.95elapsed 343%CPU (0avgtext+0avgdata 327256maxresident)k +# ############################################################ # define the binary_c project project( @@ -318,35 +324,45 @@ cflags += warn_flags ############################################################ -# make precompiled headers +# make precompiled headers (PCH) if compiler.get_id() == 'clang' + _pch = binary_c_src + '/binary_c.h.pch' + use_pch_cflags = [ '-include-pch', _pch ] pch_cflags = [ ] pch_sourcefiles = [ 'binary_c.h.pch' ] + pch_post = [ '-o', _pch ] else + _gch = binary_c_src + '/binary_c.h.gch' + use_pch_cflags = [ ] # -include is not required pch_cflags = [ '-x', 'c-header' ] pch_sourcefiles = [ 'binary_c.h.gch' ] + pch_post = [ ] endif +# make cflags for pch build pch_cflags_array = cflags + pch_cflags +# append usage flags +cflags += use_pch_cflags + pch_compiler = compiler.cmd_array() + pch_cflags_array precompiled_headers = custom_target( - 'binary_c.h.gch', + 'binary_c.h.pch', build_by_default : true, input : ['src/binary_c.h'], output : pch_sourcefiles, - command : [ pch_compiler, '-gdwarf-2', '@INPUT@' ], + command : [ pch_compiler, '-gdwarf-2', '@INPUT@', pch_post ], depend_files : [h_sourcefiles], ) ############################################################ # symlink shared_library to binary_c/src directory - +# run: ninja libbinary_c_symlink libbinary_c_symlink = custom_target( - 'symlink_libbinary_c', + 'libbinary_c_symlink', build_by_default: false, output: [ 'libbinary_c_symlink' ], command: [ 'sh', '-c', '../meson/symlink_libbinary_c.sh' ], @@ -364,7 +380,7 @@ binary_c_shared_library = shared_library( sources : [c_sourcefiles, h_sourcefiles, precompiled_headers], include_directories: include_directories(incdirs), dependencies : [ libgsl_dep ], - c_args : [ cflags, quoted_cflags_list, '-fvisibility=hidden','-H' ], + c_args : [ cflags, quoted_cflags_list, '-fvisibility=hidden' ], link_args : libs, objects : data_objects, ) @@ -380,7 +396,7 @@ binary_c_executable = executable( sources : [c_sourcefiles, h_sourcefiles, precompiled_headers], include_directories: include_directories(incdirs), dependencies : [ libgsl_dep ], - c_args : [ cflags, quoted_cflags_list, '-H' ], + c_args : [ cflags, quoted_cflags_list ], link_args : libs, objects : data_objects, ) @@ -388,10 +404,10 @@ binary_c_executable = executable( ############################################################ # symlink executable to binary_c directory - +# run : ninja binary_c_symlnik binary_c_symlink = custom_target('symlink_binary_c', build_by_default: true, - output: ['binary_c_symlinked'], + output: ['binary_c_symlink'], command: [ 'sh', '-c', '../meson/symlink_binary_c.sh' ], depends : [ binary_c_executable ], ) -- GitLab