]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Genererate confitem number fields in confitems.gperf
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 5 Jan 2019 09:56:13 +0000 (10:56 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 5 Jan 2019 21:18:36 +0000 (22:18 +0100)
When merging diverging confitems.gperf changes it is always a hassle to
regenerate the config number sequence fields by hand, and they also
trigger merge conflicts. Those numbers are now instead generated
automatically.

dev.mk.in
src/confitems.gperf

index 2abddb594fd723d5b1be1e472e988d5f34dc4dc9..50576e538526b477242a370b8aa89d2fa743cd1f 100644 (file)
--- a/dev.mk.in
+++ b/dev.mk.in
@@ -115,18 +115,23 @@ ifneq ($(shell sed 's/.*"\(.*\)".*/\1/' src/version.c 2>/dev/null),$(version))
 endif
 src/version.o: src/version.c
 
+# $(1): Name.
+# $(2): Command for fixing up source file before the gperf call.
 define generate_gperf_lookup
 src/$(1)_lookup.c: src/$(1).gperf
        $$(if $$(quiet),@echo "  GEN      $$@")
-       $$(Q)$$(GPERF) $$< >$$@.tmp
+       $$(Q)$(2) $$< | $$(GPERF) >$$@.tmp
 # Fix for gperf < 3.1 (fix parameter type and remove inlining of the get function):
        $$(Q)perl -00 -pi -e 's/unsigned int len/size_t len/; s/#ifdef __GNUC__.*?gnu_inline.*?#endif\n#endif\n//sg' $$@.tmp
        $$(Q)echo "size_t $(1)_count(void) { return $$$$(perl -ne '/TOTAL_KEYWORDS = (.+?),/ && print $$$$1' $$@.tmp); }" >>$$@.tmp
        $$(Q)mv $$@.tmp $$@
 endef
 
-$(eval $(call generate_lookup_table,confitems))
-$(eval $(call generate_lookup_table,envtoconfitems))
+add_confitems_numbers = \
+    perl -pae '$$$$s = 1 if /^%%/; s/ITEM/$$$$n++ . ", ITEM"/e if $$$$s == 1'
+
+$(eval $(call generate_gperf_lookup,confitems,$(add_confitems_numbers)))
+$(eval $(call generate_gperf_lookup,envtoconfitems,cat))
 
 .PHONY: dist
 dist: $(dist_archives)
index 46cfd377266a7d6c0abc818359e9c558564cc132..828e62eb3f4a566e6ff8a756735137060aeba8c4 100644 (file)
 %}
 struct conf_item;
 %%
-base_dir,             0, ITEM_V(base_dir, env_string, absolute_path)
-cache_dir,            1, ITEM(cache_dir, env_string)
-cache_dir_levels,     2, ITEM_V(cache_dir_levels, unsigned, dir_levels)
-compiler,             3, ITEM(compiler, string)
-compiler_check,       4, ITEM(compiler_check, string)
-compression,          5, ITEM(compression, bool)
-compression_level,    6, ITEM(compression_level, unsigned)
-cpp_extension,        7, ITEM(cpp_extension, string)
-debug,                8, ITEM(debug, bool)
-depend_mode,          9, ITEM(depend_mode, bool)
-direct_mode,         10, ITEM(direct_mode, bool)
-disable,             11, ITEM(disable, bool)
-extra_files_to_hash, 12, ITEM(extra_files_to_hash, env_string)
-hard_link,           13, ITEM(hard_link, bool)
-hash_dir,            14, ITEM(hash_dir, bool)
-ignore_headers_in_manifest, 15, ITEM(ignore_headers_in_manifest, env_string)
-keep_comments_cpp,   16, ITEM(keep_comments_cpp, bool)
-limit_multiple,      17, ITEM(limit_multiple, double)
-log_file,            18, ITEM(log_file, env_string)
-max_files,           19, ITEM(max_files, unsigned)
-max_size,            20, ITEM(max_size, size)
-path,                21, ITEM(path, env_string)
-pch_external_checksum, 22, ITEM(pch_external_checksum, bool)
-prefix_command,      23, ITEM(prefix_command, env_string)
-prefix_command_cpp,  24, ITEM(prefix_command_cpp, env_string)
-read_only,           25, ITEM(read_only, bool)
-read_only_direct,    26, ITEM(read_only_direct, bool)
-recache,             27, ITEM(recache, bool)
-run_second_cpp,      28, ITEM(run_second_cpp, bool)
-sloppiness,          29, ITEM(sloppiness, sloppiness)
-stats,               30, ITEM(stats, bool)
-temporary_dir,       31, ITEM(temporary_dir, env_string)
-umask,               32, ITEM(umask, umask)
-unify,               33, ITEM(unify, bool)
+base_dir,                   ITEM_V(base_dir, env_string, absolute_path)
+cache_dir,                  ITEM(cache_dir, env_string)
+cache_dir_levels,           ITEM_V(cache_dir_levels, unsigned, dir_levels)
+compiler,                   ITEM(compiler, string)
+compiler_check,             ITEM(compiler_check, string)
+compression,                ITEM(compression, bool)
+compression_level,          ITEM(compression_level, unsigned)
+cpp_extension,              ITEM(cpp_extension, string)
+debug,                      ITEM(debug, bool)
+depend_mode,                ITEM(depend_mode, bool)
+direct_mode,                ITEM(direct_mode, bool)
+disable,                    ITEM(disable, bool)
+extra_files_to_hash,        ITEM(extra_files_to_hash, env_string)
+hard_link,                  ITEM(hard_link, bool)
+hash_dir,                   ITEM(hash_dir, bool)
+ignore_headers_in_manifest, ITEM(ignore_headers_in_manifest, env_string)
+keep_comments_cpp,          ITEM(keep_comments_cpp, bool)
+limit_multiple,             ITEM(limit_multiple, double)
+log_file,                   ITEM(log_file, env_string)
+max_files,                  ITEM(max_files, unsigned)
+max_size,                   ITEM(max_size, size)
+path,                       ITEM(path, env_string)
+pch_external_checksum,      ITEM(pch_external_checksum, bool)
+prefix_command,             ITEM(prefix_command, env_string)
+prefix_command_cpp,         ITEM(prefix_command_cpp, env_string)
+read_only,                  ITEM(read_only, bool)
+read_only_direct,           ITEM(read_only_direct, bool)
+recache,                    ITEM(recache, bool)
+run_second_cpp,             ITEM(run_second_cpp, bool)
+sloppiness,                 ITEM(sloppiness, sloppiness)
+stats,                      ITEM(stats, bool)
+temporary_dir,              ITEM(temporary_dir, env_string)
+umask,                      ITEM(umask, umask)
+unify,                      ITEM(unify, bool)