builder: Add support for automatic toolchain setup
This commit is contained in:
parent
59f54b5678
commit
8d0e979b5f
31
builder
31
builder
|
@ -138,7 +138,6 @@ function gen_precompile_header_index() {
|
|||
} > ./include/serene_precompiles.h
|
||||
}
|
||||
|
||||
|
||||
function pushed_build() {
|
||||
mkdir -p "$BUILD_DIR"
|
||||
pushd "$BUILD_DIR" > /dev/null || return
|
||||
|
@ -151,16 +150,20 @@ function popd_build() {
|
|||
|
||||
|
||||
function build-gen() {
|
||||
local args
|
||||
setup_toolchain
|
||||
args=(
|
||||
"-DSERENE_TOOLCHAIN_PATH=$SERENE_TOOLCHAIN_PATH"
|
||||
"-DCMAKE_TOOLCHAIN_FILE=$ME/cmake/toolchains/x86_64-linux-musl.cmake"
|
||||
"-C"
|
||||
"$ME/cmake/caches/$1.cmake"
|
||||
)
|
||||
|
||||
pushed_build
|
||||
|
||||
info "Running: "
|
||||
info "cmake -G Ninja" -C "$ME/cmake/caches/serene_$1.cmake" "$ME" "${@:2}"
|
||||
cmake -G Ninja \
|
||||
-DSERENE_CONFIG_HOME="$SERENE_HOME_DIR" \
|
||||
-DLLVM_VERSION="$LLVM_VERSION" \
|
||||
-DBDWGC_VERSION="$BDWGC_VERSION" \
|
||||
-DMUSL_VERSION="$MUSL_VERSION" \
|
||||
-C "$ME/cmake/caches/serene_$1.cmake" \
|
||||
-DCMAKE_TOOLCHAIN_FILE="$ME/cmake/toolchains/x86_64-linux-musl.cmake" \
|
||||
info "cmake -G Ninja" "${args[@]}" "$ME" "${@:2}"
|
||||
cmake -G Ninja "${args[@]}" \
|
||||
"$ME" \
|
||||
"${@:2}"
|
||||
popd_build
|
||||
|
@ -180,7 +183,7 @@ function build() { ## Builds the project by regenerating the build scripts
|
|||
local cpus
|
||||
|
||||
rm -rf "$BUILD_DIR"
|
||||
build-gen "dev" "$@"
|
||||
build-gen "debug" "$@"
|
||||
pushed_build
|
||||
|
||||
cpus=$(nproc)
|
||||
|
@ -191,7 +194,7 @@ function build() { ## Builds the project by regenerating the build scripts
|
|||
function build-20() { ## Builds the project using C++20 (will regenerate the build)
|
||||
rm -rf "$BUILD_DIR"
|
||||
pushed_build
|
||||
build-gen "dev" -DCPP_20_SUPPORT=ON "$@"
|
||||
build-gen "debug" -DCPP_20_SUPPORT=ON "$@"
|
||||
cmake --build .
|
||||
popd_build
|
||||
}
|
||||
|
@ -203,7 +206,7 @@ function build-tidy() { ## Builds the project using clang-tidy (It takes longer
|
|||
function build-release() { ## Builds the project in "Release" mode
|
||||
rm -rf "$BUILD_DIR"
|
||||
pushed_build
|
||||
build-gen "prod" "$@"
|
||||
build-gen "release" "$@"
|
||||
cmake --build . --config Release
|
||||
popd_build
|
||||
}
|
||||
|
@ -212,7 +215,7 @@ function build-docs() { ## Builds the documentation of Serene
|
|||
rm -rf "$BUILD_DIR"
|
||||
pip install -r "$ME/docs/requirements.txt"
|
||||
pushed_build
|
||||
build-gen "dev" -DSERENE_ENABLE_DOCS=ON "$@"
|
||||
build-gen "debug" -DSERENE_ENABLE_DOCS=ON "$@"
|
||||
cmake --build . --parallel
|
||||
popd_build
|
||||
}
|
||||
|
@ -263,7 +266,7 @@ function tests() { ## Runs all the test cases
|
|||
function build-tests() { ## Generates and build the project including the test cases
|
||||
rm -rf "$BUILD_DIR"
|
||||
pushed_build
|
||||
build-gen "dev" -DSERENE_BUILD_TESTING=ON "$@"
|
||||
build-gen "debug" -DSERENE_BUILD_TESTING=ON "$@"
|
||||
cmake --build . --parallel
|
||||
popd_build
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
# Serene Programming Language
|
||||
#
|
||||
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# This file sets up a CMakeCache to build serene for development. In this
|
||||
# cache file we assume that you are using the toolchain and musl that are
|
||||
# built by the `builder` script. For example: `builder deps build llvm`
|
||||
# You still can just build everything yourself but the builder script and
|
||||
# this file make the process easier.
|
||||
|
||||
# Where to find the packages. Packages can be built from source
|
||||
# or downloaded via the builder script.
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "")
|
||||
|
||||
set(SERENE_CCACHE_DIR "$ENV{HOME}/.ccache" CACHE STRING "")
|
||||
|
||||
set(CMAKE_BUILD_TYPE "Debug")
|
|
@ -0,0 +1,29 @@
|
|||
# Serene Programming Language
|
||||
#
|
||||
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# This file sets up a CMakeCache to build serene for development. In this
|
||||
# cache file we assume that you are using the toolchain and musl that are
|
||||
# built by the `builder` script. For example: `builder deps build llvm`
|
||||
# You still can just build everything yourself but the builder script and
|
||||
# this file make the process easier.
|
||||
|
||||
# Where to find the packages. Packages can be built from source
|
||||
# or downloaded via the builder script.
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS OFF CACHE BOOL "")
|
||||
|
||||
set(SERENE_CCACHE_DIR "$ENV{HOME}/.ccache" CACHE STRING "")
|
||||
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
|
@ -0,0 +1,49 @@
|
|||
# Serene Programming Language
|
||||
#
|
||||
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# This file sets up a CMakeCache to build serene for development. In this
|
||||
# cache file we assume that you are using the toolchain and musl that are
|
||||
# built by the `builder` script. For example: `builder deps build llvm`
|
||||
# You still can just build everything yourself but the builder script and
|
||||
# this file make the process easier.
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
||||
|
||||
set(triple x86_64-pc-linux-musl)
|
||||
|
||||
set(CMAKE_SYSROOT ${SERENE_TOOLCHAIN_PATH})
|
||||
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
|
||||
|
||||
set(CMAKE_C_COMPILER "clang")
|
||||
set(CMAKE_C_COMPILER_AR "llvm-ar")
|
||||
set(CMAKE_C_COMPILER_RANLIB "llvm-ranlib")
|
||||
|
||||
set(CMAKE_CXX_COMPILER "clang++")
|
||||
set(CMAKE_CXX_COMPILER_AR "llvm-ar")
|
||||
set(CMAKE_CXX_COMPILER_RANLIB "llvm-ranlib")
|
||||
|
||||
set(CMAKE_ASM_COMPILER "clang")
|
||||
set(CMAKE_ASM_COMPILER_AR "llvm-ar")
|
||||
set(CMAKE_ASM_COMPILER_RANLIB "llvm-ranlib")
|
||||
|
||||
set(CMAKE_C_COMPILER_TARGET ${triple})
|
||||
set(CMAKE_CXX_COMPILER_TARGET ${triple})
|
||||
set(CMAKE_ASM_COMPILER_TARGET ${triple})
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
|
@ -101,7 +101,7 @@ function http_pull() {
|
|||
pkg_name="$1"
|
||||
version="$2"
|
||||
output="$3"
|
||||
url="$DEV_HEROES/api/packages/serene/generic/$pkg_name/$version/$pkg_name.$version.zstd"
|
||||
url="$DEV_HEROES/api/packages/serene/generic/$pkg_name/$version/$pkg_name.$version.tar.zstd"
|
||||
|
||||
info "Fetching '$url'..."
|
||||
|
||||
|
|
Loading…
Reference in New Issue