From 359dbc97ae610a78759fb9dbad1b89ee2540cdf0 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Sat, 4 Jul 2020 12:28:06 +0430 Subject: [PATCH] [meson] Use the recommended way to generate harfbuzz.cc As https://github.com/harfbuzz/harfbuzz/pull/2532 --- src/gen-harfbuzzcc.py | 24 ++++++++++-------------- src/meson.build | 14 +++++++------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/gen-harfbuzzcc.py b/src/gen-harfbuzzcc.py index de09fb50f..f45f14842 100755 --- a/src/gen-harfbuzzcc.py +++ b/src/gen-harfbuzzcc.py @@ -1,22 +1,18 @@ #!/usr/bin/env python3 -"usage: gen-harfbuzzcc.py harfbuzz.cc hb-blob.cc hb-buffer.cc ..." +"This tool is intended to be used from meson" -import os, sys - -os.chdir (os.path.dirname (__file__)) +import os, sys, shutil if len (sys.argv) < 3: - sys.exit (__doc__) + exit (__doc__) -output_file = sys.argv[1] -source_paths = sys.argv[2:] +OUTPUT = sys.argv[1] +CURRENT_SOURCE_DIR = sys.argv[2] +sources = sys.argv[3:] -result = "".join ('#include "{}"\n'.format (os.path.basename (x)) for x in source_paths if x.endswith (".cc")).encode () +with open (OUTPUT, "wb") as f: + f.write ("".join ('#include "{}"\n'.format (os.path.basename (x)) for x in sources if x.endswith (".cc")).encode ()) -with open (output_file, "rb") as f: - current = f.read() - -if result != current: - with open (output_file, "wb") as f: - f.write (result) +# copy it also to src/ +shutil.copyfile (OUTPUT, os.path.join (CURRENT_SOURCE_DIR, os.path.basename (OUTPUT))) diff --git a/src/meson.build b/src/meson.build index 41e5fb64a..72f6c9f9b 100644 --- a/src/meson.build +++ b/src/meson.build @@ -301,9 +301,7 @@ else input: rl, output: hh, command: [find_program('gen-ragel-artifacts.py'), - '@OUTPUT@', - '@CURRENT_SOURCE_DIR@', - '@INPUT@'], + '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@'], ) endforeach endif @@ -311,10 +309,12 @@ endif custom_target('harfbuzz.cc', build_by_default: true, output: 'harfbuzz.cc', - command: [find_program('gen-harfbuzzcc.py'), 'harfbuzz.cc'] + - hb_base_sources + hb_glib_sources + hb_ft_sources + - hb_graphite2_sources + hb_uniscribe_sources + hb_gdi_sources + - hb_directwrite_sources + hb_coretext_sources) + input: hb_base_sources + hb_glib_sources + hb_ft_sources + + hb_graphite2_sources + hb_uniscribe_sources + hb_gdi_sources + + hb_directwrite_sources + hb_coretext_sources, + command: [find_program('gen-harfbuzzcc.py'), + '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@'], +) incsrc = include_directories('.')