| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- #!/usr/bin/env bash
- # -----------------------------------------------------------------------------
- # This file is part of the xPacks distribution.
- # (https://xpack.github.io)
- # Copyright (c) 2019 Liviu Ionescu.
- #
- # Permission to use, copy, modify, and/or distribute this software
- # for any purpose is hereby granted, under the terms of the MIT license.
- # -----------------------------------------------------------------------------
- # -----------------------------------------------------------------------------
- # Safety settings (see https://gist.github.com/ilg-ul/383869cbb01f61a51c4d).
- if [[ ! -z ${DEBUG} ]]
- then
- set ${DEBUG} # Activate the expand mode if DEBUG is anything but empty.
- else
- DEBUG=""
- fi
- set -o errexit # Exit if command failed.
- set -o pipefail # Exit if pipe failed.
- set -o nounset # Exit if variable not set.
- # Remove the initial space and instead use '\n'.
- IFS=$'\n\t'
- # -----------------------------------------------------------------------------
- # Identify the script location, to reach, for example, the helper scripts.
- build_script_path="$0"
- if [[ "${build_script_path}" != /* ]]
- then
- # Make relative path absolute.
- build_script_path="$(pwd)/$0"
- fi
- script_folder_path="$(dirname "${build_script_path}")"
- script_folder_name="$(basename "${script_folder_path}")"
- # =============================================================================
- # Script to build the xPack GNU RISC-V Embeded GCC distribution packages.
- #
- # Developed on macOS 10.13 High Sierra, but intended to run on
- # macOS 10.10 Yosemite and CentOS 6 XBB.
- # -----------------------------------------------------------------------------
- echo
- echo "xPack GNU RISC-V Embedded GCC distribution build script."
- host_functions_script_path="${script_folder_path}/helper/host-functions-source.sh"
- source "${host_functions_script_path}"
- common_functions_script_path="${script_folder_path}/common-functions-source.sh"
- source "${common_functions_script_path}"
- defines_script_path="${script_folder_path}/defs-source.sh"
- source "${defines_script_path}"
- host_detect
- # For clarity, explicitly define the docker images here.
- docker_linux64_image=${docker_linux64_image:-"ilegeul/ubuntu:amd64-12.04-xbb-v3.2"}
- docker_linux32_image=${docker_linux32_image:-"ilegeul/ubuntu:i386-12.04-xbb-v3.2"}
- docker_linux_arm64_image=${docker_linux_arm64_image:-"ilegeul/ubuntu:arm64v8-16.04-xbb-v3.2"}
- docker_linux_arm32_image=${docker_linux_arm32_image:-"ilegeul/ubuntu:arm32v7-16.04-xbb-v3.2"}
- # -----------------------------------------------------------------------------
- # Array where the remaining args will be stored.
- declare -a rest
- help_message=" bash $0 [--win32] [--win64] [--linux32] [--linux64] [--arm32] [--arm64] [--osx] [--all] [clean|cleanlibs|cleanall|preload-images] [--env-file file] [--disable-strip] [--without-pdf] [--with-html] [--disable-multilib] [--develop] [--debug] [--use-gits] [--jobs N] [--help]"
- host_options "${help_message}" "$@"
- # Intentionally moved after option parsing.
- echo
- echo "Host helper functions source script: \"${host_functions_script_path}\"."
- echo "Common functions source script: \"${common_functions_script_path}\"."
- echo "Definitions source script: \"${defines_script_path}\"."
- host_common
- # -----------------------------------------------------------------------------
- if [ -n "${DO_BUILD_WIN32}${DO_BUILD_WIN64}${DO_BUILD_LINUX32}${DO_BUILD_LINUX64}" ]
- then
- host_prepare_docker
- fi
- # ----- Build the native distribution. ----------------------------------------
- if [ -z "${DO_BUILD_OSX}${DO_BUILD_LINUX64}${DO_BUILD_LINUX_ARM64}${DO_BUILD_WIN64}${DO_BUILD_LINUX32}${DO_BUILD_LINUX_ARM32}${DO_BUILD_WIN32}" ]
- then
- host_build_target "Creating the native distribution..." \
- --script "${HOST_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
- --env-file "${ENV_FILE}" \
- -- \
- ${rest[@]-}
- else
- # ----- Build the OS X distribution. ----------------------------------------
- if [ "${DO_BUILD_OSX}" == "y" ]
- then
- if [ "${HOST_UNAME}" == "Darwin" ]
- then
- host_build_target "Creating the OS X distribution..." \
- --script "${HOST_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
- --env-file "${ENV_FILE}" \
- --target-platform "darwin" \
- -- \
- ${rest[@]-}
- else
- echo "Building the macOS image is not possible on this platform."
- exit 1
- fi
- fi
- # ----- Build the GNU/Linux 64-bit distribution. ---------------------------
- if [ "${DO_BUILD_LINUX64}" == "y" ]
- then
- host_build_target "Creating the GNU/Linux 64-bit distribution..." \
- --script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
- --env-file "${ENV_FILE}" \
- --target-platform "linux" \
- --target-arch "x64" \
- --target-bits 64 \
- --docker-image "${docker_linux64_image}" \
- -- \
- ${rest[@]-}
- fi
- # ----- Build the Windows 64-bit distribution. -----------------------------
- if [ "${DO_BUILD_WIN64}" == "y" ]
- then
- linux_install_relative_path="linux-x64/install/${APP_LC_NAME}"
- if [ ! -f "${HOST_WORK_FOLDER_PATH}/${linux_install_relative_path}/bin/${GCC_TARGET}-gcc" ]
- then
- host_build_target "Creating the GNU/Linux 64-bit distribution..." \
- --script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
- --env-file "${ENV_FILE}" \
- --target-platform "linux" \
- --target-arch "x64" \
- --target-bits 64 \
- --docker-image "${docker_linux64_image}" \
- -- \
- ${rest[@]-}
- fi
- if [ ! -f "${HOST_WORK_FOLDER_PATH}/${linux_install_relative_path}/bin/${GCC_TARGET}-gcc" ]
- then
- echo "Mandatory GNU/Linux binaries missing."
- exit 1
- fi
- host_build_target "Creating the Windows 64-bit distribution..." \
- --script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
- --env-file "${ENV_FILE}" \
- --target-platform "win32" \
- --target-arch "x64" \
- --target-bits 64 \
- --docker-image "${docker_linux64_image}" \
- -- \
- --linux-install-path "${linux_install_relative_path}" \
- ${rest[@]-}
- fi
- # ----- Build the GNU/Linux 32-bit distribution. ---------------------------
- if [ "${DO_BUILD_LINUX32}" == "y" ]
- then
- host_build_target "Creating the GNU/Linux 32-bit distribution..." \
- --script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
- --env-file "${ENV_FILE}" \
- --target-platform "linux" \
- --target-arch "x32" \
- --target-bits 32 \
- --docker-image "${docker_linux32_image}" \
- -- \
- ${rest[@]-}
- fi
- # ----- Build the Windows 32-bit distribution. -----------------------------
- # Since the actual container is a 32-bit, use the debian32 binaries.
- if [ "${DO_BUILD_WIN32}" == "y" ]
- then
- linux_install_relative_path="linux-x32/install/${APP_LC_NAME}"
- if [ ! -f "${HOST_WORK_FOLDER_PATH}/${linux_install_relative_path}/bin/${GCC_TARGET}-gcc" ]
- then
- host_build_target "Creating the GNU/Linux 32-bit distribution..." \
- --script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
- --env-file "${ENV_FILE}" \
- --target-platform "linux" \
- --target-arch "x32" \
- --target-bits 32 \
- --docker-image "${docker_linux32_image}" \
- -- \
- ${rest[@]-}
- fi
- if [ ! -f "${HOST_WORK_FOLDER_PATH}/${linux_install_relative_path}/bin/${GCC_TARGET}-gcc" ]
- then
- echo "Mandatory GNU/Linux binaries missing."
- exit 1
- fi
- host_build_target "Creating the Windows 32-bit distribution..." \
- --script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
- --env-file "${ENV_FILE}" \
- --target-platform "win32" \
- --target-arch "x32" \
- --target-bits 32 \
- --docker-image "${docker_linux32_image}" \
- -- \
- --linux-install-path "${linux_install_relative_path}" \
- ${rest[@]-}
- fi
- # ----- Build the GNU/Linux Arm 64-bit distribution. ---------------------------
- if [ "${DO_BUILD_LINUX_ARM64}" == "y" ]
- then
- host_build_target "Creating the GNU/Linux Arm 64-bit distribution..." \
- --script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
- --env-file "${ENV_FILE}" \
- --target-platform "linux" \
- --target-arch "arm64" \
- --target-bits 64 \
- --docker-image "${docker_linux_arm64_image}" \
- -- \
- ${rest[@]-}
- fi
- # ----- Build the GNU/Linux Arm 32-bit distribution. ---------------------------
- if [ "${DO_BUILD_LINUX_ARM32}" == "y" ]
- then
- host_build_target "Creating the GNU/Linux Arm 32-bit distribution..." \
- --script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
- --env-file "${ENV_FILE}" \
- --target-platform "linux" \
- --target-arch "arm" \
- --target-bits 32 \
- --docker-image "${docker_linux_arm32_image}" \
- -- \
- ${rest[@]-}
- fi
- fi
- host_show_sha
- # -----------------------------------------------------------------------------
- host_stop_timer
- host_notify_completed
- # Completed successfully.
- exit 0
- # -----------------------------------------------------------------------------
|