Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/fe #251

Merged
merged 55 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
1251b33
adopting some best practices for cmake
leissa Sep 29, 2023
1f8f1ab
cmake: use quotes for paths
leissa Sep 29, 2023
5807912
oops
leissa Sep 29, 2023
56c15e5
cmake: refactoring
leissa Sep 29, 2023
9787a7a
PROJECT*DIR -> CMAKE_CURRENT*DIR
leissa Sep 29, 2023
0e00330
fix paths
leissa Sep 29, 2023
137079c
cmake: consistent style
leissa Sep 29, 2023
681a338
cleanup
leissa Sep 29, 2023
478c4b4
remove THORIN_BUILD_TESTING option
leissa Sep 29, 2023
b1afd2f
modules -> external + added leissa/fe
leissa Oct 2, 2023
0e9e087
thorin_exports -> thorin-targets
leissa Oct 2, 2023
61e0c4c
thorin/util/assert.h -> fe/assert.h
leissa Oct 2, 2023
6046e7c
Merge branch 'refactor/cmake' into refactor/fe
leissa Oct 2, 2023
344e418
submodules
leissa Oct 2, 2023
1c35e0c
moving submodules around
leissa Oct 2, 2023
25d0d7c
thorin/util/cast.h -> fe/cast.h
leissa Oct 2, 2023
14d49a9
doxygen fixes
leissa Oct 2, 2023
7d2ff92
use fe/loc.h and fe/sym.h
leissa Oct 2, 2023
e8c0960
docs fix
leissa Oct 2, 2023
a081deb
porting World::arena_ to fe::Arena
leissa Oct 2, 2023
7b10207
compile fix
leissa Oct 2, 2023
1427ba7
fe: bump
leissa Oct 2, 2023
7fc6e49
thorin/util/utf8.* -> fe/utf.8 / fe/lexer.h
leissa Oct 2, 2023
32fb6cb
bug fixes
leissa Oct 2, 2023
7795b25
wip: porting Parser to fe
leissa Oct 2, 2023
0cc22d0
wip: porting to fe::Parser
leissa Oct 3, 2023
c0f79d0
more porting to fe::Parser
leissa Oct 3, 2023
514d546
using default impl for Pos/Loc ostream operators
leissa Oct 3, 2023
b5519be
simplify
leissa Oct 3, 2023
84bf137
porting to fe::Parser::expect
leissa Oct 3, 2023
689d8a2
bump
leissa Oct 3, 2023
2aed9ba
refactor
leissa Oct 3, 2023
3c572e1
bump
leissa Oct 4, 2023
d1ef412
bump fe and use newer compilers in workflows
leissa Oct 6, 2023
fe72c16
workflows
leissa Oct 6, 2023
471f0a2
macos: bump to latest
leissa Oct 6, 2023
d09df4e
macos fix
leissa Oct 6, 2023
a67c6bb
macos
leissa Oct 6, 2023
f40bf6f
porting to new FE API
leissa Oct 6, 2023
81fba82
porting to new API
leissa Oct 9, 2023
498f650
msvc fix
leissa Oct 9, 2023
04193d9
bump
leissa Oct 10, 2023
1b8efd3
bump
leissa Oct 10, 2023
9f9941c
bump
leissa Oct 10, 2023
6b93400
[CI] Test release-downloader for FileCheck
fodinabor Oct 11, 2023
96f733a
[CI] fix syntax
fodinabor Oct 11, 2023
f53ac6c
does this make macos happy?
leissa Oct 11, 2023
8cdbd71
clang: compile fix
leissa Oct 11, 2023
c34d4e8
clang + isunordered + half: next try
leissa Oct 11, 2023
ef8eac2
Merge branch 'master' into refactor/fe
leissa Nov 2, 2023
4431ae5
adjust to new API
leissa Nov 2, 2023
61e647a
gtest/regex: fix cmake dependency problem
leissa Nov 2, 2023
95ecefa
FE:bump to v0.2.1
leissa Nov 2, 2023
fbcbd61
use new API
leissa Nov 3, 2023
af193ba
porting to new FE API + test case
leissa Nov 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/doxygen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ jobs:

- name: Install newest g++, graphviz, texlive
run: |
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-11 graphviz texlive-latex-base texlive-fonts-recommended texlive-fonts-extra texlive-latex-extra
sudo apt-get install g++-13 graphviz texlive-latex-base texlive-fonts-recommended texlive-fonts-extra texlive-latex-extra

export CXX=g++-11
export CXX=g++-13

- name: Install Doxygen
run: |
Expand All @@ -38,7 +38,7 @@ jobs:
mv ghostscript-10.0.0-linux-x86_64/gs-1000-linux-x86_64 ${HOME}/.local/bin/gs

- name: Configure
run: CXX=g++-11 cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Debug -DTHORIN_BUILD_DOCS=ON -DDOXYGEN_EXECUTABLE=${{github.workspace}}/doxygen-1.9.5/bin/doxygen
run: CXX=g++-13 cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Debug -DTHORIN_BUILD_DOCS=ON -DDOXYGEN_EXECUTABLE=${{github.workspace}}/doxygen-1.9.5/bin/doxygen

- name: Build
run: cmake --build ${{github.workspace}}/build -v --target docs
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
path: |
./llvm
key: llvm-14.0.0-ubuntu

- name: Install LLVM and Clang
uses: KyleMayes/[email protected]
with:
Expand All @@ -45,10 +45,10 @@ jobs:

- name: Install newest g++, valgrind
run: |
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-11 valgrind
export CXX=g++-11
sudo apt-get install g++-13 valgrind
export CXX=g++-13
sudo python -m pip install lit psutil
sudo ln -s ${{github.workspace}}/bin/FileCheck-x86_64-ubuntu /usr/bin/FileCheck
sudo chmod +x /usr/bin/FileCheck
Expand All @@ -62,11 +62,11 @@ jobs:

- name: Configure Debug
if: matrix.build-type == 'Debug'
run: CXX=g++-11 cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DTHORIN_BUILD_TESTING=ON -DTHORIN_BUILD_EXAMPLES=ON
run: CXX=g++-13 cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DBUILD_TESTING=ON -DTHORIN_BUILD_EXAMPLES=ON

- name: Configure Release
if: matrix.build-type == 'Release'
run: CXX=g++-11 cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DTHORIN_BUILD_TESTING=ON -DTHORIN_BUILD_EXAMPLES=ON -DTHORIN_LIT_WITH_VALGRIND=ON
run: CXX=g++-13 cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DBUILD_TESTING=ON -DTHORIN_BUILD_EXAMPLES=ON -DTHORIN_LIT_WITH_VALGRIND=ON

- name: Build
run: cmake --build ${{github.workspace}}/build -v
Expand Down
39 changes: 16 additions & 23 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
build-and-test:
name: Build and test ${{matrix.build-type}} mode
runs-on: macos-11
runs-on: macos-latest
strategy:
matrix:
build-type: [Debug, Release]
Expand All @@ -25,33 +25,26 @@ jobs:
ccache_options: max_size=500M
override_cache_key: mac-latest-ccache-${{matrix.build-type}}

- name: Configure
run: CC=gcc-11 CXX=g++-11 cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DTHORIN_BUILD_TESTING=ON -DTHORIN_BUILD_EXAMPLES=ON -DPython3_ROOT_DIR=$(dirname $(which python3))

- name: Cache LLVM and Clang
id: cache-llvm
uses: actions/cache@v3
with:
path: |
./llvm
key: llvm-14.0.0-mac

- name: Install LLVM and Clang
uses: KyleMayes/[email protected]
with:
version: "14.0.0"
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
run: brew install llvm@16

- name: Configure
run: |
CC="/usr/local/opt/llvm@16/bin/clang" \
CXX="/usr/local/opt/llvm@16/bin/clang++" \
CXXFLAGS="-stdlib=libc++ -fexperimental-library" \
LDFLAGS="-L/usr/local/opt/llvm@16/lib/c++ -Wl,-rpath,/usr/local/opt/llvm@16/lib/c++" \
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DBUILD_TESTING=ON -DTHORIN_BUILD_EXAMPLES=ON -DPython3_ROOT_DIR=$(dirname $(which python3))

- name: Install FileCheck
uses: i3h/download-release-asset@v1
uses: robinraju/release-downloader@v1.8
with:
owner: fodinabor
repo: FileCheckBuild
tag: latest
file: FileCheck-x86_64-mac
path: ${{github.workspace}}/bin
repository: "fodinabor/FileCheckBuild"
latest: true
fileName: FileCheck-x86_64-mac
out-file-path: bin
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install LIT
run: |
python3 -m pip install lit psutil
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
set CXX=cl.exe
python -c "import sys; import os; print(os.path.dirname(sys.executable))" > tmpPath
set /p PYTHON_PATH= < tmpPath
cmake -B ${{github.workspace}}/build -G Ninja -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DTHORIN_BUILD_TESTING=ON -DTHORIN_BUILD_EXAMPLES=ON -DPython3_ROOT_DIR=%PYTHON_PATH%
cmake -B ${{github.workspace}}/build -G Ninja -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DBUILD_TESTING=ON -DTHORIN_BUILD_EXAMPLES=ON -DPython3_ROOT_DIR=%PYTHON_PATH%

- name: Install LLVM and Clang
uses: KyleMayes/[email protected]
Expand Down
17 changes: 10 additions & 7 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
[submodule "abseil-cpp"]
path = modules/abseil-cpp
path = external/abseil-cpp
url = ../../abseil/abseil-cpp
[submodule "doxygen-awesome-css"]
path = modules/doxygen-awesome-css
path = external/doxygen-awesome-css
url = ../../jothepro/doxygen-awesome-css.git
[submodule "fe"]
path = external/fe
url = ../../leissa/fe.git
[submodule "googletest"]
path = modules/googletest
path = external/googletest
url = ../../google/googletest.git
[submodule "half"]
path = modules/half
path = external/half
url = ../../AnyDSL/half.git
[submodule "lyra"]
path = modules/lyra
path = external/lyra
url = ../../bfgroup/lyra.git
[submodule "modules/rang"]
path = modules/rang
[submodule "rang"]
path = external/rang
url = ../../agauniyal/rang.git
95 changes: 51 additions & 44 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)

project(Thorin VERSION 1.9.0)

include(CMakeDependentOption)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
include(Thorin)

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type (default Debug)" FORCE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

if(MSVC)
Expand All @@ -16,15 +25,13 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")

option(BUILD_SHARED_LIBS "Build shared libraries." ON)
option(THORIN_BUILD_DOCS "If ON, Thorin will build the documentation (requires Doxygen)." OFF)
option(THORIN_BUILD_EXAMPLES "If ON, Thorin will build examples." OFF)
option(THORIN_BUILD_TESTING "If ON, Thorin will build all of Thorin's own tests." OFF)
option(THORIN_LIT_WITH_VALGRIND "If ON, the Thorin CLI in the lit tests will be run under valgrind." OFF)
option(THORIN_INSTALL_DEPENDENCIES "If ON, Thorin's dependencies will be installed alongside Thorin (use when not installing globally)." OFF)

message(STATUS "Build type: ${CMAKE_BUILD_TYPE}; shared libs: ${BUILD_SHARED_LIBS}")
Expand All @@ -41,29 +48,35 @@ else()
add_compile_options(-Wall -Wextra)
endif()

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
include(Thorin)

find_program(MEMORYCHECK_COMMAND valgrind)
set(VALGRIND_COMMAND_OPTIONS "--leak-check=full --error-exitcode=1") # needs to be BEFORE "include(CTest)"
include(CTest)
if(BUILD_TESTING AND THORIN_BUILD_TESTING)
include(GoogleTest)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
add_subdirectory(modules/googletest EXCLUDE_FROM_ALL)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
find_program(MEMORYCHECK_COMMAND valgrind)
set(VALGRIND_COMMAND_OPTIONS "--leak-check=full --error-exitcode=1")
option(BUILD_TESTING "Build lit and unit tests." OFF) # needs to be BEFORE "include(CTest)"
include(CTest)
cmake_dependent_option(THORIN_LIT_WITH_VALGRIND "If ON, the Thorin CLI in the lit tests will be run under valgrind." OFF "BUILD_TESTING" OFF)
if(BUILD_TESTING)
include(GoogleTest)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
add_subdirectory(external/googletest EXCLUDE_FROM_ALL)
add_subdirectory(gtest)
add_subdirectory(lit)
endif()
endif()

set(ABSL_PROPAGATE_CXX_STD ON)
set(ABSL_USE_EXTERNAL_GOOGLETEST ON)
set(ABSL_ENABLE_INSTALL ON)
set(FE_ABSL ON)
if(NOT THORIN_INSTALL_DEPENDENCIES)
add_subdirectory(modules/abseil-cpp EXCLUDE_FROM_ALL)
add_subdirectory(modules/rang EXCLUDE_FROM_ALL)
add_subdirectory(modules/lyra EXCLUDE_FROM_ALL)
add_subdirectory(external/abseil-cpp EXCLUDE_FROM_ALL)
add_subdirectory(external/fe EXCLUDE_FROM_ALL)
add_subdirectory(external/lyra EXCLUDE_FROM_ALL)
add_subdirectory(external/rang EXCLUDE_FROM_ALL)
else()
add_subdirectory(modules/abseil-cpp)
add_subdirectory(modules/rang)
add_subdirectory(modules/lyra)
add_subdirectory(external/abseil-cpp)
add_subdirectory(external/fe)
add_subdirectory(external/lyra)
add_subdirectory(external/rang)
endif()
add_subdirectory(thorin)
add_subdirectory(cli)
Expand All @@ -73,39 +86,33 @@ if(THORIN_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

if(BUILD_TESTING AND THORIN_BUILD_TESTING)
add_subdirectory(gtest)
add_subdirectory(lit)
endif()

if(THORIN_BUILD_DOCS)
find_package(Doxygen REQUIRED dot)
if(DOXYGEN_FOUND)
add_subdirectory(docs)
endif()
endif()

include(CMakePackageConfigHelpers)

write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/thorin-config-version.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/thorin-config-version.cmake"
VERSION ${Thorin_VERSION}
COMPATIBILITY SameMajorVersion
)

set(THORIN_CMAKE_INSTALL_DIR lib/cmake/thorin)

install(FILES cmake/Thorin.cmake DESTINATION ${THORIN_CMAKE_INSTALL_DIR})
install(EXPORT install_exports FILE "thorin-targets.cmake" NAMESPACE thorin:: DESTINATION ${THORIN_CMAKE_INSTALL_DIR})

configure_package_config_file(
${PROJECT_SOURCE_DIR}/cmake/thorin-config.cmake.in
${PROJECT_BINARY_DIR}/thorin-config.cmake
INSTALL_DESTINATION ${THORIN_CMAKE_INSTALL_DIR}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/thorin-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/thorin-config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/thorin"
)

install(FILES
${PROJECT_BINARY_DIR}/thorin-config.cmake
${PROJECT_BINARY_DIR}/thorin-config-version.cmake
DESTINATION ${THORIN_CMAKE_INSTALL_DIR}
install(
EXPORT thorin-targets
NAMESPACE thorin::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/thorin"
)
install(
FILES
cmake/Thorin.cmake
"${CMAKE_CURRENT_BINARY_DIR}/thorin-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/thorin-config-version.cmake"
DESTINATION
"${CMAKE_INSTALL_LIBDIR}/cmake/thorin"
)
7 changes: 2 additions & 5 deletions cli/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
add_executable(thorin
main.cpp)

add_executable(thorin main.cpp)
target_link_libraries(thorin libthorin lyra)

set_target_properties(thorin PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
install(TARGETS thorin EXPORT install_exports)
install(TARGETS thorin EXPORT thorin-targets)
2 changes: 1 addition & 1 deletion cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ int main(int argc, char** argv) {

auto path = fs::path(input);
world.set(path.filename().replace_extension().string());
auto parser = fe::Parser(world);
auto parser = Parser(world);
parser.import(input, os[Md]);

if (flags.bootstrap) {
Expand Down
25 changes: 20 additions & 5 deletions cmake/Thorin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ and passes to identify the axioms.
header to be up-to-date.
- `INSTALL`: Specify, if the plugin description, plugin and headers shall
be installed with `make install`.
To export the targets, the export name `install_exports` has to be
To export the targets, the export name `thorin-targets` has to be
exported accordingly (see [install(EXPORT ..)](https://cmake.org/cmake/help/latest/command/install.html#export))


Expand Down Expand Up @@ -132,10 +132,25 @@ function(add_thorin_plugin)
)

if(${PARSED_INSTALL})
install(TARGETS thorin_${PLUGIN} EXPORT install_exports LIBRARY DESTINATION lib/thorin RUNTIME DESTINATION lib/thorin INCLUDES DESTINATION include)
install(FILES ${THORIN_FILE_LIB_DIR} DESTINATION lib/thorin)
install(FILES ${PLUGIN_H} DESTINATION include/dialects/${PLUGIN})
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${PLUGIN} DESTINATION include/dialects FILES_MATCHING PATTERN *.h)
install(
TARGETS thorin_${PLUGIN}
EXPORT thorin-targets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/thorin"
RUNTIME DESTINATION "${CMAKE_INSTALL_LIBDIR}/thorin"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")

install(
FILES ${THORIN_FILE_LIB_DIR}
DESTINATION lib/thorin)

install(
FILES ${PLUGIN_H}
DESTINATION "include/dialects/${PLUGIN}")

install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${PLUGIN} "
DESTINATION include/dialects
FILES_MATCHING PATTERN *.h)
endif()
if(TARGET thorin_all_plugins)
add_dependencies(thorin_all_plugins thorin_${PLUGIN})
Expand Down
1 change: 1 addition & 0 deletions cmake/thorin-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})

include(../absl/abslConfig)
include(../fe/fe-config)
include(../rang/rang-config)
include(thorin-targets)
set(THORIN_TARGET_NAMESPACE "thorin::")
Expand Down
Loading