-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
1,098 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Compile tree-gen | ||
description: Install tools and compile tree-gen | ||
inputs: | ||
build_type: | ||
required: true | ||
description: Is the build a debug or release version | ||
c_compiler: | ||
required: true | ||
description: Which C compiler to use | ||
cxx_compiler: | ||
required: true | ||
description: Which C++ compiler to use | ||
shell: | ||
required: true | ||
description: Which shell to use for the `run` command | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Install conan | ||
run: python3 -m pip install --upgrade pip conan | ||
shell: ${{ inputs.shell }} | ||
- name: Get latest CMake | ||
uses: lukka/get-cmake@latest | ||
- name: Configure and build | ||
run: | | ||
conan profile detect --force | ||
conan_profile=${{ inputs.conan_profile }} | ||
lowercase_conan_profile=$(echo ${conan_profile} | tr '[:upper:]' '[:lower:]') | ||
conan build . -pr=conan/profiles/${lowercase_conan_profile} -b missing | ||
shell: ${{ inputs.shell }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
jobs: | ||
cpp-linux-x64: | ||
name: "C++ tests (gcc-clang/Linux/x64)" | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
build_type: | ||
- Debug | ||
- Release | ||
compiler: | ||
- clang | ||
- g | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- uses: ./.github/actions/cpp-tests | ||
with: | ||
build_type: ${{ matrix.build_type }} | ||
c_compiler: ${{ matrix.c_compiler }} | ||
cxx_compiler: ${{ matrix.cxx_compiler }} | ||
conan_profile: tests-${{ matrix.build_type }}-${{ matrix.compiler }}-linux-x64 | ||
shell: bash | ||
|
||
cpp-macos-x64: | ||
name: "C++ tests (clang/MacOS/x64)" | ||
runs-on: macos-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
build_type: | ||
- Debug | ||
- Release | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Install dependencies | ||
run: | | ||
brew install bison flex | ||
echo "/usr/local/opt/bison/bin" >> $GITHUB_PATH | ||
echo "/usr/local/opt/flex/bin" >> $GITHUB_PATH | ||
- uses: ./.github/actions/cpp-tests | ||
with: | ||
build_type: ${{ matrix.build_type }} | ||
conan_profile: tests-${{ matrix.build_type }}-apple_clang-macos-x64 | ||
shell: bash | ||
|
||
cpp-windows-x64: | ||
name: "C++ tests (msvc/Windows/x64)" | ||
runs-on: windows-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
build_type: | ||
- Debug | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: C:\Users\runneradmin\AppData\Local\Temp\chocolatey | ||
key: ${{ runner.os }}-chocolatey-cpp-0 | ||
restore-keys: | | ||
${{ runner.os }}-chocolatey-cpp- | ||
${{ runner.os }}-chocolatey- | ||
- name: Install dependencies | ||
run: choco install winflexbison3 --version 2.5.24.20210105 | ||
- uses: ./.github/actions/cpp-tests | ||
with: | ||
build_type: ${{ matrix.build_type }} | ||
conan_profile: tests-${{ matrix.build_type }}-msvc-windows-x64 | ||
shell: bash | ||
|
||
cpp-linux-arm64: | ||
name: "C++ tests (clang/Linux/ARM64)" | ||
runs-on: [self-hosted, ARM64, Linux] | ||
container: python:3.11 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
build_type: | ||
- Debug | ||
- Release | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Add Python symlink | ||
run: ln -sf /usr/local/bin/python3.11 /usr/bin/python3 | ||
shell: bash | ||
- name: Install bison and flex | ||
run: | | ||
apt-get update | ||
apt-get install -y bison flex | ||
- uses: ./.github/actions/cpp-tests | ||
with: | ||
build_type: Release | ||
conan_profile: tests-${{ matrix.build_type }}-clang-linux-arm64 | ||
shell: bash | ||
|
||
cpp-macos-arm64: | ||
name: "C++ tests (clang/macos/ARM64)" | ||
runs-on: [self-hosted, ARM64, macOS] | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
build_type: | ||
- Debug | ||
- Release | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Install bison and flex | ||
run: | | ||
brew install bison flex | ||
echo "$(brew --prefix bison)/bin" >> $GITHUB_PATH | ||
echo "$(brew --prefix flex)/bin" >> $GITHUB_PATH | ||
shell: bash | ||
- uses: ./.github/actions/cpp-tests | ||
with: | ||
build_type: Release | ||
conan_profile: tests-${{ matrix.build_type }}-apple_clang-macos-arm64 | ||
shell: bash | ||
|
||
complete: | ||
# see https://github.community/t/status-check-for-a-matrix-jobs/127354/7 | ||
name: Report status | ||
needs: | ||
- cpp-linux-x64 | ||
- cpp-macos-x64 | ||
- cpp-windows-x64 | ||
- cpp-linux-arm64 | ||
- cpp-macos-arm64 | ||
if: ${{ always() }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check all job status | ||
# see https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#needs-context | ||
# see https://stackoverflow.com/a/67532120/4907315 | ||
if: >- | ||
${{ | ||
contains(needs.*.result, 'failure') | ||
|| contains(needs.*.result, 'cancelled') | ||
|| contains(needs.*.result, 'skipped') | ||
}} | ||
run: exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
## [ 0.1.0 ] - [ 2023-12-18 ] | ||
|
||
### Added | ||
- Created repository from QuTech/Deflt libqasm's repository, src/func-gen folde | ||
|
||
### Changed | ||
- | ||
|
||
### Removed | ||
- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
cmake_minimum_required(VERSION 3.12 FATAL_ERROR) | ||
|
||
project(func-gen C CXX) | ||
|
||
# If func-gen was already included elsewhere in the project, don't include it again | ||
# There should be only one place for it and one version per project | ||
if(NOT TARGET ${PROJECT_NAME}) | ||
|
||
# Loads up the appropriate directories for installing stuff | ||
include(GNUInstallDirs) | ||
|
||
# Include the generate_tree functions | ||
include(cmake/generate_funcs.cmake) | ||
|
||
add_executable(func-gen) | ||
|
||
add_subdirectory(src) | ||
|
||
target_include_directories(func-gen | ||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../include/" | ||
) | ||
|
||
target_compile_features(${PROJECT_NAME}_test PRIVATE | ||
cxx_std_11 | ||
) | ||
|
||
# fPIC: otherwise some weirdness happens with pthreads or something when linking statically. | ||
if(CMAKE_COMPILER_IS_GNUCXX) | ||
target_compile_options(func-gen PRIVATE | ||
-Wall -Wextra -Werror -Wfatal-errors | ||
-fPIC | ||
-Wno-error=deprecated-declarations | ||
-Wno-error=restrict | ||
-Wno-error=sign-compare | ||
) | ||
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") | ||
target_compile_options(func-gen PRIVATE | ||
-Wall -Wextra -Werror -Wfatal-errors | ||
-fPIC | ||
-Wno-error=sign-compare | ||
-Wno-error=unused-private-field | ||
-Wno-error=unused-but-set-variable | ||
) | ||
elseif(MSVC) | ||
target_compile_options(func-gen PRIVATE | ||
/WX | ||
/D_CRT_NONSTDC_NO_DEPRECATE | ||
/D_CRT_SECURE_NO_WARNINGS | ||
/D_UNICODE /DUNICODE | ||
/diagnostics:column /EHsc /FC /fp:precise /Gd /GS /MP /sdl /utf-8 /Zc:inline | ||
) | ||
else() | ||
message(SEND_ERROR "Unknown compiler!") | ||
endif() | ||
|
||
# Address sanitizer | ||
if(ASAN_ENABLED) | ||
if(MSVC AND CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
string(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") | ||
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}\n") | ||
|
||
# /MTd is needed to link clang_rt.asan-i386.lib statically | ||
# Otherwise the path to clang_rt.asan-i386.dll should be provided | ||
add_compile_options(/fsanitize=address /MTd) | ||
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") | ||
add_compile_options(-fsanitize=address,undefined -fno-omit-frame-pointer) | ||
add_link_options(-fsanitize=address,undefined) | ||
endif() | ||
endif() | ||
|
||
|
||
#=============================================================================# | ||
# Installation # | ||
#=============================================================================# | ||
|
||
# Install the generator tool only if this is the top level project | ||
if (${CMAKE_PROJECT_NAME} STREQUAL func-gen) | ||
install( | ||
TARGETS func-gen | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
) | ||
install( | ||
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
FILES_MATCHING PATTERN "*.hpp" | ||
) | ||
endif() | ||
|
||
|
||
endif() # NOT TARGET ${PROJECT_NAME} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
function(generate_funcs HDR SRC VER) | ||
# Get the directory for the header file and make sure it exists. | ||
get_filename_component(HDR_DIR "${HDR}" PATH) | ||
file(MAKE_DIRECTORY "${HDR_DIR}") | ||
|
||
# Get the directory for the source file and make sure it exists. | ||
get_filename_component(SRC_DIR "${SRC}" PATH) | ||
file(MAKE_DIRECTORY "${SRC_DIR}") | ||
|
||
# Add a command to do the generation. Note the $<TARGET_FILE:func-gen> | ||
# dependency; this makes cmake correctly recompile the generator and | ||
# regenerate the files with it if its source files change. | ||
add_custom_command( | ||
COMMAND func-gen "${HDR}" "${SRC}" "${VER}" | ||
OUTPUT "${HDR}" "${SRC}" | ||
DEPENDS func-gen | ||
) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
include(default) | ||
|
||
[settings] | ||
compiler.cppstd=17 | ||
func-gen/*:build_type=Debug | ||
|
||
[options] | ||
func-gen/*:asan_enabled=False | ||
func-gen/*:build_tests=False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
include(default) | ||
|
||
[settings] | ||
compiler.cppstd=17 | ||
func-gen/*:build_type=Release | ||
|
||
[options] | ||
func-gen/*:asan_enabled=False | ||
func-gen/*:build_tests=False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
include(default) | ||
|
||
[settings] | ||
compiler.cppstd=17 | ||
func-gen/*:build_type=Debug | ||
|
||
[options] | ||
func-gen/*:asan_enabled=True | ||
func-gen/*:build_tests=True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include(tests-debug) | ||
|
||
[settings] | ||
compiler=apple-clang | ||
compiler.version=14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include(tests-debug) | ||
|
||
[settings] | ||
compiler=apple-clang | ||
compiler.version=14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
include(tests-debug) | ||
|
||
[settings] | ||
compiler=clang | ||
compiler.version=14 | ||
|
||
[conf] | ||
tools.build:cxxflags=["-stdlib=libc++"] | ||
tools.build:compiler_executables={ 'c' : 'clang', 'cpp' : 'clang++' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
include(tests-debug) | ||
|
||
[settings] | ||
compiler=clang | ||
compiler.version=14 | ||
|
||
[conf] | ||
tools.build:cxxflags=["-stdlib=libc++"] | ||
tools.build:compiler_executables={ 'c' : 'clang', 'cpp' : 'clang++' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include(tests-debug) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include(tests-debug) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
include(default) | ||
|
||
[settings] | ||
compiler.cppstd=17 | ||
func-gen/*:build_type=Release | ||
|
||
[options] | ||
func-gen/*:asan_enabled=True | ||
func-gen/*:build_tests=True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include(tests-release) | ||
|
||
[settings] | ||
compiler=apple-clang | ||
compiler.version=14 |
Oops, something went wrong.