Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
Signed-off-by: petersalemink95 <peter.salemink95@gmail.com>
  • Loading branch information
petersalemink95 committed Jun 12, 2024
2 parents 6f37818 + 939cc7d commit 19e63c6
Show file tree
Hide file tree
Showing 44 changed files with 727 additions and 383 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ jobs:

env:
CMAKE_PREFIX_PATH: /home/linuxbrew/.linuxbrew
CC: clang-15
CXX: clang++-15
CLANG_TIDY: clang-tidy-15
PRESET: ci-clang-tidy-${{ matrix.build-option }}
TARGET: nonexistent # will be overwritten later in this action

Expand All @@ -51,6 +48,9 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y ninja-build clang-15 clang-tidy-15
sudo ln -s /usr/bin/clang-15 /usr/local/bin/clang
sudo ln -s /usr/bin/clang++-15 /usr/local/bin/clang++
sudo ln -s /usr/bin/clang-tidy-15 /usr/local/bin/clang-tidy
- name: Enable brew
run: |
Expand Down
33 changes: 0 additions & 33 deletions .github/workflows/dco-check.yml

This file was deleted.

19 changes: 10 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,10 @@ jobs:
compiler: [gcc, clang]
include:
- compiler: gcc
cc: gcc-12
cxx: g++-12
- compiler: clang
cc: clang-15
cxx: clang++-15

env:
CMAKE_PREFIX_PATH: /home/linuxbrew/.linuxbrew
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
PRESET: ci-${{ matrix.compiler }}-${{ matrix.build-option }}

steps:
Expand All @@ -86,6 +80,11 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y ninja-build gcc-12 g++-12 clang-15
sudo ln -s /usr/bin/clang-15 /usr/local/bin/clang
sudo ln -s /usr/bin/clang++-15 /usr/local/bin/clang++
sudo ln -s /usr/bin/gcc-12 /usr/local/bin/gcc
sudo ln -s /usr/bin/g++-12 /usr/local/bin/g++
- name: Enable brew
run: |
echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
Expand All @@ -100,7 +99,7 @@ jobs:
strategy:
matrix:
build-option: [ debug, release ]
compiler: [msvc] # , clang-cl] TODO(mgovers): reenable Clang CL when https://github.com/actions/runner-images/issues/10001 is fixed
compiler: [msvc, clang-cl]

env:
PRESET: ${{ matrix.compiler }}-${{ matrix.build-option }}
Expand Down Expand Up @@ -128,6 +127,10 @@ jobs:
Import-Module (Join-Path $vsPath 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll')
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -host_arch=x64'
# Resolve dirty PATH environment
# TODO(mgovers): Remove after https://github.com/actions/runner-images/issues/10001 is resolved
$env:PATH = ($env:PATH -split ';' | Where-Object { $_ -ne 'C:\Program Files\LLVM\bin' }) -join ';'
# generate cmake cache
cmake --preset ${{ env.PRESET }} -DCMAKE_PREFIX_PATH=C:\conda_envs\cpp_pkgs\Library; if(!$?) { Exit $LASTEXITCODE }
# build
Expand All @@ -151,8 +154,6 @@ jobs:
build-option: [ debug, release ]
env:
CMAKE_PREFIX_PATH: /usr/local
CC: clang
CXX: clang++
PRESET: ci-clang-${{ matrix.build-option }}

steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ jobs:
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
CMAKE_PREFIX_PATH: /home/linuxbrew/.linuxbrew
LLVM_COV: llvm-cov-15
CC: clang-15
CXX: clang++-15
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -37,6 +35,8 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y ninja-build clang-15 lcov gcovr
sudo ln -s /usr/bin/clang-15 /usr/local/bin/clang
sudo ln -s /usr/bin/clang++-15 /usr/local/bin/clang++
- name: Enable brew
run: |
echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

repos:
- repo: https://github.com/fsfe/reuse-tool
rev: v3.0.1
rev: v3.0.2
hooks:
- id: reuse
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 22.6.0
rev: 24.4.2
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.2.0
rev: v1.10.0
hooks:
- id: mypy
- repo: local
Expand Down
8 changes: 8 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ authors:
given-names: "Marc"
email: "Marc.van.Raalte@Alliander.com"
affiliation: "Alliander"
- family-names: "Figueroa Manrique"
given-names: "Santiago"
email: "Santiago.Figueroa.Manrique@Alliander.com"
affiliation: "Alliander"
- name: "Contributors to the LF Energy project Power Grid Model"
contact:
- name: "LF Energy project Power Grid Model"
Expand Down Expand Up @@ -131,4 +135,8 @@ references:
given-names: "Chenguang"
email: "Chenguang.Wang@Alliander.com"
affiliation: "Alliander"
- family-names: "Figueroa Manrique"
given-names: "Santiago"
email: "Santiago.Figueroa.Manrique@Alliander.com"
affiliation: "Alliander"
- name: "Contributors to the LF Energy project Power Grid Model"
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,17 @@ endif()
# add C library
add_subdirectory("power_grid_model_c")

# get tests
if(${PGM_ENABLE_TESTING})
# dev build
if(${PGM_ENABLE_DEV_BUILD})
include(CTest)
enable_testing()

# get tests
add_subdirectory("tests")
# get c api example
add_subdirectory("power_grid_model_c_example")
endif()

# get c api example
add_subdirectory("power_grid_model_c_example")


# export the power grid model
include("cmake/export_power_grid_model.cmake")
45 changes: 31 additions & 14 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"binaryDir": "${sourceDir}/cpp_build/${presetName}",
"installDir": "${sourceDir}/install/${presetName}",
"cacheVariables": {
"PGM_ENABLE_TESTING": "ON"
"PGM_ENABLE_DEV_BUILD": "ON"
},
"environment": {
"PLATFORM_C_FLAGS": "",
Expand Down Expand Up @@ -79,9 +79,9 @@
"name": "msvc-base",
"description": "Target Windows using the MSVC compiler.",
"hidden": true,
"environment": {
"CC": "cl.exe",
"CXX": "cl.exe"
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe"
},
"inherits": "windows-base"
},
Expand All @@ -90,10 +90,12 @@
"description": "Target Windows using Clang with CL-like command line.",
"hidden": true,
"environment": {
"CC": "clang-cl.exe",
"CXX": "clang-cl.exe",
"CXXFLAGS": "$penv{CXXFLAGS} -Wno-uninitialized-const-reference -Wno-unknown-attributes"
},
"cacheVariables": {
"CMAKE_C_COMPILER": "clang-cl.exe",
"CMAKE_CXX_COMPILER": "clang-cl.exe"
},
"inherits": "windows-base"
},
{
Expand Down Expand Up @@ -124,8 +126,10 @@
{
"name": "clang-tidy-unix-base",
"cacheVariables": {
"CMAKE_C_CLANG_TIDY": "$env{CLANG_TIDY}",
"CMAKE_CXX_CLANG_TIDY": "$env{CLANG_TIDY}"
"CMAKE_C_CLANG_TIDY": "clang-tidy",
"CMAKE_CXX_CLANG_TIDY": "clang-tidy",
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++"
},
"inherits": "unix-base",
"hidden": true
Expand Down Expand Up @@ -162,18 +166,27 @@
"release"
]
},
{
"name": "clang-base",
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++"
},
"inherits": "unix-sanitizer",
"hidden": true
},
{
"name": "clang-debug",
"inherits": [
"debug",
"unix-sanitizer"
"clang-base"
]
},
{
"name": "clang-release",
"inherits": [
"release",
"unix-sanitizer"
"clang-base"
]
},
{
Expand Down Expand Up @@ -211,6 +224,10 @@
"environment": {
"COMPILER_CXX_FLAGS": "$env{COMPILER_C_FLAGS} -Wno-maybe-uninitialized"
},
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++"
},
"inherits": "unix-sanitizer",
"hidden": true
},
Expand Down Expand Up @@ -252,15 +269,15 @@
{
"name": "ci-gcc-release",
"inherits": [
"gcc-release",
"unix-coverage"
"gcc-release"
]
},
{
"name": "ci-sonar",
"inherits": [
"unix-coverage",
"debug"
"clang-base",
"debug",
"unix-coverage"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.7
1.8
10 changes: 5 additions & 5 deletions docs/advanced_documentation/build-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,17 @@ In principle, you can use any C++ IDE with cmake and ninja support to develop th
the bare CMake CLI to set up the project. For ease of use, several presets are available (CMake 3.23+). Supported presets
for your development platform can be listed using `cmake --list-presets`.

On Linux/macOS, the presets will use command `clang`/`clang++` or `gcc`/`g++` to find the relevant `clang` or `gcc` compiler. It is the developer's reponsiblity to properly define symbolic links (which should be discoverable through `PATH` environment variable) of `clang` or `gcc` compiler in your system. If you want to build with `clang-tidy`, you also need to define symbolic link of `clang-tidy` to point to the actual `clang-tidy` executable of your system.

Similar also applies to Windows: the presets will use command `cl.exe` or `clang-cl.exe` to find the compiler. Developer needs to make sure the they are discoverable in `PATH`. For x64 Windows native development using MSVC or Clang CL, please use the `x64 Native Command Prompt`, which uses `vcvarsall.bat` to set up the appropriate build environment.

## Visual Studio Code Support

You can use any IDE to develop this project. As a popular cross-platform IDE, the settings for Visual Studio Code is preconfigured in the folder `.vscode`. You can open the repository folder with VSCode and the configuration will be loaded automatically.

```{note}
VSCode (as well as some other IDEs) does not set its own build environment itself. For optimal usage, open the folder
using `cmake <project_dir>` from a terminal that has the environment set up. E.g.:
* For x64 Windows native development using MSVC or Clang CL, use the `x64 Native Command Prompt`, which uses
`vcvarsall.bat` to set the appropriate build environment.
* For Linux/WSL using the LLVM-15 `clang`, `source` or `export` `CC=clang-15`, `CXX=clang++-15` and `LLVM_COV=llvm-cov-15`. Optionally, you can `export` `CLANG_TIDY=clang-tidy-15`.
using `cmake <project_dir>` from a terminal that has the environment set up. See above section for tips.
```

## Build Script for Linux/macOS
Expand Down
Loading

0 comments on commit 19e63c6

Please sign in to comment.