Skip to content

Commit

Permalink
Adding conan profiles.
Browse files Browse the repository at this point in the history
  • Loading branch information
rturrado committed Sep 26, 2023
1 parent 7bdde50 commit f8975cb
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 7 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Test
on:
push:
branches:
- develop
- add_conan_profiles
pull_request:

jobs:
Expand Down Expand Up @@ -43,7 +43,9 @@ jobs:
- name: Configure and build
run: |
conan profile detect
conan build . -s:h compiler.cppstd=20 -s:h libqasm/*:build_type=${{ matrix.build_type }} -o libqasm/*:build_tests=True -o libqasm/*:compat=True -o libqasm/*:asan_enabled=True -b missing
build_type=${{ matrix.build_type }}
build_type=${build_type@L}
conan build . -pr=conan/profiles/tests-${build_type}-compat -b missing
- name: Test
working-directory: build/${{ matrix.build_type }}
run: ctest -C ${{ matrix.build_type }} --output-on-failure
Expand Down Expand Up @@ -87,7 +89,7 @@ jobs:
python3 -m venv venv
source venv/bin/activate
python3 -m pip install --upgrade pip conan
conan build . -s:h compiler.cppstd=20 -s:h libqasm/*:build_type=Release -o libqasm/*:build_tests=True -o libqasm/*:compat=True -o libqasm/*:asan_enabled=True -b missing
conan build . -pr=conan/profiles/tests-release-compat -b missing
- name: Test
working-directory: build/Release
run: ctest -C Release --output-on-failure
Expand Down
37 changes: 33 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,51 @@ conan profile detect
```

The installation of `libqasm` dependencies, as well as the compilation, can be done in one go.<br/>
Notice the command below is building `libqasm` in Debug mode with tests.

```
git clone https://github.com/QuTech-Delft/libqasm.git
cd libqasm
conan build . -s:h compiler.cppstd=20 -s:h libqasm/*:build_type=Debug -o libqasm/*:build_tests=True -b missing
conan build . -pr=conan/profiles/tests-debug -b missing
```

### Build profiles

The command above is building `libqasm` in debug mode with tests using the `debug-tests` profile.

libqasm provides a set of predefined profiles under the `conan/profiles` folder.

All these files follow the `{tests,}-{debug,release}-{compat,}` naming convention. For example:
- `release` sets `build_tests=False`, `build_type=Release` and `libqasm_compat=False`, and
- `test-debug-compat` sets `build_tests=True`, `build_type=Debug` and `libqasm_compat=True`.

All the profiles set `compiler.cppstd=20`.

All the `tests` profiles set `asan_enabled=True`.

### Build options

Profiles are a shorthand for command line options. The command above could be written as well as:

```
conan build . -s:h compiler.cppstd=20 -s:h libqasm/*:build_type=Debug -o libqasm/*:asan_enabled=True -o libqasm/*:build_tests=True -o libqasm/*:compat=False -b missing
```

These are the list of options that could be specified whether in a profile or in the command line:

- `libqasm/*:build_tests={True,False}`: build tests or not.
- `libqasm/*:build_type={Debug,Release}`: builds in debug or release mode.
- `libqasm/*:asan_enabled={True,False}`: enables Address Sanitizer.
- `libqasm/*:compat={True,False}`: enables the compatibility layer.
- `libqasm/*:shared={True,False}`: builds libqasm as a shared library.

## Install

### From Python

Install from the project root directory as follows:

```
python -m pip install --verbose .
python3 -m pip install --verbose .
```

or if you'd rather use conda:
Expand All @@ -85,7 +114,7 @@ conda install libqasm --use-local
You can test if it works by running:

```
python -m pytest
python3 -m pytest
```

### From C++
Expand Down
10 changes: 10 additions & 0 deletions conan/profiles/debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(default)

[settings]
compiler.cppstd=20
libqasm/*:build_type=Debug

[options]
libqasm/*:asan_enabled=False
libqasm/*:build_tests=False
libqasm/*:compat=False
10 changes: 10 additions & 0 deletions conan/profiles/debug-compat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(default)

[settings]
compiler.cppstd=20
libqasm/*:build_type=Debug

[options]
libqasm/*:asan_enabled=False
libqasm/*:build_tests=False
libqasm/*:compat=True
10 changes: 10 additions & 0 deletions conan/profiles/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(default)

[settings]
compiler.cppstd=20
libqasm/*:build_type=Release

[options]
libqasm/*:asan_enabled=False
libqasm/*:build_tests=False
libqasm/*:compat=False
10 changes: 10 additions & 0 deletions conan/profiles/release-compat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(default)

[settings]
compiler.cppstd=20
libqasm/*:build_type=Release

[options]
libqasm/*:asan_enabled=False
libqasm/*:build_tests=False
libqasm/*:compat=True
10 changes: 10 additions & 0 deletions conan/profiles/tests-debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(default)

[settings]
compiler.cppstd=20
libqasm/*:build_type=Debug

[options]
libqasm/*:asan_enabled=True
libqasm/*:build_tests=True
libqasm/*:compat=False
10 changes: 10 additions & 0 deletions conan/profiles/tests-debug-compat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(default)

[settings]
compiler.cppstd=20
libqasm/*:build_type=Debug

[options]
libqasm/*:asan_enabled=True
libqasm/*:build_tests=True
libqasm/*:compat=True
10 changes: 10 additions & 0 deletions conan/profiles/tests-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(default)

[settings]
compiler.cppstd=20
libqasm/*:build_type=Release

[options]
libqasm/*:asan_enabled=False
libqasm/*:build_tests=True
libqasm/*:compat=False
10 changes: 10 additions & 0 deletions conan/profiles/tests-release-compat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(default)

[settings]
compiler.cppstd=20
libqasm/*:build_type=Release

[options]
libqasm/*:asan_enabled=False
libqasm/*:build_tests=True
libqasm/*:compat=True

0 comments on commit f8975cb

Please sign in to comment.