diff --git a/CMakeLists.txt b/CMakeLists.txt index a3ac39df..83dc5f42 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,11 @@ cmake_minimum_required(VERSION 3.14) -project(Codon) +project(Codon VERSION "0.11.1" + HOMEPAGE_URL "https://github.com/exaloop/codon" + DESCRIPTION "high-performance, extensible Python compiler") +configure_file("${PROJECT_SOURCE_DIR}/cmake/config.h.in" + "${PROJECT_SOURCE_DIR}/compiler/config/config.h") +configure_file("${PROJECT_SOURCE_DIR}/cmake/config.py.in" + "${PROJECT_SOURCE_DIR}/docs/sphinx/config/config.py") set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden -pedantic -Wall -Wno-return-type-c-linkage -Wno-gnu-zero-variadic-macro-arguments") @@ -8,8 +14,10 @@ set(CMAKE_CXX_FLAGS_RELEASE "-O3") include_directories(.) include_directories(compiler) -# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") -# set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") +if(ASAN) + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") + set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") +endif() set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) @@ -17,7 +25,7 @@ find_package(LLVM REQUIRED) message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") -include(${CMAKE_SOURCE_DIR}/scripts/deps.cmake) +include(${CMAKE_SOURCE_DIR}/cmake/deps.cmake) set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) if(APPLE) diff --git a/scripts/backtrace-config.h.cmake b/cmake/backtrace-config.h.in similarity index 100% rename from scripts/backtrace-config.h.cmake rename to cmake/backtrace-config.h.in diff --git a/scripts/backtrace-supported.h.cmake b/cmake/backtrace-supported.h.in similarity index 100% rename from scripts/backtrace-supported.h.cmake rename to cmake/backtrace-supported.h.in diff --git a/cmake/config.h.in b/cmake/config.h.in new file mode 100644 index 00000000..f0214d85 --- /dev/null +++ b/cmake/config.h.in @@ -0,0 +1,6 @@ +#pragma once + +#define CODON_VERSION "@PROJECT_VERSION@" +#define CODON_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ +#define CODON_VERSION_MINOR @PROJECT_VERSION_MINOR@ +#define CODON_VERSION_PATCH @PROJECT_VERSION_PATCH@ diff --git a/cmake/config.py.in b/cmake/config.py.in new file mode 100644 index 00000000..0890c696 --- /dev/null +++ b/cmake/config.py.in @@ -0,0 +1,4 @@ +CODON_VERSION = "@PROJECT_VERSION@" +CODON_VERSION_MAJOR = @PROJECT_VERSION_MAJOR@ +CODON_VERSION_MINOR = @PROJECT_VERSION_MINOR@ +CODON_VERSION_PATCH = @PROJECT_VERSION_PATCH@ diff --git a/scripts/deps.cmake b/cmake/deps.cmake similarity index 68% rename from scripts/deps.cmake rename to cmake/deps.cmake index e2131af6..77541cf2 100644 --- a/scripts/deps.cmake +++ b/cmake/deps.cmake @@ -15,7 +15,41 @@ CPMAddPackage( "ZLIB_COMPAT ON" "ZLIB_ENABLE_TESTS OFF" "CMAKE_POSITION_INDEPENDENT_CODE ON") -set_target_properties(zlib PROPERTIES EXCLUDE_FROM_ALL ON) +if(zlibng_ADDED) + set_target_properties(zlib PROPERTIES EXCLUDE_FROM_ALL ON) +endif() + +CPMAddPackage( + NAME xz + GITHUB_REPOSITORY "xz-mirror/xz" + VERSION 5.2.5 + GIT_TAG e7da44d5151e21f153925781ad29334ae0786101 + OPTIONS "BUILD_SHARED_LIBS OFF" + "CMAKE_POSITION_INDEPENDENT_CODE ON") +if(xz_ADDED) + set_target_properties(xz PROPERTIES EXCLUDE_FROM_ALL ON) + set_target_properties(xzdec PROPERTIES EXCLUDE_FROM_ALL ON) +endif() + +CPMAddPackage( + NAME bz2 + URL "https://www.sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz" + DOWNLOAD_ONLY YES) +if(bz2_ADDED) + add_library(bz2 STATIC + "${bz2_SOURCE_DIR}/blocksort.c" + "${bz2_SOURCE_DIR}/huffman.c" + "${bz2_SOURCE_DIR}/crctable.c" + "${bz2_SOURCE_DIR}/randtable.c" + "${bz2_SOURCE_DIR}/compress.c" + "${bz2_SOURCE_DIR}/decompress.c" + "${bz2_SOURCE_DIR}/bzlib.c" + "${bz2_SOURCE_DIR}/libbz2.def") + set_target_properties(bz2 PROPERTIES + COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64" + POSITION_INDEPENDENT_CODE ON) +endif() + CPMAddPackage( NAME bdwgc GITHUB_REPOSITORY "ivmai/bdwgc" @@ -27,7 +61,10 @@ CPMAddPackage( "enable_large_config ON" "enable_thread_local_alloc ON" "enable_handle_fork ON") -set_target_properties(cord PROPERTIES EXCLUDE_FROM_ALL ON) +if(bdwgc_ADDED) + set_target_properties(cord PROPERTIES EXCLUDE_FROM_ALL ON) +endif() + CPMAddPackage( NAME openmp GITHUB_REPOSITORY "llvm-mirror/openmp" @@ -35,6 +72,7 @@ CPMAddPackage( GIT_TAG release_90 OPTIONS "OPENMP_ENABLE_LIBOMPTARGET OFF" "OPENMP_STANDALONE_BUILD ON") + CPMAddPackage( NAME backtrace GITHUB_REPOSITORY "ianlancetaylor/libbacktrace" @@ -54,10 +92,10 @@ if(backtrace_ADDED) endif() # Generate backtrace-supported.h based on the above. configure_file( - ${CMAKE_SOURCE_DIR}/scripts/backtrace-supported.h.cmake + ${CMAKE_SOURCE_DIR}/cmake/backtrace-supported.h.in ${backtrace_SOURCE_DIR}/backtrace-supported.h) configure_file( - ${CMAKE_SOURCE_DIR}/scripts/backtrace-config.h.cmake + ${CMAKE_SOURCE_DIR}/cmake/backtrace-config.h.in ${backtrace_SOURCE_DIR}/config.h) add_library(backtrace STATIC "${backtrace_SOURCE_DIR}/atomic.c" diff --git a/compiler/config/.gitignore b/compiler/config/.gitignore new file mode 100644 index 00000000..94548af5 --- /dev/null +++ b/compiler/config/.gitignore @@ -0,0 +1,3 @@ +* +*/ +!.gitignore diff --git a/compiler/util/common.h b/compiler/util/common.h index 8386f9d1..588d0498 100644 --- a/compiler/util/common.h +++ b/compiler/util/common.h @@ -1,9 +1,5 @@ #pragma once -#define CODON_VERSION_MAJOR 0 -#define CODON_VERSION_MINOR 11 -#define CODON_VERSION_PATCH 0 - #include #include #include @@ -13,6 +9,7 @@ #include #include +#include "config/config.h" #include "util/fmt/format.h" #include "util/fmt/ostream.h" diff --git a/docs/sphinx/conf.py b/docs/sphinx/conf.py index 54bf74c1..a7168c98 100644 --- a/docs/sphinx/conf.py +++ b/docs/sphinx/conf.py @@ -15,19 +15,23 @@ import os import sys +sys.path.insert(0, os.path.abspath("./config")) sys.path.insert(0, os.path.abspath("./_ext")) - # -- Project information ----------------------------------------------------- -project = u'Codon' -copyright = u'2019-2021, Exaloop, Inc.' -author = u'exaloop' +project = 'Codon' +copyright = '2019-2021, Exaloop, Inc.' +author = 'exaloop' +from config import CODON_VERSION_MAJOR, CODON_VERSION_MINOR, CODON_VERSION_PATCH +ver_major = CODON_VERSION_MAJOR +ver_minor = CODON_VERSION_MINOR +ver_patch = CODON_VERSION_PATCH # The short X.Y version -version = u'0.11' +version = '%d.%d' % (ver_major, ver_minor) # The full version, including alpha/beta/rc tags -release = u'0.11.0' +release = '%d.%d.%d' % (ver_major, ver_minor, ver_patch) # Logo path html_logo = 'logo.png' diff --git a/docs/sphinx/config/.gitignore b/docs/sphinx/config/.gitignore new file mode 100644 index 00000000..94548af5 --- /dev/null +++ b/docs/sphinx/config/.gitignore @@ -0,0 +1,3 @@ +* +*/ +!.gitignore diff --git a/scripts/backtrace-support.h.cmake b/scripts/backtrace-support.h.cmake deleted file mode 100644 index e69de29b..00000000