From e745e45e27448cc5d341af05afd318d3c6c1978f Mon Sep 17 00:00:00 2001 From: "Federico M. Facca" Date: Wed, 16 Oct 2024 13:54:52 +0200 Subject: [PATCH] fix makefile to support 3.0.0 --- Makefile | 8 ++++-- README.md | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 78 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index e1b7b033..0b2c7aed 100644 --- a/Makefile +++ b/Makefile @@ -9,15 +9,19 @@ else LANGUAGE_DEPS = image endif +# Extract version from SCHEMA (CGMES_2.4.15_27JAN2020 => 2_4_15) +CGMES_VERSION=$(subst .,_,$(wordlist 2,4,$(subst _, ,$(SCHEMA)))) + all: $(LANGUAGES) $(LANGUAGES): $(LANGUAGE_DEPS) $(CIMGEN) \ --outdir=output/$@/$(SCHEMA) \ --schemadir=cgmes_schema/$(SCHEMA) \ - --langdir=$@ + --langdir=$@ \ + --cgmes_version=cgmes_v$(CGMES_VERSION) image: docker build -t cimgen -f Dockerfile . -.PHONY: all image python modernpython java javascript +.PHONY: all image $(LANGUAGES) diff --git a/README.md b/README.md index eb52133b..c31918fa 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,19 @@ cimgen --outdir=output/cpp/CGMES_2.4.15_27JAN2020 --schemadir=cgmes_schema/CGMES This will build version `CGMES_2.4.15_27JAN2020` in the subfolder `output/cpp/CGMES_2.4.15_27JAN2020`. -If you wish to build an alternative version, you can see available options in the subfolder called `cgmes_schema`. -For the schema `CGMES_3.0.0` you have to use the option `--cgmes_version=cgmes_v3_0_0`. +> [!NOTE] +> If you wish to build an alternative version, you can see available options in the subfolder called `cgmes_schema`. +> For the schema `CGMES_3.0.0` you have to use the option +> `--cgmes_version=cgmes_v3_0_0`. `outdir` can be set to whichever absolute path you wish to create the files in. + +Alternatively, you can leverage `Makefile`: + +```bash +pip install -e . +#unset BUILD_IN_DOCKER # if you previously set to use docker +#export SCHEMA=CGMES_3.0.0 # to use CGMES 3.0.0 +make cpp +``` #### Generating C++ files in a Docker container @@ -29,6 +40,14 @@ docker build --tag cimgen --file Dockerfile . docker run --volume "$(pwd)/output:/output" cimgen --outdir=/output/cpp/CGMES_2.4.15_27JAN2020 --schemadir=/cimgen/cgmes_schema/CGMES_2.4.15_27JAN2020 --langdir=cpp --cgmes_version=cgmes_v2_4_15 ``` +alternatively, you can leverage `Makefile`: + +```bash +export BUILD_IN_DOCKER=true +#export SCHEMA=CGMES_3.0.0 to use CGMES 3.0.0 +make cpp +``` + ### Generating Python files #### Generating Python files on Linux @@ -38,7 +57,14 @@ pip install -e . cimgen --outdir=output/python/CGMES_2.4.15_27JAN2020 --schemadir=cgmes_schema/CGMES_2.4.15_27JAN2020 --langdir=python --cgmes_version=cgmes_v2_4_15 ``` -`outdir` can be set to whichever absolute path you wish to create the files in. +alternatively, you can leverage `Makefile`: + +```bash +pip install -e . +#unset BUILD_IN_DOCKER # if you previously set to use docker +#export SCHEMA=CGMES_3.0.0 # to use CGMES 3.0.0 +make python +``` #### Generating Python files in a Docker container @@ -47,6 +73,49 @@ docker build --tag cimgen --file Dockerfile . docker run --volume "$(pwd)/output:/output" cimgen --outdir=/output/python/CGMES_2.4.15_27JAN2020 --schemadir=/cimgen/cgmes_schema/CGMES_2.4.15_27JAN2020 --langdir=python --cgmes_version=cgmes_v2_4_15 ``` +alternatively, you can leverage `Makefile`: + +```bash +export BUILD_IN_DOCKER=true +#export SCHEMA=CGMES_3.0.0 to use CGMES 3.0.0 +make python +``` + +### Generating Modern Python (i.e. PyDantic based dataclasses) files + +#### Generating Modern Python files on Linux + +```bash +pip install -e . +cimgen --outdir=output/modernpython/CGMES_2.4.15_27JAN2020 --schemadir=cgmes_schema/CGMES_2.4.15_27JAN2020 --langdir=modernpython --cgmes_version=cgmes_v2_4_15 +``` + +`outdir` can be set to whichever absolute path you wish to create the files in. + +alternatively, you can leverage `Makefile`: + +```bash +pip install -e . +#unset BUILD_IN_DOCKER # if you previously set to use docker +#export SCHEMA=CGMES_3.0.0 # to use CGMES 3.0.0 +make modernpython +``` + +#### Generating Modern Python files in a Docker container + +```bash +docker build --tag cimgen --file Dockerfile . +docker run --volume "$(pwd)/output:/output" cimgen --outdir=/output/modernpython/CGMES_2.4.15_27JAN2020 --schemadir=/cimgen/cgmes_schema/CGMES_2.4.15_27JAN2020 --langdir=modernpython --cgmes_version=cgmes_v2_4_15 +``` + +alternatively, you can leverage `Makefile`: + +```bash +export BUILD_IN_DOCKER=true +#export SCHEMA=CGMES_3.0.0 to use CGMES 3.0.0 +make modernpython +``` + ## License This project is released under the terms of the [Apache 2.0 license](./LICENSE).