diff --git a/.cirrus.yml b/.cirrus.yml index a47e7eb8..4f9aaa67 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -12,14 +12,8 @@ freebsd_task: # LLVM_VERSION: 14 LLVM_VERSION: 15 LLVM_VERSION: 16 - matrix: - # USE_CMAKE: 0 - USE_CMAKE: 1 install_script: pkg install -y bash coreutils cmake gmake llvm$LLVM_VERSION script: | - export LLVM_CONFIG=llvm-config$LLVM_VERSION - export CLANG=clang$LLVM_VERSION - export MAKE=gmake export CC=cc bash travis.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a81a9612..8ff74f74 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,38 +15,20 @@ jobs: env: CHECK_CLANG_FORMAT: 1 build: - name: Build (${{ matrix.os }}, llvm-${{ matrix.llvm }}, cmake=${{ matrix.cmake }}, cuda=${{ matrix.cuda }}, ${{ matrix.lua }}) + name: Build (${{ matrix.os }}, llvm-${{ matrix.llvm }}, cuda=${{ matrix.cuda }}, ${{ matrix.lua }}) runs-on: ${{ matrix.os }} strategy: matrix: - os: ['ubuntu-22.04', 'macos-11', 'windows-2022'] + os: ['macos-11', 'windows-2022'] llvm: ['11', '12', '13', '14', '15', '16'] - cmake: ['0', '1'] cuda: ['0', '1'] lua: ['luajit', 'moonjit'] exclude: - # Linux: exclude LLVM 11-13, 15-16, cmake - # Note: CMake configurations are tested in Docker - - os: 'ubuntu-22.04' - llvm: '11' - - os: 'ubuntu-22.04' - llvm: '12' - - os: 'ubuntu-22.04' - llvm: '13' - - os: 'ubuntu-22.04' - llvm: '15' - - os: 'ubuntu-22.04' - llvm: '16' - - os: 'ubuntu-22.04' - cmake: '1' - - # macOS: exclude make, cuda - - os: 'macos-11' - cmake: '0' + # macOS: exclude cuda - os: 'macos-11' cuda: '1' - # Windows: exclude LLVM 12-16, make + # Windows: exclude LLVM 12-16 - os: 'windows-2022' llvm: '12' - os: 'windows-2022' @@ -57,12 +39,6 @@ jobs: llvm: '15' - os: 'windows-2022' llvm: '16' - - os: 'windows-2022' - cmake: '0' - - # Moonjit requires CMake - - cmake: '0' - lua: 'moonjit' # CUDA: only LLVM 11 - llvm: '12' @@ -92,9 +68,7 @@ jobs: - run: ./travis.sh shell: bash env: - LLVM_CONFIG: llvm-config-${{ matrix.llvm }} - CLANG: clang-${{ matrix.llvm }} - USE_CMAKE: ${{ matrix.cmake }} + LLVM_VERSION: ${{ matrix.llvm }} USE_CUDA: ${{ matrix.cuda }} STATIC_LLVM: 1 STATIC_LUAJIT: 1 diff --git a/CHANGES.md b/CHANGES.md index b0605058..e3d4f3d7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,7 @@ ## Removed features * Removed support for LLVM <= 10 + * Removed the long-deprecated Makefile build # Release 1.1.1 (2023-08-22) diff --git a/GNUmakefile b/GNUmakefile deleted file mode 100644 index e00da295..00000000 --- a/GNUmakefile +++ /dev/null @@ -1,339 +0,0 @@ - -# If the defaults for LLVM_CONFIG are not right for your installation -# create a Makefile.inc file and point LLVM_CONFIG at the llvm-config binary for your llvm distribution -# If you want to enable cuda compiler support is enabled if the path specified by -# CUDA_HOME exists - --include Makefile.inc - -# Debian packages name llvm-config with a version number - list them here in preference order -LLVM_CONFIG ?= $(shell which llvm-config13 llvm-config14 llvm-config false | head -1) -#luajit will be downloaded automatically (it's much smaller than llvm) -#to override this, set LUAJIT_PREFIX to the home of an already installed luajit -LUAJIT_PREFIX ?= build - -# same with clang -CLANG ?= $(shell which clang-3.5 clang false | head -1) - -CXX ?= $(CLANG)++ -CC ?= $(CLANG) - -LLVM_PREFIX = $(shell $(LLVM_CONFIG) --prefix) - -#if clang is not installed in the same prefix as llvm -#then use the clang in the caller's path -ifeq ($(wildcard $(LLVM_PREFIX)/bin/clang),) -CLANG_PREFIX ?= $(dir $(shell $(CLANG) --version |awk '$$1 == "InstalledDir:" { print$$2 }')) -else -CLANG_PREFIX ?= $(LLVM_PREFIX) -endif - -CUDA_HOME ?= /usr/local/cuda -ENABLE_CUDA ?= $(shell test -e $(CUDA_HOME) && echo 1 || echo 0) - -.SUFFIXES: -.SECONDARY: -UNAME := $(shell uname) - - -PKG_CONFIG = $(shell which pkg-config false | head -1) - -AR = ar -LD = ld -FLAGS += -Wall -g -fPIC -LFLAGS = -g - -# The -E flag is BSD-specific. It is supported (though undocumented) -# on certain newer versions of GNU Sed, but not all. Check for -E -# support and otherwise fall back to the GNU Sed flag -r. -SED_E = sed -E -ifeq ($(shell sed -E '' /dev/null 2>&1 && echo yes || echo no),no) -SED_E = sed -r -endif - -TERRA_VERSION_RAW=$(shell git describe --tags 2>/dev/null || echo unknown) -TERRA_VERSION=$(shell echo "$(TERRA_VERSION_RAW)" | $(SED_E) 's/^release-//') -FLAGS += -DTERRA_VERSION_STRING="\"$(TERRA_VERSION)\"" - -# Add the following lines to Makefile.inc to switch to LuaJIT-2.1 beta releases -#LUAJIT_VERSION_BASE =2.1 -#LUAJIT_VERSION_EXTRA =.0-beta2 - -LUAJIT_VERSION_BASE ?= 2.1 -LUAJIT_VERSION_EXTRA ?= .0-beta3 -LUAJIT_VERSION ?= LuaJIT-$(LUAJIT_VERSION_BASE)$(LUAJIT_VERSION_EXTRA) -LUAJIT_EXECUTABLE ?= luajit-$(LUAJIT_VERSION_BASE)$(LUAJIT_VERSION_EXTRA) -LUAJIT_COMMIT ?= 50936d784474747b4569d988767f1b5bab8bb6d0 -ifneq ($(strip $(LUAJIT_COMMIT)),) -LUAJIT_URL ?= https://github.com/LuaJIT/LuaJIT/archive/$(LUAJIT_COMMIT).tar.gz -LUAJIT_TAR ?= LuaJIT-$(LUAJIT_COMMIT).tar.gz -LUAJIT_DIR ?= build/LuaJIT-$(LUAJIT_COMMIT) -else -LUAJIT_URL ?= http://luajit.org/download/$(LUAJIT_VERSION).tar.gz -LUAJIT_TAR ?= $(LUAJIT_VERSION).tar.gz -LUAJIT_DIR ?= build/$(LUAJIT_VERSION) -endif -LUAJIT_LIB ?= $(LUAJIT_PREFIX)/lib/libluajit-5.1.a -LUAJIT_INCLUDE ?= $(dir $(shell ls 2>/dev/null $(LUAJIT_PREFIX)/include/luajit-$(LUAJIT_VERSION_BASE)/lua.h || ls 2>/dev/null $(LUAJIT_PREFIX)/include/lua.h || echo $(LUAJIT_PREFIX)/include/luajit-$(LUAJIT_VERSION_BASE)/lua.h)) -LUAJIT ?= $(LUAJIT_PREFIX)/bin/$(LUAJIT_EXECUTABLE) - -FLAGS += -I build -I $(LUAJIT_INCLUDE) -I release/include/terra -I $(shell $(LLVM_CONFIG) --includedir) -I $(CLANG_PREFIX)/include - -FLAGS += -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -O0 -fno-common -Wcast-qual -CPPFLAGS = -fno-rtti -Woverloaded-virtual -fvisibility-inlines-hidden - -LLVM_VERSION_NUM=$(shell $(LLVM_CONFIG) --version | sed -e s/svn//) -LLVM_VERSION=$(shell echo $(LLVM_VERSION_NUM) | $(SED_E) 's/^([0-9]+)\.([0-9]+).*/\1\2/') -LLVM_VERSION_MAJOR=$(shell echo $(LLVM_VERSION_NUM) | $(SED_E) 's/^([0-9]+)\..*/\1/') - -FLAGS += -DLLVM_VERSION=$(LLVM_VERSION) - -ifeq ($(shell expr $(LLVM_VERSION) \>= 160), 1) -CPPFLAGS += -std=c++17 -else -ifeq ($(shell expr $(LLVM_VERSION) \>= 100), 1) -CPPFLAGS += -std=c++14 -else -CPPFLAGS += -std=c++11 -endif -endif - -ifneq ($(findstring $(UNAME), Linux FreeBSD),) -DYNFLAGS = -shared -fPIC -TERRA_STATIC_LIBRARY += -Wl,-export-dynamic -Wl,--whole-archive $(LIBRARY) -Wl,--no-whole-archive -else -DYNFLAGS = -dynamiclib -single_module -fPIC -install_name "@rpath/libterra.dylib" -TERRA_STATIC_LIBRARY = -Wl,-force_load,$(LIBRARY) -endif - -CLANG_LIBS += libclangFrontend.a \ - libclangDriver.a \ - libclangSerialization.a \ - libclangCodeGen.a \ - libclangParse.a \ - libclangSema.a \ - libclangAnalysis.a \ - libclangEdit.a \ - libclangAST.a \ - libclangLex.a \ - libclangBasic.a - -ifeq ($(shell expr $(LLVM_VERSION) \>= 80), 1) -CLANG_LIBS += libclangASTMatchers.a -endif - -ifeq ($(shell expr $(LLVM_VERSION) \>= 150), 1) -CLANG_LIBS += libclangSupport.a -endif - -# Get full path to clang libaries -CLANG_LIBFILES := $(patsubst %, $(CLANG_PREFIX)/lib/%, $(CLANG_LIBS)) - -LLVM_LIBS += $(shell $(LLVM_CONFIG) --libs --link-static) -LLVM_LIBFILES := $(shell $(LLVM_CONFIG) --libfiles --link-static) - -ifeq ($(shell expr $(LLVM_VERSION) \>= 100), 1) - LLVM_LIBFILES += $(shell $(LLVM_CONFIG) --libdir)/libPolly*.a -endif - -# llvm sometimes requires ncurses and libz, check if they have the symbols, and add them if they do -ifeq ($(shell nm $(LLVM_PREFIX)/lib/libLLVMSupport.a | grep setupterm >/dev/null 2>&1; echo $$?), 0) - SUPPORT_LIBRARY_FLAGS += -lcurses -endif -ifeq ($(shell nm $(LLVM_PREFIX)/lib/libLLVMSupport.a | grep compress2 >/dev/null 2>&1; echo $$?), 0) - SUPPORT_LIBRARY_FLAGS += -lz -endif - -ifeq ($(UNAME), Linux) -SUPPORT_LIBRARY_FLAGS += -ldl -pthread -endif -ifeq ($(UNAME), FreeBSD) -SUPPORT_LIBRARY_FLAGS += -lexecinfo -pthread -endif - -LIBFFI_LIBS = $(shell $(PKG_CONFIG) --libs libffi) -FLAGS += $(shell $(PKG_CONFIG) --cflags libffi) -ifeq ($(LIBFFI_LIBS),) -$(error libffi is not installed) -endif - -LIBXML20_LIBS = $(shell $(PKG_CONFIG) --libs libxml-2.0) -FLAGS += $(shell $(PKG_CONFIG) --cflags libxml-2.0) -ifeq ($(LIBXML20_LIBS),) -$(error libxml-2.0 is not installed) -endif - -LIBEDIT_LIBS = $(shell $(PKG_CONFIG) --libs libedit) -FLAGS += $(shell $(PKG_CONFIG) --cflags libedit) -ifeq ($(LIBEDIT_LIBS),) -$(error libedit is not installed) -endif - -SUPPORT_LIBRARY_FLAGS += $(LIBFFI_LIBS) $(LIBXML20_LIBS) $(LIBEDIT_LIBS) - -PACKAGE_DEPS += $(LUAJIT_LIB) - -ifeq ($(shell expr $(LLVM_VERSION) \>= 160), 1) -CLANG_RESOURCE_DIRECTORY=$(CLANG_PREFIX)/lib/clang/$(LLVM_VERSION_MAJOR) -else -CLANG_RESOURCE_DIRECTORY=$(CLANG_PREFIX)/lib/clang/$(LLVM_VERSION_NUM) -endif - -ifeq ($(ENABLE_CUDA),1) -CUDA_INCLUDES = -DTERRA_ENABLE_CUDA -I $(CUDA_HOME)/include -I $(CUDA_HOME)/nvvm/include -FLAGS += $(CUDA_INCLUDES) -endif - -ifeq (OFF,$(shell $(LLVM_CONFIG) --assertion-mode)) -FLAGS += -DTERRA_LLVM_HEADERS_HAVE_NDEBUG -endif - -LIBOBJS = tkind.o tcompiler.o tllvmutil.o tcwrapper.o tinline.o terra.o lparser.o lstring.o lobject.o lzio.o llex.o lctype.o treadnumber.o tcuda.o tdebug.o tinternalizedfiles.o lj_strscan.o -LIBLUA = terralib.lua strict.lua cudalib.lua asdl.lua terralist.lua - -EXEOBJS = main.o linenoise.o - -EMBEDDEDLUA = $(addprefix build/,$(LIBLUA:.lua=.h)) -GENERATEDHEADERS = $(EMBEDDEDLUA) build/internalizedfiles.h - -LUAHEADERS = lua.h lualib.h lauxlib.h luaconf.h - -OBJS = $(LIBOBJS) $(EXEOBJS) - -EXECUTABLE = release/bin/terra -LIBRARY = release/lib/libterra.a -LIBRARY_NOLUA = release/lib/libterra_nolua.a -LIBRARY_NOLUA_NOLLVM = release/lib/libterra_nolua_nollvm.a -LIBRARY_VARIANTS = $(LIBRARY_NOLUA) $(LIBRARY_NOLUA_NOLLVM) -ifeq ($(UNAME), Darwin) -DYNLIBRARY = release/lib/libterra.dylib -DYNLIBRARY_LINK = release/lib/terra.dylib -else -DYNLIBRARY = release/lib/libterra.so -DYNLIBRARY_LINK = release/lib/terra.so -endif -RELEASE_HEADERS = $(addprefix release/include/terra/,$(LUAHEADERS)) -BIN2C = build/bin2c - -#put any install-specific stuff in here --include Makefile.inc - -.PHONY: all clean download purge test release install -all: $(EXECUTABLE) $(DYNLIBRARY) $(DYNLIBRARY_LINK) - -test: all - (cd tests; ./run) - -variants: $(LIBRARY_VARIANTS) - -build/%.o: src/%.cpp $(PACKAGE_DEPS) - $(CXX) $(FLAGS) $(CPPFLAGS) $< -c -o $@ - -build/%.o: src/%.c $(PACKAGE_DEPS) - $(CC) $(FLAGS) $< -c -o $@ - -download: build/$(LUAJIT_TAR) - -build/$(LUAJIT_TAR): -ifeq ($(UNAME), Darwin) - curl -L $(LUAJIT_URL) -o build/$(LUAJIT_TAR) -else - wget $(LUAJIT_URL) -O build/$(LUAJIT_TAR) -endif - -build/lib/libluajit-5.1.a: build/$(LUAJIT_TAR) - (cd build; tar -xf $(LUAJIT_TAR)) - # MACOSX_DEPLOYMENT_TARGET is a workaround for https://github.com/LuaJIT/LuaJIT/issues/484 - # see also https://github.com/LuaJIT/LuaJIT/issues/575 - (cd $(LUAJIT_DIR); $(MAKE) install PREFIX=$(realpath build) CC=$(CC) STATIC_CC="$(CC) -fPIC" XCFLAGS=-DLUAJIT_ENABLE_GC64 MACOSX_DEPLOYMENT_TARGET=10.7) - -release/include/terra/%.h: $(LUAJIT_INCLUDE)/%.h $(LUAJIT_LIB) - cp $(LUAJIT_INCLUDE)/$*.h $@ - -build/llvm_objects/llvm_list: $(addprefix build/, $(LIBOBJS) $(EXEOBJS)) - mkdir -p build/llvm_objects/luajit - # Extract Luajit + all LLVM & Clang libraries - cd build/llvm_objects; for lib in $(LUAJIT_LIB) $(LLVM_LIBFILES) $(CLANG_LIBFILES); do \ - echo Extracing objects from $$lib; \ - DIR=$$(basename $$lib .a); \ - mkdir -p $$DIR; \ - cd $$DIR; \ - ar x $$lib; \ - cd ..; \ - done - -build/lua_objects/lj_obj.o: $(LUAJIT_LIB) - mkdir -p build/lua_objects - cd build/lua_objects; ar x $(realpath $(LUAJIT_LIB)) - -$(LIBRARY): $(RELEASE_HEADERS) $(addprefix build/, $(LIBOBJS)) build/llvm_objects/llvm_list build/lua_objects/lj_obj.o - mkdir -p release/lib - rm -f $@ - $(AR) -cq $@ $(addprefix build/, $(LIBOBJS)) build/llvm_objects/*/*.o build/lua_objects/*.o - ranlib $@ - -$(LIBRARY_NOLUA): $(RELEASE_HEADERS) $(addprefix build/, $(LIBOBJS)) build/llvm_objects/llvm_list - mkdir -p release/lib - rm -f $@ - $(AR) -cq $@ $(addprefix build/, $(LIBOBJS)) build/llvm_objects/*/*.o - -$(LIBRARY_NOLUA_NOLLVM): $(RELEASE_HEADERS) $(addprefix build/, $(LIBOBJS)) - mkdir -p release/lib - rm -f $@ - $(AR) -cq $@ $(addprefix build/, $(LIBOBJS)) - -$(DYNLIBRARY): $(LIBRARY) - $(CXX) $(DYNFLAGS) $(TERRA_STATIC_LIBRARY) $(SUPPORT_LIBRARY_FLAGS) -o $@ - -$(DYNLIBRARY_LINK): $(DYNLIBRARY) - ln -s $(notdir $(DYNLIBRARY)) $(DYNLIBRARY_LINK) - -$(EXECUTABLE): $(addprefix build/, $(EXEOBJS)) $(LIBRARY) - mkdir -p release/bin release/lib - $(CXX) $(addprefix build/, $(EXEOBJS)) -o $@ $(LFLAGS) $(TERRA_STATIC_LIBRARY) $(SUPPORT_LIBRARY_FLAGS) - if [ ! -e terra ]; then ln -s $(EXECUTABLE) terra; fi; - -$(BIN2C): src/bin2c.c - $(CC) -O3 -o $@ $< - - -#rule for packaging lua code into a header file -build/%.bc: src/%.lua $(PACKAGE_DEPS) - $(LUAJIT) -bg $< $@ -build/%.h: build/%.bc $(PACKAGE_DEPS) - $(LUAJIT) src/genheader.lua $< $@ - -build/internalizedfiles.h: $(PACKAGE_DEPS) src/geninternalizedfiles.lua lib/std.t lib/parsing.t - $(LUAJIT) src/geninternalizedfiles.lua $@ $(CLANG_RESOURCE_DIRECTORY) "%.h$$" $(CLANG_RESOURCE_DIRECTORY) "%.modulemap$$" lib "%.t$$" - -clean: - rm -rf build/*.o build/*.d $(GENERATEDHEADERS) - rm -rf $(EXECUTABLE) terra $(LIBRARY) $(LIBRARY_NOLUA) $(LIBRARY_NOLUA_NOLLVM) $(DYNLIBRARY) $(DYNLIBRARY_LINK) $(RELEASE_HEADERS) build/llvm_objects build/lua_objects - -purge: clean - rm -rf build/* - -TERRA_SHARE_PATH=release/share/terra - -RELEASE_NAME := terra-`uname | sed -e s/Darwin/OSX/ | sed -e s/CYGWIN.*/Windows/`-`uname -m`-`git rev-parse --short HEAD` -release: - for i in `git ls-tree HEAD -r tests --name-only`; do mkdir -p $(TERRA_SHARE_PATH)/`dirname $$i`; cp $$i $(TERRA_SHARE_PATH)/$$i; done; - mv release $(RELEASE_NAME) - zip -q -r $(RELEASE_NAME).zip $(RELEASE_NAME) - mv $(RELEASE_NAME) release - -PREFIX ?= /usr/local -install: all - cp -R release/* $(PREFIX) - -# dependency rules -DEPENDENCIES = $(patsubst %.o,build/%.d,$(OBJS)) -build/%.d: src/%.cpp $(PACKAGE_DEPS) $(GENERATEDHEADERS) - @$(CXX) $(FLAGS) $(CPPFLAGS) -w -MM -MT '$@ $(@:.d=.o)' $< -o $@ -build/%.d: src/%.c $(PACKAGE_DEPS) $(GENERATEDHEADERS) - @$(CC) $(FLAGS) -w -MM -MT '$@ $(@:.d=.o)' $< -o $@ - -#if we are cleaning, then don't include dependencies (which would require the header files are built) -ifeq ($(findstring $(MAKECMDGOALS),download purge clean release),) --include $(DEPENDENCIES) -endif diff --git a/Makefile b/Makefile deleted file mode 100644 index 5a628f57..00000000 --- a/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -all: - @echo Please use gmake instead of bmake to build this project! - @false - -.PHONY: all diff --git a/release/share/terra/README.md b/release/share/terra/README.md index 862c2ff2..e9b071c5 100644 --- a/release/share/terra/README.md +++ b/release/share/terra/README.md @@ -137,11 +137,6 @@ On FreeBSD, use: pkg install -y cmake llvm13 ``` -Terra also supports an older build system based on GNU Make (for -Linux, macOS and FreeBSD only). This build system is deprecated, and -in the vast majority of circumstances CMake is both preferred and -substantially more flexible. - ### Supported LLVM Versions ### The current recommended version of LLVM is **13**. The following versions are also supported: @@ -247,45 +242,6 @@ further configure the Terra build via CMake: * `TERRA_STATIC_LINK_LUAJIT` (default `ON`): Whether to statically link against LuaJIT or not. * `TERRA_SLIB_INCLUDE_LUAJIT` (default `ON`, except on Windows): Whether `libterra_s.a` should include LuaJIT or not. -### Building Terra with GNU Make (Linux, macOS, FreeBSD) - -Note: This build system is deprecated. Please use CMake instead (see -above). - -The basic procedure for building with GNU Make is the following: - -``` -git clone https://github.com/terralang/terra.git -cd terra -make -j4 # tune this for how many cores you have -``` - -This will build Terra into the `terra/release` directory. - -Make will attempt to auto-detect the location of LLVM by searching for -`llvm-config` on `PATH`. If it is unable to do so (e.g., because LLVM -is installed in a non-standard location), this can be specified -manually by setting the following environment variable: - -``` -export LLVM_CONFIG=path/to/llvm/bin/llvm-config -``` - -This can also be set by creating a file called `Makefile.inc` with the -following contents: - -``` -LLVM_CONFIG=path/to/llvm/bin/llvm-config -``` - -Similarly, Make will attempt to discover the location of `clang`. If -this fails, it can be corrected via the `CLANG` environment (or -Makefile) variable. - -The Make build will automatically detect CUDA if it is installed at -`/usr/local/cuda`. Otherwise, please set `CUDA_HOME` to the location -where CUDA is installed. - ### Building Terra with CMake (Windows) See the CMake instructions above. The biggest caveats when buildings diff --git a/travis.sh b/travis.sh index baadea50..dbebfcba 100755 --- a/travis.sh +++ b/travis.sh @@ -29,55 +29,48 @@ if [[ -n $DOCKER_DISTRO ]]; then fi if [[ $(uname) = Linux ]]; then - distro_name="$(lsb_release -cs)" - sudo apt-get update -qq - if [[ $LLVM_CONFIG = llvm-config-14 ]]; then - sudo apt-get install -y llvm-14-dev clang-14 libclang-14-dev libedit-dev libpfm4-dev - else - echo "Don't know this LLVM version: $LLVM_CONFIG" - echo "(If you're looking for more configurations, see Docker tests.)" - exit 1 - fi + echo "Use Docker for testing build on Linux" + exit 1 elif [[ $(uname) = Darwin ]]; then - if [[ $LLVM_CONFIG = llvm-config-16 ]]; then + if [[ $LLVM_VERSION = 16 ]]; then curl -L -O https://github.com/terralang/llvm-build/releases/download/llvm-16.0.3/clang+llvm-16.0.3-x86_64-apple-darwin.tar.xz tar xf clang+llvm-16.0.3-x86_64-apple-darwin.tar.xz ln -s clang+llvm-16.0.3-x86_64-apple-darwin/bin/llvm-config llvm-config-16 ln -s clang+llvm-16.0.3-x86_64-apple-darwin/bin/clang clang-16 export CMAKE_PREFIX_PATH=$PWD/clang+llvm-16.0.3-x86_64-apple-darwin - elif [[ $LLVM_CONFIG = llvm-config-15 ]]; then + elif [[ $LLVM_VERSION = 15 ]]; then curl -L -O https://github.com/terralang/llvm-build/releases/download/llvm-15.0.2/clang+llvm-15.0.2-x86_64-apple-darwin.tar.xz tar xf clang+llvm-15.0.2-x86_64-apple-darwin.tar.xz ln -s clang+llvm-15.0.2-x86_64-apple-darwin/bin/llvm-config llvm-config-15 ln -s clang+llvm-15.0.2-x86_64-apple-darwin/bin/clang clang-15 export CMAKE_PREFIX_PATH=$PWD/clang+llvm-15.0.2-x86_64-apple-darwin - elif [[ $LLVM_CONFIG = llvm-config-14 ]]; then + elif [[ $LLVM_VERSION = 14 ]]; then curl -L -O https://github.com/terralang/llvm-build/releases/download/llvm-14.0.6/clang+llvm-14.0.6-x86_64-apple-darwin.tar.xz tar xf clang+llvm-14.0.6-x86_64-apple-darwin.tar.xz ln -s clang+llvm-14.0.6-x86_64-apple-darwin/bin/llvm-config llvm-config-14 ln -s clang+llvm-14.0.6-x86_64-apple-darwin/bin/clang clang-14 export CMAKE_PREFIX_PATH=$PWD/clang+llvm-14.0.6-x86_64-apple-darwin - elif [[ $LLVM_CONFIG = llvm-config-13 ]]; then + elif [[ $LLVM_VERSION = 13 ]]; then curl -L -O https://github.com/terralang/llvm-build/releases/download/llvm-13.0.1/clang+llvm-13.0.1-x86_64-apple-darwin.tar.xz tar xf clang+llvm-13.0.1-x86_64-apple-darwin.tar.xz ln -s clang+llvm-13.0.1-x86_64-apple-darwin/bin/llvm-config llvm-config-13 ln -s clang+llvm-13.0.1-x86_64-apple-darwin/bin/clang clang-13 export CMAKE_PREFIX_PATH=$PWD/clang+llvm-13.0.1-x86_64-apple-darwin - elif [[ $LLVM_CONFIG = llvm-config-12 ]]; then + elif [[ $LLVM_VERSION = 12 ]]; then curl -L -O https://github.com/terralang/llvm-build/releases/download/llvm-12.0.1/clang+llvm-12.0.1-x86_64-apple-darwin-macos11.tar.xz tar xf clang+llvm-12.0.1-x86_64-apple-darwin-macos11.tar.xz ln -s clang+llvm-12.0.1-x86_64-apple-darwin/bin/llvm-config llvm-config-12 ln -s clang+llvm-12.0.1-x86_64-apple-darwin/bin/clang clang-12 export CMAKE_PREFIX_PATH=$PWD/clang+llvm-12.0.1-x86_64-apple-darwin - elif [[ $LLVM_CONFIG = llvm-config-11 ]]; then + elif [[ $LLVM_VERSION = 11 ]]; then curl -L -O https://github.com/terralang/llvm-build/releases/download/llvm-11.1.0/clang+llvm-11.1.0-x86_64-apple-darwin-macos11.tar.xz tar xf clang+llvm-11.1.0-x86_64-apple-darwin-macos11.tar.xz ln -s clang+llvm-11.1.0-x86_64-apple-darwin/bin/llvm-config llvm-config-11 ln -s clang+llvm-11.1.0-x86_64-apple-darwin/bin/clang clang-11 export CMAKE_PREFIX_PATH=$PWD/clang+llvm-11.1.0-x86_64-apple-darwin else - echo "Don't know this LLVM version: $LLVM_CONFIG" + echo "Don't know this LLVM version: $LLVM_VERSION" exit 1 fi @@ -89,11 +82,11 @@ elif [[ $(uname) = Darwin ]]; then export PATH=$PWD:$PATH elif [[ $(uname) = MINGW* ]]; then - if [[ $LLVM_CONFIG = llvm-config-14 ]]; then + if [[ $LLVM_VERSION = 14 ]]; then curl -L -O https://github.com/terralang/llvm-build/releases/download/llvm-14.0.0/clang+llvm-14.0.0-x86_64-windows-msvc17.7z 7z x -y clang+llvm-14.0.0-x86_64-windows-msvc17.7z export CMAKE_PREFIX_PATH=$PWD/clang+llvm-14.0.0-x86_64-windows-msvc17 - elif [[ $LLVM_CONFIG = llvm-config-11 ]]; then + elif [[ $LLVM_VERSION = 11 ]]; then curl -L -O https://github.com/terralang/llvm-build/releases/download/llvm-11.1.0/clang+llvm-11.1.0-x86_64-windows-msvc17.7z 7z x -y clang+llvm-11.1.0-x86_64-windows-msvc17.7z export CMAKE_PREFIX_PATH=$PWD/clang+llvm-11.1.0-x86_64-windows-msvc17 @@ -118,72 +111,68 @@ else exit 1 fi -if [[ $USE_CMAKE -eq 1 ]]; then - CMAKE_FLAGS=() - if [[ -n $STATIC_LLVM && $STATIC_LLVM -eq 0 ]]; then - CMAKE_FLAGS+=( - -DTERRA_STATIC_LINK_LLVM=OFF - ) - fi - if [[ -n $SLIB_INCLUDE_LLVM && $SLIB_INCLUDE_LLVM -eq 0 ]]; then - CMAKE_FLAGS+=( - -DTERRA_SLIB_INCLUDE_LLVM=OFF - ) - fi - if [[ -n $STATIC_LUAJIT && $STATIC_LUAJIT -eq 0 ]]; then - CMAKE_FLAGS+=( - -DTERRA_STATIC_LINK_LUAJIT=OFF - ) - fi - if [[ -n $SLIB_INCLUDE_LUAJIT && $SLIB_INCLUDE_LUAJIT -eq 0 ]]; then - CMAKE_FLAGS+=( - -DTERRA_SLIB_INCLUDE_LUAJIT=OFF - ) - fi - if [[ -n $TERRA_LUA ]]; then - CMAKE_FLAGS+=( - -DTERRA_LUA=$TERRA_LUA - ) - fi - if [[ $USE_CUDA -eq 1 ]]; then - # Terra should autodetect, but force an error if it doesn't work. - CMAKE_FLAGS+=( - -DTERRA_ENABLE_CUDA=ON - ) - fi +CMAKE_FLAGS=() +if [[ -n $STATIC_LLVM && $STATIC_LLVM -eq 0 ]]; then + CMAKE_FLAGS+=( + -DTERRA_STATIC_LINK_LLVM=OFF + ) +fi +if [[ -n $SLIB_INCLUDE_LLVM && $SLIB_INCLUDE_LLVM -eq 0 ]]; then + CMAKE_FLAGS+=( + -DTERRA_SLIB_INCLUDE_LLVM=OFF + ) +fi +if [[ -n $STATIC_LUAJIT && $STATIC_LUAJIT -eq 0 ]]; then + CMAKE_FLAGS+=( + -DTERRA_STATIC_LINK_LUAJIT=OFF + ) +fi +if [[ -n $SLIB_INCLUDE_LUAJIT && $SLIB_INCLUDE_LUAJIT -eq 0 ]]; then + CMAKE_FLAGS+=( + -DTERRA_SLIB_INCLUDE_LUAJIT=OFF + ) +fi +if [[ -n $TERRA_LUA ]]; then + CMAKE_FLAGS+=( + -DTERRA_LUA=$TERRA_LUA + ) +fi +if [[ $USE_CUDA -eq 1 ]]; then + # Terra should autodetect, but force an error if it doesn't work. + CMAKE_FLAGS+=( + -DTERRA_ENABLE_CUDA=ON + ) +fi - pushd build - cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/../install "${CMAKE_FLAGS[@]}" - if [[ $(uname) = MINGW* ]]; then - cmake --build . --target INSTALL --config Release - else - make install -j${THREADS:-2} - fi +pushd build +cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/../install "${CMAKE_FLAGS[@]}" +if [[ $(uname) = MINGW* ]]; then + cmake --build . --target INSTALL --config Release +else + make install -j${THREADS:-2} +fi - # Skip ctest on Windows; this is currently broken. - if [[ $(uname) != MINGW* ]]; then - ctest --output-on-failure -j${THREADS:-2} - fi - popd +# Skip ctest on Windows; this is currently broken. +if [[ $(uname) != MINGW* ]]; then + ctest --output-on-failure -j${THREADS:-2} +fi +popd - # Skip this on macOS because it spews too much on Mojave and newer. - if [[ $(uname) != Darwin ]]; then - pushd tests - ../install/bin/terra ./run - popd - fi +# Skip this on macOS because it spews too much on Mojave and newer. +if [[ $(uname) != Darwin ]]; then + pushd tests + ../install/bin/terra ./run + popd +fi - # Only deploy CMake builds, and only with LLVM 13 (macOS) and 11 (Windows). - if [[ (( $(uname) == Darwin && $LLVM_CONFIG = llvm-config-13 ) || ( $(uname) == MINGW* && $LLVM_CONFIG = llvm-config-11 && $USE_CUDA -eq 1 )) && $SLIB_INCLUDE_LLVM -eq 1 && $TERRA_LUA = luajit ]]; then - RELEASE_NAME=terra-`uname | sed -e s/Darwin/OSX/ | sed -e s/MINGW.*/Windows/`-`uname -m`-`git rev-parse --short HEAD` - mv install $RELEASE_NAME - if [[ $(uname) = MINGW* ]]; then - 7z a -t7z $RELEASE_NAME.7z $RELEASE_NAME - else - tar cfJv $RELEASE_NAME.tar.xz $RELEASE_NAME - fi - mv $RELEASE_NAME install +# Only deploy builds with LLVM 13 (macOS) and 11 (Windows). +if [[ (( $(uname) == Darwin && $LLVM_VERSION = 13 ) || ( $(uname) == MINGW* && $LLVM_VERSION = 11 && $USE_CUDA -eq 1 )) && $SLIB_INCLUDE_LLVM -eq 1 && $TERRA_LUA = luajit ]]; then + RELEASE_NAME=terra-`uname | sed -e s/Darwin/OSX/ | sed -e s/MINGW.*/Windows/`-`uname -m`-`git rev-parse --short HEAD` + mv install $RELEASE_NAME + if [[ $(uname) = MINGW* ]]; then + 7z a -t7z $RELEASE_NAME.7z $RELEASE_NAME + else + tar cfJv $RELEASE_NAME.tar.xz $RELEASE_NAME fi -else - ${MAKE:-make} LLVM_CONFIG=$(which $LLVM_CONFIG) CLANG=$(which $CLANG) test -j${THREADS:-2} + mv $RELEASE_NAME install fi