From 3bee1bbc91ef19360a539a490cae98000f0c6b0f Mon Sep 17 00:00:00 2001 From: Alina Lenk <alina.v.lenk@gmail.com> Date: Mon, 11 Apr 2022 00:07:35 +0200 Subject: [PATCH] generate_packets.py: Don't lazy-overwrite unless requested at configure-time See osdn #43995 Signed-off-by: Alina Lenk <alina.v.lenk@gmail.com> --- common/Makefile.am | 3 ++- common/generate_packets.py | 11 +++++------ configure.ac | 4 ++-- doc/INSTALL.meson | 3 +++ meson.build | 8 +++++--- meson_options.txt | 5 +++++ 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/common/Makefile.am b/common/Makefile.am index 1c4fede216..8eec80b17e 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -169,7 +169,8 @@ packets_generate: networking/packets.def generate_packets.py --client-h ../client/packhand_gen.h \ --client-c ../client/packhand_gen.c \ --server-h ../server/hand_gen.h \ - --server-c ../server/hand_gen.c + --server-c ../server/hand_gen.c \ + $(GENERATE_PACKETS_ARGS) touch packets_generate # These files are not generated to builddir, but to srcdir */ diff --git a/common/generate_packets.py b/common/generate_packets.py index 76f0d907d0..6a18eade03 100755 --- a/common/generate_packets.py +++ b/common/generate_packets.py @@ -30,7 +30,7 @@ from itertools import chain, combinations # See get_argparser for what each of these does # Keep initial values in sync with argparser defaults is_verbose = False -lazy_overwrite = True +lazy_overwrite = False generate_stats = False generate_logs = True use_log_macro = "log_packet_detailed" @@ -108,13 +108,12 @@ def get_argparser(): script.add_argument("-v", "--verbose", action = "store_true", help = "enable log messages during code generation") - # Default behavior: Only overwrite existing output files when they + # When enabled: Only overwrite existing output files when they # actually changed. This prevents make from rebuilding all dependents # in cases where that wouldn't even be necessary. - script.add_argument("-f", "--force-overwrite", - dest = "lazy_overwrite", action = "store_false", - help = "always overwrite output files, even when" - " their contents didn't change") + script.add_argument("--lazy-overwrite", action = "store_true", + help = "only overwrite output files when their" + " contents actually changed") output.add_argument("-s", "--gen-stats", action = "store_true", help = "generate code reporting packet usage" diff --git a/configure.ac b/configure.ac index 2d3662b162..e37fbd3a51 100644 --- a/configure.ac +++ b/configure.ac @@ -468,8 +468,8 @@ AS_IF([test "x$enable_delta_protocol" = "xno"], [ AC_MSG_WARN([won't be able to play with regular Freeciv])],[ AC_DEFINE([FREECIV_DELTA_PROTOCOL], [1], [Delta protocol enabled])]) -dnl done setting arguments for the packet generator -AC_SUBST([GENERATE_PACKETS_ARGS]) +dnl extra arguments for the packet generator +AC_ARG_VAR([GENERATE_PACKETS_ARGS], [Additional arguments for the packet generator]) FC_WEB_OPTIONS diff --git a/doc/INSTALL.meson b/doc/INSTALL.meson index a78c3444b4..4d707fdfee 100644 --- a/doc/INSTALL.meson +++ b/doc/INSTALL.meson @@ -135,6 +135,9 @@ gitrev (boolean): freeciv-web (boolean): Build freeciv-web version instead of normal one. +gen-packets-args (array): + Aditional packet generator arguments passed to common/generate_packets.py. + run.sh ------ diff --git a/meson.build b/meson.build index 3b10a169e7..79ac0786d3 100644 --- a/meson.build +++ b/meson.build @@ -448,6 +448,8 @@ if get_option('nls') subdir('translations/ruledit') endif +gen_packets_args = get_option('gen-packets-args') + python_exe = find_program('python3') sh_exe = find_program('sh') @@ -487,20 +489,20 @@ pack_common = custom_target('packets_common', output: ['packets_gen.h', 'packets_gen.c'], command: [python_exe, files('common/generate_packets.py'), '--common-h', '@OUTPUT0@', - '--common-c', '@OUTPUT1@'], + '--common-c', '@OUTPUT1@'] + gen_packets_args, depend_files: files('common/networking/packets.def')) pack_server = custom_target('packets_server', output: ['hand_gen.h', 'hand_gen.c'], command: [python_exe, files('common/generate_packets.py'), '--server-h', '@OUTPUT0@', - '--server-c', '@OUTPUT1@'], + '--server-c', '@OUTPUT1@'] + gen_packets_args, depend_files: files('common/networking/packets.def')) pack_client = custom_target('packets_client', output: ['packhand_gen.h', 'packhand_gen.c'], command: [python_exe, files('common/generate_packets.py'), '--client-h', '@OUTPUT0@', - '--client-c', '@OUTPUT1@'], + '--client-c', '@OUTPUT1@'] + gen_packets_args, depend_files: files('common/networking/packets.def')) gitrev = custom_target('gitrev', output: 'fc_gitrev_gen.h', diff --git a/meson_options.txt b/meson_options.txt index 204e86ce9e..91d2656cff 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -54,3 +54,8 @@ option('freeciv-web', type: 'boolean', value: false, description: 'Make a freeciv-web server build instead of normal one') + +option('gen-packets-args', + type: 'array', + value: [], + description: 'Additional arguments for the packet generator') -- 2.17.1