diff options
-rw-r--r-- | sigc++/adaptors/lambda/meson.build | 45 | ||||
-rw-r--r-- | sigc++/adaptors/meson.build | 41 | ||||
-rw-r--r-- | sigc++/functors/meson.build | 35 | ||||
-rw-r--r-- | sigc++/meson.build | 104 | ||||
-rwxr-xr-x | tools/handle-built-files.py | 19 |
5 files changed, 148 insertions, 96 deletions
diff --git a/sigc++/adaptors/lambda/meson.build b/sigc++/adaptors/lambda/meson.build new file mode 100644 index 0000000..37e1994 --- /dev/null +++ b/sigc++/adaptors/lambda/meson.build @@ -0,0 +1,45 @@ +# sigc++/adaptors/lambda + +# Input: python3, handle_built_files, m4_template, m4_include_dir +# Output: +# Input and output: built_h_files, built_cc_files, built_h_file_targets, +# built_cc_file_targets + +# .m4 files to build .h and .cc files from. +adaptors_lambda_cc_m4_files = [ + 'lambda.cc', +] +adaptors_lambda_h_m4_files = [ + 'base.h', + 'select.h', +] +foreach file : adaptors_lambda_h_m4_files + built_h_files += 'adaptors' / 'lambda' / file +endforeach +foreach file : adaptors_lambda_cc_m4_files + built_cc_files += 'adaptors' / 'lambda' / file +endforeach + +if maintainer_mode + # Maintainer mode. Generate .h and .cc files from .m4 files in macros/ directory. + foreach file : adaptors_lambda_cc_m4_files + adaptors_lambda_h_m4_files + built_file_target = custom_target('adaptors_lambda_' + file, + input: 'macros' / file + '.m4', + output: file, + command: [ + python3, handle_built_files, 'build_from_m4', + m4_include_dir, + '@INPUT@', + '@OUTPUT@', + ], + depend_files: m4_template, + build_by_default: maintainer_mode, + install: false, + ) + if file.endswith('.cc') + built_cc_file_targets += built_file_target + else + built_h_file_targets += built_file_target + endif + endforeach +endif diff --git a/sigc++/adaptors/meson.build b/sigc++/adaptors/meson.build new file mode 100644 index 0000000..311c9b4 --- /dev/null +++ b/sigc++/adaptors/meson.build @@ -0,0 +1,41 @@ +# sigc++/adaptors + +# Input: python3, handle_built_files, m4_template, m4_include_dir +# Output: +# Input and output: built_h_files, built_h_file_targets + +# .m4 files to build .h files from. +adaptors_h_m4_files = [ + 'adaptor_trait.h', + 'bind.h', + 'bind_return.h', + 'compose.h', + 'deduce_result_type.h', + 'exception_catch.h', + 'hide.h', + 'retype.h', + 'retype_return.h', + 'track_obj.h', +] +foreach file : adaptors_h_m4_files + built_h_files += 'adaptors' / file +endforeach + +if maintainer_mode + # Maintainer mode. Generate .h files from .m4 files in macros/ directory. + foreach file : adaptors_h_m4_files + built_h_file_targets += custom_target('adaptors_' + file, + input: 'macros' / file + '.m4', + output: file, + command: [ + python3, handle_built_files, 'build_from_m4', + m4_include_dir, + '@INPUT@', + '@OUTPUT@', + ], + depend_files: m4_template, + build_by_default: maintainer_mode, + install: false, + ) + endforeach +endif diff --git a/sigc++/functors/meson.build b/sigc++/functors/meson.build new file mode 100644 index 0000000..4ea6fa4 --- /dev/null +++ b/sigc++/functors/meson.build @@ -0,0 +1,35 @@ +# sigc++/functors + +# Input: python3, handle_built_files, m4_template, m4_include_dir +# Output: +# Input and output: built_h_files, built_h_file_targets + +# .m4 files to build .h files from. +functors_h_m4_files = [ + 'functor_trait.h', + 'mem_fun.h', + 'ptr_fun.h', + 'slot.h', +] +foreach file : functors_h_m4_files + built_h_files += 'functors' / file +endforeach + +if maintainer_mode + # Maintainer mode. Generate .h files from .m4 files in macros/ directory. + foreach file : functors_h_m4_files + built_h_file_targets += custom_target('functors_' + file, + input: 'macros' / file + '.m4', + output: file, + command: [ + python3, handle_built_files, 'build_from_m4', + m4_include_dir, + '@INPUT@', + '@OUTPUT@', + ], + depend_files: m4_template, + build_by_default: maintainer_mode, + install: false, + ) + endforeach +endif diff --git a/sigc++/meson.build b/sigc++/meson.build index ca453d8..176bf5c 100644 --- a/sigc++/meson.build +++ b/sigc++/meson.build @@ -1,7 +1,8 @@ # sigc++ # Input: sigcxx_build_dep, sigcxx_pcname, sigcxx_libversion, sigcxx_api_version, -# install_includedir, project_source_root, sigc_res +# install_includedir, project_source_root, sigc_res, python3, +# handle_built_files # Output: source_h_files, built_h_files, sigcxx_own_dep, built_files_root, # built_h_file_targets @@ -33,54 +34,28 @@ functors_h_files = [ 'functors' / 'slot_base.h', ] -# .m4 files to build .h and .cc files from. -adaptors_lambda_cc_m4_files = [ - 'lambda.cc', -] +# .m4 files to build .h files from. sigc_h_m4_files = [ 'limit_reference.h', 'signal.h', ] -adaptors_h_m4_files = [ - 'adaptor_trait.h', - 'bind.h', - 'bind_return.h', - 'compose.h', - 'deduce_result_type.h', - 'exception_catch.h', - 'hide.h', - 'retype.h', - 'retype_return.h', - 'track_obj.h', -] -adaptors_lambda_h_m4_files = [ - 'base.h', - 'select.h', -] -functors_h_m4_files = [ - 'functor_trait.h', - 'mem_fun.h', - 'ptr_fun.h', - 'slot.h', -] + +m4_template = files('macros' / 'template.macros.m4') +m4_include_dir = meson.current_source_dir() / 'macros' source_h_files = sigc_h_files + adaptors_h_files + functors_h_files built_h_files = sigc_h_m4_files -foreach file : adaptors_h_m4_files - built_h_files += 'adaptors' / file -endforeach -foreach file : adaptors_lambda_h_m4_files - built_h_files += 'adaptors' / 'lambda' / file -endforeach -foreach file : functors_h_m4_files - built_h_files += 'functors' / file -endforeach - built_cc_files = [] -foreach file : adaptors_lambda_cc_m4_files - built_cc_files += 'adaptors' / 'lambda' / file -endforeach + +# Force meson+ninja to generate source files before anything is compiled. +# Compilation must depend on these targets. +built_cc_file_targets = [] +built_h_file_targets = [] + +subdir('adaptors') +subdir('adaptors/lambda') +subdir('functors') install_headers('sigc++.h', subdir: sigcxx_pcname / 'sigc++') install_headers(sigc_h_files, subdir: sigcxx_pcname / 'sigc++') @@ -107,58 +82,26 @@ endif if maintainer_mode - # Maintainer mode. Generate .h and .cc files from .m4 files in macros/ directories. + # Maintainer mode. Generate .h and .cc files from .m4 files in macros/ directory. + # .h and .cc files are also generated in subdirectories. # docs/reference/meson.build needs this. built_files_root = project_build_root - m4_and_built_files = [] - foreach file : adaptors_lambda_cc_m4_files + adaptors_lambda_h_m4_files - m4_and_built_files += [['adaptors' / 'lambda' / 'macros' / file + '.m4', - 'adaptors' / 'lambda' / file]] - endforeach foreach file : sigc_h_m4_files - m4_and_built_files += [['macros' / file + '.m4', file]] - endforeach - foreach file : adaptors_h_m4_files - m4_and_built_files += [['adaptors' / 'macros' / file + '.m4', 'adaptors' / file]] - endforeach - foreach file : functors_h_m4_files - m4_and_built_files += [['functors' / 'macros' / file + '.m4', 'functors' / file]] - endforeach - - # Force meson+ninja to generate source files before anything is compiled. - # Compilation must depend on these targets. - built_cc_file_targets = [] - built_h_file_targets = [] - - foreach m4_and_built_file : m4_and_built_files - input_file = m4_and_built_file[0] - output_file = m4_and_built_file[1] - if output_file.endswith('.cc') - stamp_file = output_file.underscorify() + '.cc' - else - stamp_file = output_file.underscorify() + '.stamp' - endif - built_file_target = custom_target(output_file.underscorify(), - input: input_file, - output: stamp_file, + built_h_file_targets += custom_target(file, + input: 'macros' / file + '.m4', + output: file, command: [ python3, handle_built_files, 'build_from_m4', - meson.current_source_dir() / 'macros', + m4_include_dir, '@INPUT@', - meson.current_build_dir() / output_file, '@OUTPUT@', ], - depend_files: 'macros' / 'template.macros.m4', + depend_files: m4_template, build_by_default: maintainer_mode, install: false, ) - if output_file.endswith('.cc') - built_cc_file_targets += built_file_target - else - built_h_file_targets += built_file_target - endif endforeach extra_include_dirs = ['..'] @@ -181,8 +124,7 @@ else # not maintainer_mode # Not maintainer mode. Compile built source code files in # project_source_root/untracked/sigc++. - # docs/reference/meson.build needs these. - built_h_file_targets = [] + # docs/reference/meson.build needs this. built_files_root = project_source_root / 'untracked' # Two cases: diff --git a/tools/handle-built-files.py b/tools/handle-built-files.py index 59601c5..150da5c 100755 --- a/tools/handle-built-files.py +++ b/tools/handle-built-files.py @@ -16,13 +16,12 @@ subcommand = sys.argv[1] # Invoked from custom_target() in meson.build. def build_from_m4(): - # argv[2] argv[3] argv[4] argv[5] - # <include_dir> <input_file> <output_file> <stamp_file> + # argv[2] argv[3] argv[4] + # <include_dir> <input_file> <output_file> include_dir = sys.argv[2] input_file = sys.argv[3] output_file = sys.argv[4] - stamp_file = sys.argv[5] # Create the destination directory, if it does not exist. output_dir = os.path.dirname(output_file) @@ -33,18 +32,8 @@ def build_from_m4(): '-I', include_dir, input_file, ] - output_file_obj = open(output_file, mode='w') - result = subprocess.run(cmd, stdout=output_file_obj) - output_file_obj.close() - - if result.returncode: - return result.returncode - - if stamp_file.endswith('.cc'): - shutil.copy(output_file, stamp_file) - else: - Path(stamp_file).touch(exist_ok=True) - return 0 + with open(output_file, mode='w') as output_file_obj: + return subprocess.run(cmd, stdout=output_file_obj).returncode # Invoked from meson.add_install_script(). def install_built_h_files(): |