diff --git a/Makefile b/Makefile index 18ce8f2..9beb3c6 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ AR = ar BUILD_TYPE = Debug BUILD_DIR = libwapp-build/$(PLATFORM)-$(BUILD_TYPE) INSTALL_PREFIX = dist +CODEGEN_INPUT = "" # Internal variables override CFLAGS = -Wall -Wextra -Werror -pedantic -Isrc @@ -54,6 +55,7 @@ help: @echo " BUILD_TYPE Build type. Choose from \`Debug\`, \`RelWithDebInfo\` or \`Release\` (Default: Debug)." @echo " BUILD_DIR Directory where build files will be written." @echo " INSTALL_PREFIX Prefix where library and include files will be installed." + @echo " CODEGEN_INPUT Input file for code generation (See codegen_custom_data_example.json for an example)." @echo @echo "Available targets:" @echo " make Build, install and test the full wapp library." @@ -113,7 +115,7 @@ run-cc-test: build-cc-test @rm $(TEST_CXX_OUT) codegen: - python3 -m codegen + python3 -m codegen -f $(CODEGEN_INPUT) install: build-lib @mkdir -p $(LIB_INSTALL) diff --git a/codegen/__main__.py b/codegen/__main__.py index e2ea776..8a45e62 100644 --- a/codegen/__main__.py +++ b/codegen/__main__.py @@ -11,7 +11,7 @@ def main(types_file: Path | None): dbl_list_datatypes: Dict[CDataType, DblListData] = {} array_datatypes: Dict[CDataType, ArrayData] = {} - if types_file is not None: + if types_file is not None and types_file.is_file() and "json" in types_file.suffix.lower(): with types_file.open("r") as infile: datatypes = json.load(infile) dbl_list_data = datatypes.get(DBL_LIST_DATA)