From f8975cb0ccbc96991307bbf9b61145cbf0a6000f Mon Sep 17 00:00:00 2001 From: rturrado <68099809+rturrado@users.noreply.github.com> Date: Tue, 26 Sep 2023 16:39:07 +0200 Subject: [PATCH 1/7] Adding conan profiles. --- .github/workflows/test.yml | 8 ++++--- README.md | 37 +++++++++++++++++++++++++---- conan/profiles/debug | 10 ++++++++ conan/profiles/debug-compat | 10 ++++++++ conan/profiles/release | 10 ++++++++ conan/profiles/release-compat | 10 ++++++++ conan/profiles/tests-debug | 10 ++++++++ conan/profiles/tests-debug-compat | 10 ++++++++ conan/profiles/tests-release | 10 ++++++++ conan/profiles/tests-release-compat | 10 ++++++++ 10 files changed, 118 insertions(+), 7 deletions(-) create mode 100644 conan/profiles/debug create mode 100644 conan/profiles/debug-compat create mode 100644 conan/profiles/release create mode 100644 conan/profiles/release-compat create mode 100644 conan/profiles/tests-debug create mode 100644 conan/profiles/tests-debug-compat create mode 100644 conan/profiles/tests-release create mode 100644 conan/profiles/tests-release-compat diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c53c345e..23134c5d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ name: Test on: push: branches: - - develop + - add_conan_profiles pull_request: jobs: @@ -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 @@ -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 diff --git a/README.md b/README.md index 6cc1e8a1..5a1ff845 100644 --- a/README.md +++ b/README.md @@ -57,14 +57,43 @@ conan profile detect ``` The installation of `libqasm` dependencies, as well as the compilation, can be done in one go.
-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 @@ -72,7 +101,7 @@ conan build . -s:h compiler.cppstd=20 -s:h libqasm/*:build_type=Debug -o libqasm 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: @@ -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++ diff --git a/conan/profiles/debug b/conan/profiles/debug new file mode 100644 index 00000000..405995d9 --- /dev/null +++ b/conan/profiles/debug @@ -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 diff --git a/conan/profiles/debug-compat b/conan/profiles/debug-compat new file mode 100644 index 00000000..e070c6d1 --- /dev/null +++ b/conan/profiles/debug-compat @@ -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 diff --git a/conan/profiles/release b/conan/profiles/release new file mode 100644 index 00000000..7842c688 --- /dev/null +++ b/conan/profiles/release @@ -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 diff --git a/conan/profiles/release-compat b/conan/profiles/release-compat new file mode 100644 index 00000000..696093b8 --- /dev/null +++ b/conan/profiles/release-compat @@ -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 diff --git a/conan/profiles/tests-debug b/conan/profiles/tests-debug new file mode 100644 index 00000000..6021f64d --- /dev/null +++ b/conan/profiles/tests-debug @@ -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 diff --git a/conan/profiles/tests-debug-compat b/conan/profiles/tests-debug-compat new file mode 100644 index 00000000..4a7202d3 --- /dev/null +++ b/conan/profiles/tests-debug-compat @@ -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 diff --git a/conan/profiles/tests-release b/conan/profiles/tests-release new file mode 100644 index 00000000..9bfd0fd6 --- /dev/null +++ b/conan/profiles/tests-release @@ -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 diff --git a/conan/profiles/tests-release-compat b/conan/profiles/tests-release-compat new file mode 100644 index 00000000..0cadc7f4 --- /dev/null +++ b/conan/profiles/tests-release-compat @@ -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 From 8de378681ec70a7a815c2986b1054ec9a97e37f1 Mon Sep 17 00:00:00 2001 From: rturrado <68099809+rturrado@users.noreply.github.com> Date: Wed, 27 Sep 2023 01:01:18 +0200 Subject: [PATCH 2/7] Trying to fix the MacOS and Windows builds. --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 23134c5d..220b6c2e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,6 +46,7 @@ jobs: build_type=${{ matrix.build_type }} build_type=${build_type@L} conan build . -pr=conan/profiles/tests-${build_type}-compat -b missing + shell: bash - name: Test working-directory: build/${{ matrix.build_type }} run: ctest -C ${{ matrix.build_type }} --output-on-failure From 3fc0402d0f15a877d01acece169999559950f257 Mon Sep 17 00:00:00 2001 From: rturrado <68099809+rturrado@users.noreply.github.com> Date: Wed, 27 Sep 2023 01:10:11 +0200 Subject: [PATCH 3/7] Trying to fix the MacOS builds. --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 220b6c2e..83ddc942 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,8 +44,8 @@ jobs: run: | conan profile detect build_type=${{ matrix.build_type }} - build_type=${build_type@L} - conan build . -pr=conan/profiles/tests-${build_type}-compat -b missing + lowercase_build_type=${build_type,,} + conan build . -pr=conan/profiles/tests-${lowercase_build_type}-compat -b missing shell: bash - name: Test working-directory: build/${{ matrix.build_type }} From 147c322eba451878937a097241dd05295135049a Mon Sep 17 00:00:00 2001 From: rturrado <68099809+rturrado@users.noreply.github.com> Date: Wed, 27 Sep 2023 01:16:57 +0200 Subject: [PATCH 4/7] Trying to fix the MacOS builds. MacOS doesn't like neither '${blah@L}' nor '${blah,,}' for converting 'blah' to lowercase. --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 83ddc942..7d59d04c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,7 +44,7 @@ jobs: run: | conan profile detect build_type=${{ matrix.build_type }} - lowercase_build_type=${build_type,,} + lowercase_build_type=$(echo ${build_type} | tr '[:upper:]' '[:lower:]') conan build . -pr=conan/profiles/tests-${lowercase_build_type}-compat -b missing shell: bash - name: Test From 7337efbd5b91a5a0c9c2c51f36303e9bc45d69b3 Mon Sep 17 00:00:00 2001 From: rturrado <68099809+rturrado@users.noreply.github.com> Date: Wed, 27 Sep 2023 01:41:58 +0200 Subject: [PATCH 5/7] Updated README.md. Updated tests profiles to always enable Address Sanitizer. --- README.md | 23 ++++++++++------------- conan/profiles/tests-release | 2 +- conan/profiles/tests-release-compat | 2 +- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 5a1ff845..c94bab57 100644 --- a/README.md +++ b/README.md @@ -66,17 +66,13 @@ 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. +The command above is building `libqasm` in Debug mode with tests using the `tests-debug` profile. +A group of predefined profiles is provided under the `conan/profiles` folder. +They follow the `[tests-](debug|release)[-compat]` naming convention. For example: + - `release` is a Release build without tests and compatibility with the original API. + - `tests-debug-compat` is a Debug build with tests and compatibility enabled. -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`. +All the profiles set the C++ standard to 20. All the `tests` profiles enable Address Sanitizer. ### Build options @@ -88,11 +84,12 @@ conan build . -s:h compiler.cppstd=20 -s:h libqasm/*:build_type=Debug -o libqasm 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_tests={True,False}`: builds 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. +- `libqasm/*:compat={True,False}`: enables installation of the headers for the original API, +on top of the ones for the new API. +- `libqasm/*:shared={True,False}`: builds a shared object library instead of a static library, if applicable. ## Install diff --git a/conan/profiles/tests-release b/conan/profiles/tests-release index 9bfd0fd6..e0ab99ec 100644 --- a/conan/profiles/tests-release +++ b/conan/profiles/tests-release @@ -5,6 +5,6 @@ compiler.cppstd=20 libqasm/*:build_type=Release [options] -libqasm/*:asan_enabled=False +libqasm/*:asan_enabled=True libqasm/*:build_tests=True libqasm/*:compat=False diff --git a/conan/profiles/tests-release-compat b/conan/profiles/tests-release-compat index 0cadc7f4..f67282ee 100644 --- a/conan/profiles/tests-release-compat +++ b/conan/profiles/tests-release-compat @@ -5,6 +5,6 @@ compiler.cppstd=20 libqasm/*:build_type=Release [options] -libqasm/*:asan_enabled=False +libqasm/*:asan_enabled=True libqasm/*:build_tests=True libqasm/*:compat=True From 46969e5e9217aca20d3b1edce6e346b44fae39de Mon Sep 17 00:00:00 2001 From: rturrado <68099809+rturrado@users.noreply.github.com> Date: Wed, 27 Sep 2023 01:43:04 +0200 Subject: [PATCH 6/7] Updated test.yml before PR. --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7d59d04c..bfc62bad 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ name: Test on: push: branches: - - add_conan_profiles + - develop pull_request: jobs: From 09c9e414290302c91c9fb0144a6a80dfb9f454d0 Mon Sep 17 00:00:00 2001 From: rturrado <68099809+rturrado@users.noreply.github.com> Date: Wed, 27 Sep 2023 11:31:40 +0200 Subject: [PATCH 7/7] Updated README.md to explain what '-b missing' does in the 'conan build' command line. --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c94bab57..57e6ebc4 100644 --- a/README.md +++ b/README.md @@ -64,9 +64,14 @@ cd libqasm conan build . -pr=conan/profiles/tests-debug -b missing ``` +The command above is building `libqasm` in Debug mode with tests using the `tests-debug` profile. + +The `-b missing` parameter asks `conan` to build packages from sources +in case it cannot find the binary packages for the current configuration (platform, OS, compiler, build type...). + ### Build profiles -The command above is building `libqasm` in Debug mode with tests using the `tests-debug` profile. + A group of predefined profiles is provided under the `conan/profiles` folder. They follow the `[tests-](debug|release)[-compat]` naming convention. For example: - `release` is a Release build without tests and compatibility with the original API.