#! /bin/bash # Toolchain builder for the Serene programming language # # Copyright (c) 2019-2023 Sameer Rahmani # # 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 . # ----------------------------------------------------------------------------- # Commentary # ----------------------------------------------------------------------------- # This is the builder script for the Serene project. It makes it easier to # interact with the CMake build scripts. # # In order to define a subcommand all you need to do is to define a function # with the following syntax: # # function subcommand-name() { ## DESCRIPTION # .. subcommand body .. # } # # Make sure to provid one line of DESCRIPTION for the subcommand and use two "#" # characters to start the description following by a space. Otherwise, your # subcommand won't be registered # set -e command=$1 VERSION="0.9.0" ME=$(cd "$(dirname "$0")/." >/dev/null 2>&1 ; pwd -P) # shellcheck source=./scripts/utils.sh source "$ME/scripts/utils.sh" user="serene" channel="stable" function _conan() { PYTHONPATH="$ME:$PYTHONPATH" conan "$@" } function _create() { _conan create --user "$user" --channel "$channel" \ --profile:host="../../profiles/stage$1" \ . "${@:2}" } function llvm-source() { ## Build the llvm source pkg _push "packages/sources/llvm/" _create "$@" _pop } function cmake() { ## Build the cmake package _push "packages/cmake/" _create "$@" _pop } function gcc() { ## Build the gcc package _push "packages/gcc/" _create "$@" _pop } function help() { ## Print out this help message echo "Commands:" grep -E '^function [a-zA-Z0-9_-]+\(\) \{ ## .*$$' "$0" | \ sort | \ sed 's/^function \([a-zA-Z0-9_-]*\)() { ## \(.*\)/\1:\2/' | \ awk 'BEGIN {FS=":"}; {printf "\033[36m%-30s\033[0m %s\n", $1, $2}' } # ----------------------------------------------------------------------------- # Main logic # ----------------------------------------------------------------------------- echo -e "\nSerene Builder Version $VERSION" echo -e "\nCopyright (C) 2019-2023" echo -e "Sameer Rahmani " echo -e "Serene comes with ABSOLUTELY NO WARRANTY;" echo -e "This is free software, and you are welcome" echo -e "to redistribute it under certain conditions;" echo -e "for details take a look at the LICENSE file.\n" # Find the subcommand in the functions and run we find it. for fn in $(fn-names); do if [[ $fn == "$command" ]]; then eval "$fn ${*:2}" exit $? fi done # If we couldn't find the command print out the help message help