Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit 2cf15d1

Browse files
authored
CTest Infrastructure, documentation Docker image and improved docs (#1122)
* Simplying adding libraries * Refactor with initial test structure * Updating documentation * Fixing style * Updating LLVM dependencies * Fixing CI * Fixing target name * Updating CI for mac * Following log suggestion * Disabling lit * Disabling lit * Fixing broken link * Introducing name checker for quantum instructions * Updating style checker * Updating allocation manager * Preparing test tools * Fixing style * Updating IR builder test component * Finishing test helper * Updating style * Static qubit allocation tests * Updating tests and documentation * Updating style * Fixing CI * Updating CI * Updating CI * Updating Linux CI * Fixing issues * Fixing bug * Making constructor explicit * Adding test coverage reports * Changing TODOs * Changing TODOs * Updating test suite * String tests * Adding results test * Finishing most of factory tests * Fixing links * Incorporating the changes in #1121 * Updating coverage report * Attempting to fix CI * Making submodule shallow * Working document on qubit allocation analysis * Updating target
1 parent 700cdec commit 2cf15d1

File tree

90 files changed

+15098
-966
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+15098
-966
lines changed

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "src/Passes/vendors/googletest"]
2+
path = src/Passes/vendors/googletest
3+
url = https://github.com/google/googletest.git
4+
shallow = true

build/passes-linux.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ steps:
1010
sudo apt-get install -y llvm-11 lldb-11 llvm-11-dev libllvm11 llvm-11-runtime
1111
sudo apt install -y python3 python3-pip
1212
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 0
13+
git submodule update --init --recursive
1314
cd src/Passes/
1415
pip install -r requirements.txt
1516
chmod +x manage
1617
export PYTHONUNBUFFERED=1
1718
export PYTHON_BIN_PATH=/usr/bin/python3
1819
export CC=clang-11
1920
export CXX=clang++-11
20-
./manage runci
21+
./manage runci
22+
rm -rf vendors/*
23+
2124
displayName: Linux build and CI for passes

build/passes-mac.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11

22
steps:
33
- script: |
4+
rm '/usr/local/bin/2to3'
45
brew install llvm@11
56
brew install cmake
67
brew install [email protected]
7-
brew unlink [email protected] && brew link [email protected]
8+
brew unlink [email protected]
9+
810
911
# Updating paths
1012
export PATH="/usr/local/opt/python/libexec/bin:$PATH"
1113
export PATH="/usr/local/opt/llvm@11/bin:$PATH"
1214
export LDFLAGS="${LDFLAGS} -L/usr/local/opt/llvm@11/lib"
1315
export CPPFLAGS="${CPPFLAGS} -I/usr/local/opt/llvm@11/include"
14-
16+
17+
git submodule update --init --recursive
1518
cd src/Passes/
16-
pip install -r requirements.txt
19+
pip3 install --user -r requirements.txt
1720
chmod +x manage
1821
./manage runci
22+
rm -rf vendors/*
1923

src/Passes/.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ cert-env*,\
88
cert-err52-cpp,\
99
cert-err60-cpp,\
1010
cert-flp30-c,\
11+
clang-analyzer-*,\
1112
clang-analyzer-security.FloatLoopCounter,\
1213
google-build-explicit-make-pair,\
1314
google-build-namespaces,\

src/Passes/CMakeLists.txt

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,69 @@ cmake_minimum_required(VERSION 3.4.3)
22

33
project(QirPasses)
44

5+
option(MICROSOFT_ENABLE_TESTS "Enable test targets" ON)
6+
option(MICROSOFT_ENABLE_DYNAMIC_LOADING "Use dynamic loading" ON)
7+
option(MICROSOFT_GENERATE_COVERAGE "Generate coverage" OFF)
8+
9+
# Microsoft Settings
10+
set(MICROSOFT_ROOT_PASSES_DIR ${CMAKE_CURRENT_SOURCE_DIR})
11+
set(MICROSOFT_ROOT_VENDOR_DIR ${MICROSOFT_ROOT_PASSES_DIR}/vendors)
12+
message(STATUS "Passes dir: ${MICROSOFT_ROOT_PASSES_DIR}")
13+
message(STATUS "Vendor dir: ${MICROSOFT_ROOT_VENDOR_DIR}")
14+
515
find_package(LLVM REQUIRED CONFIG)
616
include(CheckCXXCompilerFlag)
717

818
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
919
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
1020

21+
22+
# -fvisibility-inlines-hidden is set when building LLVM and on Darwin warnings
23+
# are triggered if llvm-tutor is built without this flag (though otherwise it
24+
# builds fine). For consistency, add it here too.
25+
check_cxx_compiler_flag("-fvisibility-inlines-hidden" SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG)
26+
if(${SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG})
27+
if (${SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG} STREQUAL "1")
28+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden")
29+
endif()
30+
endif()
31+
32+
33+
# Helper variable to determine if we are using clang compiler
34+
set(using_clang_compiler FALSE)
35+
if ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
36+
set(using_clang_compiler TRUE)
37+
endif ()
38+
39+
# Add compiler flags if we are
40+
if (MICROSOFT_GENERATE_COVERAGE)
41+
message(STATUS "Generating coverage data")
42+
43+
if (using_clang_compiler)
44+
# Generating coverage output
45+
set(CMAKE_CXX_FLAGS_DEBUG "-g -fprofile-instr-generate -fcoverage-mapping -O0")
46+
47+
# Forcing debug build
48+
set(CMAKE_BUILD_TYPE "Debug")
49+
else ()
50+
message(SEND_ERROR "Coverage flag enabled but clang compiler not found, CMake will exit.")
51+
endif ()
52+
endif (MICROSOFT_GENERATE_COVERAGE)
53+
54+
55+
56+
if(MICROSOFT_ENABLE_TESTS)
57+
add_subdirectory(${MICROSOFT_ROOT_VENDOR_DIR}/googletest)
58+
target_compile_options(gmock
59+
INTERFACE
60+
-Wno-everything)
61+
target_compile_options(gtest
62+
INTERFACE
63+
-Wno-everything)
64+
65+
endif(MICROSOFT_ENABLE_TESTS)
66+
67+
1168
# Setting the standard configuration for the C++ compiler
1269
# Rather than allowing C++17, we restrict ourselves to
1370
# C++14 as this is the standard currently used by the LLVM
@@ -18,22 +75,22 @@ set(CMAKE_CXX_STANDARD 14)
1875
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1976
set(CMAKE_CXX_EXTENSIONS OFF)
2077
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Weverything -Wconversion -Wno-c++98-compat-pedantic -Wno-c++98-compat -Wno-padded -Wno-exit-time-destructors -Wno-global-constructors")
21-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror ")
78+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-documentation-unknown-command")
79+
80+
include(${MICROSOFT_ROOT_PASSES_DIR}/cmake/Testing.cmake)
81+
include(${MICROSOFT_ROOT_PASSES_DIR}/cmake/Library.cmake)
82+
83+
84+
2285

2386
# LLVM is normally built without RTTI. Be consistent with that.
2487
if(NOT LLVM_ENABLE_RTTI)
88+
message(STATUS "RTTI is off")
2589
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
90+
else()
91+
message(STATUS "RTTI is on")
2692
endif()
2793

28-
# -fvisibility-inlines-hidden is set when building LLVM and on Darwin warnings
29-
# are triggered if llvm-tutor is built without this flag (though otherwise it
30-
# builds fine). For consistency, add it here too.
31-
check_cxx_compiler_flag("-fvisibility-inlines-hidden" SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG)
32-
if(${SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG})
33-
if (${SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG} STREQUAL "1")
34-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden")
35-
endif()
36-
endif()
3794

3895
# We export the compile commands which are needed by clang-tidy
3996
# to run the static analysis
@@ -47,6 +104,8 @@ add_definitions(${LLVM_DEFINITIONS})
47104
include_directories(${CMAKE_SOURCE_DIR}/Source)
48105
llvm_map_components_to_libnames(llvm_libs support core irreader passes orcjit x86asmparser x86codegen x86desc x86disassembler x86info interpreter objcarcopts)
49106

107+
message(STATUS "${llvm_libs}")
108+
50109

51110
# Adding the libraries
52111
add_subdirectory(Source)

src/Passes/Dockerfile renamed to src/Passes/Docker/CI.Ubuntu20.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:20.04 as bazel
1+
FROM ubuntu:20.04
22

33
# basic dependencies -
44
ENV DEBIAN_FRONTEND=noninteractive

src/Passes/Docker/Docs.dockerfile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
##########################
2+
# Generator
3+
##########################
4+
FROM ubuntu:20.04 as generator
5+
6+
ENV DEBIAN_FRONTEND=noninteractive
7+
RUN apt-get update -y && \
8+
apt-get install -y
9+
10+
RUN apt-get install -y curl \
11+
pkg-config \
12+
findutils \
13+
wget \
14+
unzip doxygen
15+
16+
RUN wget https://github.com/matusnovak/doxybook2/releases/download/v1.3.6/doxybook2-linux-amd64-v1.3.6.zip && \
17+
unzip doxybook2-linux-amd64-v1.3.6.zip
18+
19+
ADD Source/ /build/Source/
20+
ADD doxygen.cfg /build/
21+
22+
ADD docs/ /build/docs/
23+
24+
WORKDIR /build/
25+
RUN doxygen doxygen.cfg && \
26+
doxybook2 --input Doxygen/xml --config docs/.doxybook/config.json --output docs/src/ && \
27+
rm -rf docs/src/Namespaces/namespace_0d*
28+
29+
##########################
30+
# Builder
31+
##########################
32+
FROM node:alpine as builder
33+
34+
RUN mkdir /src/
35+
COPY --from=generator /build/docs/ /docs/
36+
37+
WORKDIR /docs/
38+
RUN yarn install && yarn build
39+
40+
41+
##########################
42+
# Documentation
43+
##########################
44+
FROM nginx:latest as documentation
45+
ADD docs/nginx/default.conf /etc/nginx/conf.d/default.conf
46+
47+
COPY --from=builder /docs/src/.vuepress/dist/ /usr/share/nginx/html

src/Passes/Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
nothing:
22
@echo "Preventing the user from accidently running the clean command."
3-
3+
4+
documentation:
5+
docker build -f Docker/Docs.dockerfile -t qir-passes-docs:latest .
6+
7+
documentation-shell: documentation
8+
docker run --rm -i -t qir-passes-docs:latest sh
9+
10+
serve-docs: documentation
11+
docker run -it --rm -p 8080:80 --name qir-documentation -t qir-passes-docs:latest
12+
13+
doxygen:
14+
doxygen doxygen.cfg
15+
416
clean:
517
rm -rf Release/
618
rm -rf Debug/

0 commit comments

Comments
 (0)