Skip to content

Commit

Permalink
fix makefile to support 3.0.0
Browse files Browse the repository at this point in the history
Signed-off-by: Federico M. Facca <[email protected]>

Delete .DS_Store

Signed-off-by: Federico M. Facca <[email protected]>

Update build.yaml

Signed-off-by: Federico M. Facca <[email protected]>

Delete cgmes_schema/.DS_Store

Signed-off-by: Federico M. Facca <[email protected]>

Update build.yaml

Signed-off-by: Federico M. Facca <[email protected]>
  • Loading branch information
chicco785 committed Nov 10, 2024
1 parent cee0a97 commit 6e07123
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 7 deletions.
Binary file removed .DS_Store
Binary file not shown.
10 changes: 8 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:

schema:
- CGMES_2.4.15_27JAN2020
- CGMES_3.0.0

steps:
- name: Checkout repo
Expand All @@ -40,10 +41,15 @@ jobs:
pip install .
# Extract version (2.4.15 => 2_4_15), ignore the date part
SCHEMA_VERSION=$(echo "${{matrix.schema}}" | cut -d'_' -f2 | cut -d'.' -f1-3 | tr '.' '_')
# Run cimgen with the valid version
cimgen \
--outdir=output/${{matrix.language}} \
--outdir=output/${{matrix.language}}/${{matrix.schema}} \
--schemadir=cgmes_schema/${{matrix.schema}} \
--langdir=${{matrix.language}}
--langdir=${{matrix.language}} \
--cgmes_version=cgmes_v${SCHEMA_VERSION}
- name: Create artifact
uses: actions/upload-artifact@v4
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
75 changes: 72 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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

Expand All @@ -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).
Expand Down
Binary file removed cgmes_schema/.DS_Store
Binary file not shown.

0 comments on commit 6e07123

Please sign in to comment.