Skip to content

Commit

Permalink
List ssl_debug_helpers_generated.h in generated files
Browse files Browse the repository at this point in the history
Running `generate_ssl_debug_helpers.py` generates both
`ssl_debug_helpers_generated.c` and `ssl_debug_helpers_generated.h`.

List the `.h` file as well as the `.c` file in `check-generated-files.sh` so
that `check-generated-files.sh -u` will complain if it isn't up to date.

List it in `Makefile` and `CMakeLists.txt` so that parallel builds know when
to wait until the `.h` file is present. In `Makefile`, declare the `.c` file
as depending on the `.h` file for order. This way, a dependency for either
will wait until the `.h` file is present, and since the `.h` file is
generated after the `.c` file, this guarantees that the `.c` file is
present.

This fixes random failures of `make -j` from a fresh checkout.

Signed-off-by: Gilles Peskine <[email protected]>
  • Loading branch information
gilles-peskine-arm committed Dec 13, 2021
1 parent 32d2a58 commit 12e27d4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ if(GEN_FILES)

add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/ssl_debug_helpers_generated.h
${CMAKE_CURRENT_BINARY_DIR}/ssl_debug_helpers_generated.c
COMMAND
${MBEDTLS_PYTHON_EXECUTABLE}
Expand All @@ -161,6 +162,7 @@ else()
link_to_source(error.c)
link_to_source(version_features.c)
link_to_source(ssl_debug_helpers_generated.c)
link_to_source(ssl_debug_helpers_generated.h)
endif()

if(CMAKE_COMPILER_IS_GNUCC)
Expand Down
11 changes: 7 additions & 4 deletions library/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,9 @@ libmbedcrypto.dll: $(OBJS_CRYPTO)
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -o $@ -c $<

.PHONY: generated_files
GENERATED_FILES = error.c version_features.c ssl_debug_helpers_generated.c
GENERATED_FILES = \
error.c version_features.c \
ssl_debug_helpers_generated.c ssl_debug_helpers_generated.h
generated_files: $(GENERATED_FILES)

error.c: ../scripts/generate_errors.pl
Expand All @@ -298,9 +300,10 @@ error.c:
echo " Gen $@"
$(PERL) ../scripts/generate_errors.pl

ssl_debug_helpers_generated.c: ../scripts/generate_ssl_debug_helpers.py
ssl_debug_helpers_generated.c: $(filter-out %config%,$(wildcard ../include/mbedtls/*.h))
ssl_debug_helpers_generated.c:
ssl_debug_helpers_generated.c: | ssl_debug_helpers_generated.h
ssl_debug_helpers_generated.h: ../scripts/generate_ssl_debug_helpers.py
ssl_debug_helpers_generated.h: $(filter-out %config%,$(wildcard ../include/mbedtls/*.h))
ssl_debug_helpers_generated.h:
echo " Gen $@"
$(PYTHON) ../scripts/generate_ssl_debug_helpers.py --mbedtls-root .. .

Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/check-generated-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ check()
check scripts/generate_errors.pl library/error.c
check scripts/generate_query_config.pl programs/test/query_config.c
check scripts/generate_features.pl library/version_features.c
check scripts/generate_ssl_debug_helpers.py library/ssl_debug_helpers_generated.c
check scripts/generate_ssl_debug_helpers.py library/ssl_debug_helpers_generated.h library/ssl_debug_helpers_generated.c
# generate_visualc_files enumerates source files (library/*.c). It doesn't
# care about their content, but the files must exist. So it must run after
# the step that creates or updates these files.
Expand Down

0 comments on commit 12e27d4

Please sign in to comment.