From e4d2319a1153b5c721584d11b1e30b4646868fb7 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 9 Sep 2026 22:59:53 -0700 Subject: [PATCH 1/4] build: rebuild the generated sources when the generator changes The stamps that drive the generation only depend on json_common.{c,h}, so a change to generate.py or to the modules it imports does not trigger anything: make reports there is nothing to be done, the tree keeps the sources generated by the previous version of the generator, and the change appears to have no effect until someone cleans the tree by hand. Add the generator sources to the prerequisites of every stamp. Signed-off-by: Kir Kolyshkin --- Makefile.am | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Makefile.am b/Makefile.am index 6ea1b983..0577b5f1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -57,20 +57,29 @@ ocispec_include_HEADERS = $(HEADER_FILES) \ src/ocispec/json_common.h endif -src/runtime_spec_stamp: src/ocispec/json_common.h src/ocispec/json_common.c +GENERATOR_FILES = \ + src/ocispec/generate.py \ + src/ocispec/headers.py \ + src/ocispec/helpers.py \ + src/ocispec/json_api.py \ + src/ocispec/sources.py + +STAMP_DEPS = src/ocispec/json_common.h src/ocispec/json_common.c $(GENERATOR_FILES) + +src/runtime_spec_stamp: $(STAMP_DEPS) $(PYTHON) $(srcdir)/src/ocispec/generate.py --gen-ref --root=${srcdir} --out=${builddir}/src/ocispec ${srcdir}/runtime-spec/schema @touch $@ -src/image_spec_stamp: src/ocispec/json_common.h src/ocispec/json_common.c +src/image_spec_stamp: $(STAMP_DEPS) $(PYTHON) $(srcdir)/src/ocispec/generate.py --gen-ref --root=${srcdir} --out=${builddir}/src/ocispec ${srcdir}/image-spec/schema @touch $@ -src/image_manifest_stamp: src/ocispec/json_common.h src/ocispec/json_common.c +src/image_manifest_stamp: $(STAMP_DEPS) $(PYTHON) $(srcdir)/src/ocispec/generate.py --gen-ref --root=${srcdir}/tests/test-spec --out=${builddir}/src/ocispec ${srcdir}/tests/test-spec/imageManifestItems @touch $@ -src/basic-test_stamp: src/ocispec/json_common.h src/ocispec/json_common.c +src/basic-test_stamp: $(STAMP_DEPS) $(PYTHON) $(srcdir)/src/ocispec/generate.py --gen-ref --root=${srcdir}/tests/test-spec --out=${builddir}/src/ocispec ${srcdir}/tests/test-spec/basic @touch $@ @@ -268,11 +277,7 @@ EXTRA_DIST = autogen.sh \ tests/data/map-string-string-array.json \ tests/data/int64_values.json \ tests/test-spec \ - src/ocispec/generate.py \ - src/ocispec/headers.py \ - src/ocispec/helpers.py \ - src/ocispec/json_api.py \ - src/ocispec/sources.py \ + $(GENERATOR_FILES) \ $(HEADER_FILES) \ runtime-spec \ image-spec \ From 6630c3f0bcc3bf90cb7c1fd0ceb8589d662edc77 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 10 Sep 2026 13:26:20 -0700 Subject: [PATCH 2/4] build: drop a stray empty line in a recipe The empty line in the middle of the src/image_spec_stamp recipe is harmless but confusing; remove it. Signed-off-by: Kir Kolyshkin --- Makefile.am | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 0577b5f1..b21d54b3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -72,7 +72,6 @@ src/runtime_spec_stamp: $(STAMP_DEPS) src/image_spec_stamp: $(STAMP_DEPS) $(PYTHON) $(srcdir)/src/ocispec/generate.py --gen-ref --root=${srcdir} --out=${builddir}/src/ocispec ${srcdir}/image-spec/schema - @touch $@ src/image_manifest_stamp: $(STAMP_DEPS) From 25831bd6422f8ce82a4d08acd6b54b19ea3380c4 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 10 Sep 2026 13:26:35 -0700 Subject: [PATCH 3/4] build: derive the generated files from the generator groups Every generated source and header was listed twice: once in SOURCE_FILES, and once more in a hand-written rule tying it to the stamp of the generator run that produces it. The two lists drifted apart -- runtime_spec_schema_config_zos.h was missing from the stamp rules entirely, and only the $(HEADER_FILES): %.h: %.c rule kept it building. Split SOURCE_FILES into one variable per generator run and derive the stamp prerequisites from those, headers included. The lists are now stated once, and a file added to a group cannot be forgotten in the rules. The $(HEADER_FILES): %.h: %.c rule becomes redundant: every header now depends on its stamp directly. Signed-off-by: Kir Kolyshkin --- Makefile.am | 118 +++++++++++++--------------------------------------- 1 file changed, 30 insertions(+), 88 deletions(-) diff --git a/Makefile.am b/Makefile.am index b21d54b3..c7f76cd3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,41 +13,50 @@ noinst_LTLIBRARIES = libocispec.la noinst_LIBRARIES = libocispec.a endif -SOURCE_FILES = \ - src/ocispec/image_spec_schema_config_schema.c \ - src/ocispec/image_spec_schema_content_descriptor.c \ - src/ocispec/image_spec_schema_defs.c \ - src/ocispec/image_spec_schema_defs_descriptor.c \ - src/ocispec/image_spec_schema_image_index_schema.c \ - src/ocispec/image_spec_schema_image_layout_schema.c \ - src/ocispec/image_spec_schema_image_manifest_schema.c \ +IMAGE_SPEC_SOURCES = \ + src/ocispec/image_spec_schema_config_schema.c \ + src/ocispec/image_spec_schema_content_descriptor.c \ + src/ocispec/image_spec_schema_defs.c \ + src/ocispec/image_spec_schema_defs_descriptor.c \ + src/ocispec/image_spec_schema_image_index_schema.c \ + src/ocispec/image_spec_schema_image_layout_schema.c \ + src/ocispec/image_spec_schema_image_manifest_schema.c + +RUNTIME_SPEC_SOURCES = \ src/ocispec/runtime_spec_schema_config_freebsd.c \ src/ocispec/runtime_spec_schema_config_linux.c \ - src/ocispec/runtime_spec_schema_config_zos.c \ src/ocispec/runtime_spec_schema_config_schema.c \ src/ocispec/runtime_spec_schema_config_solaris.c \ src/ocispec/runtime_spec_schema_config_vm.c \ src/ocispec/runtime_spec_schema_config_windows.c \ + src/ocispec/runtime_spec_schema_config_zos.c \ src/ocispec/runtime_spec_schema_defs.c \ src/ocispec/runtime_spec_schema_defs_freebsd.c \ src/ocispec/runtime_spec_schema_defs_linux.c \ - src/ocispec/runtime_spec_schema_defs_zos.c \ src/ocispec/runtime_spec_schema_defs_vm.c \ src/ocispec/runtime_spec_schema_defs_windows.c \ - src/ocispec/runtime_spec_schema_state_schema.c \ + src/ocispec/runtime_spec_schema_defs_zos.c \ src/ocispec/runtime_spec_schema_features_linux.c \ src/ocispec/runtime_spec_schema_features_schema.c \ - src/ocispec/image_manifest_items_image_manifest_items_schema.c \ - src/ocispec/basic_test_double_array_item.c \ + src/ocispec/runtime_spec_schema_state_schema.c + +IMAGE_MANIFEST_SOURCES = \ + src/ocispec/image_manifest_items_image_manifest_items_schema.c + +BASIC_TEST_SOURCES = \ src/ocispec/basic_test_double_array.c \ + src/ocispec/basic_test_double_array_item.c \ + src/ocispec/basic_test_int64_values.c \ + src/ocispec/basic_test_map_string_string_array.c \ src/ocispec/basic_test_top_array_int.c \ src/ocispec/basic_test_top_array_string.c \ src/ocispec/basic_test_top_double_array_int.c \ src/ocispec/basic_test_top_double_array_obj.c \ src/ocispec/basic_test_top_double_array_refobj.c \ - src/ocispec/basic_test_top_double_array_string.c \ - src/ocispec/basic_test_int64_values.c \ - src/ocispec/basic_test_map_string_string_array.c + src/ocispec/basic_test_top_double_array_string.c + +SOURCE_FILES = $(IMAGE_SPEC_SOURCES) $(RUNTIME_SPEC_SOURCES) \ + $(IMAGE_MANIFEST_SOURCES) $(BASIC_TEST_SOURCES) HEADER_FILES = $(SOURCE_FILES:.c=.h) @@ -82,78 +91,11 @@ src/basic-test_stamp: $(STAMP_DEPS) $(PYTHON) $(srcdir)/src/ocispec/generate.py --gen-ref --root=${srcdir}/tests/test-spec --out=${builddir}/src/ocispec ${srcdir}/tests/test-spec/basic @touch $@ -src/ocispec/image_spec_schema_config_schema.c \ - src/ocispec/image_spec_schema_content_descriptor.c \ - src/ocispec/image_spec_schema_defs.c \ - src/ocispec/image_spec_schema_defs_descriptor.c \ - src/ocispec/image_spec_schema_image_index_schema.c \ - src/ocispec/image_spec_schema_image_layout_schema.c \ - src/ocispec/image_spec_schema_image_manifest_schema.c \ - src/ocispec/image_spec_schema_config_schema.h \ - src/ocispec/image_spec_schema_content_descriptor.h \ - src/ocispec/image_spec_schema_defs.h \ - src/ocispec/image_spec_schema_defs_descriptor.h \ - src/ocispec/image_spec_schema_image_index_schema.h \ - src/ocispec/image_spec_schema_image_layout_schema.h \ - src/ocispec/image_spec_schema_image_manifest_schema.h: src/image_spec_stamp - -src/ocispec/runtime_spec_schema_config_linux.h \ - src/ocispec/runtime_spec_schema_config_schema.h \ - src/ocispec/runtime_spec_schema_config_solaris.h \ - src/ocispec/runtime_spec_schema_config_vm.h \ - src/ocispec/runtime_spec_schema_config_windows.h \ - src/ocispec/runtime_spec_schema_defs.h \ - src/ocispec/runtime_spec_schema_defs_linux.h \ - src/ocispec/runtime_spec_schema_defs_zos.h \ - src/ocispec/runtime_spec_schema_features_linux.h \ - src/ocispec/runtime_spec_schema_features_schema.h \ - src/ocispec/runtime_spec_schema_features_linux.c \ - src/ocispec/runtime_spec_schema_features_schema.c \ - src/ocispec/runtime_spec_schema_defs_vm.h \ - src/ocispec/runtime_spec_schema_defs_windows.h \ - src/ocispec/runtime_spec_schema_state_schema.h \ - src/ocispec/runtime_spec_schema_config_linux.c \ - src/ocispec/runtime_spec_schema_config_zos.c \ - src/ocispec/runtime_spec_schema_config_schema.c \ - src/ocispec/runtime_spec_schema_config_solaris.c \ - src/ocispec/runtime_spec_schema_config_vm.c \ - src/ocispec/runtime_spec_schema_config_windows.c \ - src/ocispec/runtime_spec_schema_defs.c \ - src/ocispec/runtime_spec_schema_defs_linux.c \ - src/ocispec/runtime_spec_schema_defs_vm.c \ - src/ocispec/runtime_spec_schema_defs_zos.c \ - src/ocispec/runtime_spec_schema_defs_windows.c \ - src/ocispec/runtime_spec_schema_config_freebsd.h \ - src/ocispec/runtime_spec_schema_defs_freebsd.h \ - src/ocispec/runtime_spec_schema_config_freebsd.c \ - src/ocispec/runtime_spec_schema_defs_freebsd.c \ - src/ocispec/runtime_spec_schema_state_schema.c: src/runtime_spec_stamp - -src/ocispec/image_manifest_items_image_manifest_items_schema.h \ - src/ocispec/image_manifest_items_image_manifest_items_schema.c: src/image_manifest_stamp - -src/ocispec/basic_test_double_array_item.h \ - src/ocispec/basic_test_double_array.h \ - src/ocispec/basic_test_top_array_int.h \ - src/ocispec/basic_test_top_array_string.h \ - src/ocispec/basic_test_top_double_array_int.h \ - src/ocispec/basic_test_top_double_array_obj.h \ - src/ocispec/basic_test_top_double_array_refobj.h \ - src/ocispec/basic_test_top_double_array_string.h \ - src/ocispec/basic_test_map_string_string_array.h \ - src/ocispec/basic_test_double_array_item.c \ - src/ocispec/basic_test_double_array.c \ - src/ocispec/basic_test_top_array_int.c \ - src/ocispec/basic_test_top_array_string.c \ - src/ocispec/basic_test_top_double_array_int.c \ - src/ocispec/basic_test_top_double_array_obj.c \ - src/ocispec/basic_test_top_double_array_refobj.c \ - src/ocispec/basic_test_top_double_array_string.c \ - src/ocispec/basic_test_int64_values.h \ - src/ocispec/basic_test_int64_values.c \ - src/ocispec/basic_test_map_string_string_array.c: src/basic-test_stamp - -$(HEADER_FILES): %.h: %.c src/ocispec/generate.py +# Each group of sources and matching headers comes out of one generator run. +$(IMAGE_SPEC_SOURCES) $(IMAGE_SPEC_SOURCES:.c=.h): src/image_spec_stamp +$(RUNTIME_SPEC_SOURCES) $(RUNTIME_SPEC_SOURCES:.c=.h): src/runtime_spec_stamp +$(IMAGE_MANIFEST_SOURCES) $(IMAGE_MANIFEST_SOURCES:.c=.h): src/image_manifest_stamp +$(BASIC_TEST_SOURCES) $(BASIC_TEST_SOURCES:.c=.h): src/basic-test_stamp BUILT_SOURCES = $(HEADER_FILES) $(SOURCE_FILES) From 2d20179996621d2b1dba603768c42feb03edaa86 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 10 Sep 2026 13:26:35 -0700 Subject: [PATCH 4/4] build: use automake defaults for the test programs Automake defaults prog_SOURCES to the program name with a .c suffix, and prog_LDADD to LDADD, so the per-test blocks only restated the defaults. Set LDADD once and drop them, along with TESTS_LDADD. Signed-off-by: Kir Kolyshkin --- Makefile.am | 54 ++--------------------------------------------------- 1 file changed, 2 insertions(+), 52 deletions(-) diff --git a/Makefile.am b/Makefile.am index c7f76cd3..4650b093 100644 --- a/Makefile.am +++ b/Makefile.am @@ -107,7 +107,8 @@ TMP_C_FILES = $(SOURCE_FILES:.c=.c.tmp) CLEANFILES += $(HEADER_FILES) $(SOURCE_FILES) $(TMP_H_FILES) $(TMP_C_FILES) -TESTS_LDADD = libocispec.la $(SELINUX_LIBS) $(JSON_C_LIBS) +# Default for every program built here; no per-program _LDADD needed. +LDADD = libocispec.la $(SELINUX_LIBS) $(JSON_C_LIBS) libocispec_a_SOURCES = @@ -119,57 +120,6 @@ pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = ocispec.pc endif -tests_test_1_SOURCES = tests/test-1.c -tests_test_1_LDADD = $(TESTS_LDADD) - -tests_test_2_SOURCES = tests/test-2.c -tests_test_2_LDADD = $(TESTS_LDADD) - -tests_test_3_SOURCES = tests/test-3.c -tests_test_3_LDADD = $(TESTS_LDADD) - -tests_test_4_SOURCES = tests/test-4.c -tests_test_4_LDADD = $(TESTS_LDADD) - -tests_test_5_SOURCES = tests/test-5.c -tests_test_5_LDADD = $(TESTS_LDADD) - -tests_test_6_SOURCES = tests/test-6.c -tests_test_6_LDADD = $(TESTS_LDADD) - -tests_test_7_SOURCES = tests/test-7.c -tests_test_7_LDADD = $(TESTS_LDADD) - -tests_test_8_SOURCES = tests/test-8.c -tests_test_8_LDADD = $(TESTS_LDADD) - -tests_test_9_SOURCES = tests/test-9.c -tests_test_9_LDADD = $(TESTS_LDADD) - -tests_test_10_SOURCES = tests/test-10.c -tests_test_10_LDADD = $(TESTS_LDADD) - -tests_test_11_SOURCES = tests/test-11.c -tests_test_11_LDADD = $(TESTS_LDADD) - -tests_test_12_SOURCES = tests/test-12.c -tests_test_12_LDADD = $(TESTS_LDADD) - -tests_test_13_SOURCES = tests/test-13.c -tests_test_13_LDADD = $(TESTS_LDADD) - -tests_test_14_SOURCES = tests/test-14.c -tests_test_14_LDADD = $(TESTS_LDADD) - -tests_test_15_SOURCES = tests/test-15.c -tests_test_15_LDADD = $(TESTS_LDADD) - -tests_test_16_SOURCES = tests/test-16.c -tests_test_16_LDADD = $(TESTS_LDADD) - -src_ocispec_validate_SOURCES = src/ocispec/validate.c -src_ocispec_validate_LDADD = $(TESTS_LDADD) - TESTS = tests/test-1 \ tests/test-2 \ tests/test-3 \