From 27cdf8d389d63c7f52f49028bca7d3274340c5de Mon Sep 17 00:00:00 2001 From: Gregor Weiss Date: Fri, 12 Apr 2024 12:13:47 +0200 Subject: [PATCH 1/3] hardcode somewhat logical order of header files in public_header.py append possibly missing header files assumes that missing header files need no dedicated position in list --- public_header.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/public_header.py b/public_header.py index 595ebd8..1e5855e 100644 --- a/public_header.py +++ b/public_header.py @@ -91,9 +91,12 @@ destination = current_path.joinpath('include/library/public') if os.path.isdir(destination) == False: os.mkdir(destination) -header_files = [f for f in os.listdir(source) if os.path.isfile(os.path.join(source, f))] -header_files.remove('prim_types_double.h') -header_files.remove('prim_types_single.h') +all_header_files = [f for f in os.listdir(source) if os.path.isfile(os.path.join(source, f))] +all_header_files.remove('prim_types_double.h') +all_header_files.remove('prim_types_single.h') +header_files = ['macros.h', 'constants.h', 'dwt.h', 'tagtree.h', 'mq_types.h', 'mq.h', + 'bitstream.h', 'codestream.h', 'tier1.h', 'tier2.h', 'types.h', 'libbwc.h'] +header_files += [element for element in all_header_files if element not in header_files] print(header_files) #----------------------------------------------------------# From f66091747a63b0a1bbb7fe240c34ab2dce4a7a12 Mon Sep 17 00:00:00 2001 From: Gregor Weiss Date: Mon, 15 Apr 2024 13:57:12 +0200 Subject: [PATCH 2/3] Warn if new header files in include/library/private are not included in either include_files or exclude_files lists for bwc.h generation. --- public_header.py | 21 ++++++++++++--------- src/library/CMakeLists.txt | 8 +++++++- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/public_header.py b/public_header.py index 1e5855e..1d111a1 100644 --- a/public_header.py +++ b/public_header.py @@ -91,13 +91,16 @@ destination = current_path.joinpath('include/library/public') if os.path.isdir(destination) == False: os.mkdir(destination) -all_header_files = [f for f in os.listdir(source) if os.path.isfile(os.path.join(source, f))] -all_header_files.remove('prim_types_double.h') -all_header_files.remove('prim_types_single.h') -header_files = ['macros.h', 'constants.h', 'dwt.h', 'tagtree.h', 'mq_types.h', 'mq.h', +include_files = ['macros.h', 'constants.h', 'dwt.h', 'tagtree.h', 'mq_types.h', 'mq.h', 'bitstream.h', 'codestream.h', 'tier1.h', 'tier2.h', 'types.h', 'libbwc.h'] -header_files += [element for element in all_header_files if element not in header_files] -print(header_files) +exclude_files = ["prim_types_double.h", "prim_types_single.h"] +all_files = [f for f in os.listdir(source) if os.path.isfile(os.path.join(source, f))] +missing_files = [f for f in all_files if f not in include_files and f not in exclude_files] +if missing_files: + raise Warning("Consider updating public_header.py. Missing header file(s)" + f"\n{missing_files}\n" + "should be added to include_files or exclude_files lists.") +print(include_files) #----------------------------------------------------------# # Create the I/O stream and write the bwc file header. # @@ -216,7 +219,7 @@ printFlg = False buff = "" brktCnt = 0 -for file in header_files: +for file in include_files: with open(source.joinpath(file)) as f: for line in f: if("BWC_" in line): @@ -253,7 +256,7 @@ public_header.write(ubox + tab + sbox + lspaces * " " + "____ ____ _ _ ____ ___ delimFlg = False buff = "" -for file in header_files: +for file in include_files: with open(source.joinpath(file)) as f: for line in f: if("typedef enum" in line): @@ -291,7 +294,7 @@ preProcFlg = False buff = "" brktCnt = 0 -for file in header_files: +for file in include_files: with open(source.joinpath(file)) as f: for line in f: if("typedef struct" in line or diff --git a/src/library/CMakeLists.txt b/src/library/CMakeLists.txt index d760a60..549453e 100755 --- a/src/library/CMakeLists.txt +++ b/src/library/CMakeLists.txt @@ -57,7 +57,13 @@ if("${PREC}" STREQUAL "Single") endif() execute_process(COMMAND python3 public_header.py ${PYTHON_ARGUMENT} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + RESULT_VARIABLE result + ERROR_VARIABLE error_output) + +if(result) + message(WARNING "Public header generation failed: ${error_output}") +endif() #----------------------------------------------------------# # Set the linking type according to user choice and add # From ecf6c6ffc1061a69e3a981296cab24719a4cb2a0 Mon Sep 17 00:00:00 2001 From: Gregor Weiss Date: Mon, 15 Apr 2024 16:08:59 +0200 Subject: [PATCH 3/3] Reset printFlg during derived types parsing. --- public_header.py | 1 + 1 file changed, 1 insertion(+) diff --git a/public_header.py b/public_header.py index 1d111a1..d5c5f45 100644 --- a/public_header.py +++ b/public_header.py @@ -317,6 +317,7 @@ for file in include_files: public_header.write(deliminator) public_header.write(buff) delimFlg = True + printFlg = False buff = "" f.close