Add Windows support and clean up toolchain #10
| @@ -4,8 +4,20 @@ | |||||||
| # FILE:        scripts/xtclib | # FILE:        scripts/xtclib | ||||||
| # DESCRIPTION: XTchain library | # DESCRIPTION: XTchain library | ||||||
| # DEVELOPERS:  Rafal Kupiec <belliash@codingworkshop.eu.org> | # DEVELOPERS:  Rafal Kupiec <belliash@codingworkshop.eu.org> | ||||||
|  | #              Aiken Harris <harraiken91@gmail.com> | ||||||
|  |  | ||||||
|  |  | ||||||
|  | # Prints XTChain banner | ||||||
|  | banner() | ||||||
|  | { | ||||||
|  |     local XTC_BANNER="XT Toolchain v${XTCVER} for Linux" | ||||||
|  |  | ||||||
|  |     printf "###############################################################################\n\n" | ||||||
|  |     printf "%*s\n\n" $(( (${#XTC_BANNER} + 80) / 2)) "${XTC_BANNER}" | ||||||
|  |     printf "###############################################################################\n\n\n" | ||||||
|  | } | ||||||
|  | export -f banner | ||||||
|  |  | ||||||
| # Sets the target architecture | # Sets the target architecture | ||||||
| charch() | charch() | ||||||
| { | { | ||||||
| @@ -54,51 +66,67 @@ export -f chbuild | |||||||
| # Prints help | # Prints help | ||||||
| help() | help() | ||||||
| { | { | ||||||
| 	version |     banner | ||||||
| 	echo "XTChain defines an internal list of commands:" |     echo "XTChain defines an internal list of commands:" | ||||||
| 	echo " * charch [arch]   - sets the target CPU architecture [aarch64/armv7/i686/amd64]" |     echo " * banner          - prints XTChain banner" | ||||||
| 	echo " * chbuild [type]  - sets build type [debug/release]" |     echo " * charch [arch]   - sets the target CPU architecture [aarch64/armv7/i686/amd64]" | ||||||
| 	echo " * help            - prints this message" |     echo " * chbuild [type]  - sets build type [debug/release]" | ||||||
| 	echo " * version         - prints XTChain and its components version" |     echo " * help            - prints this message" | ||||||
| 	echo " * xbuild          - builds an application with a Ninja build system" |     echo " * version         - prints XTChain and its components version" | ||||||
|  |     echo " * xbuild          - builds an application with a Ninja build system" | ||||||
| } | } | ||||||
| export -f help | export -f help | ||||||
|  |  | ||||||
| # Displays version banner | # Displays version banner | ||||||
| version() | version() | ||||||
| { | { | ||||||
|     echo "###############################################################################" |     local XTCHAIN_EXTTOOLS=false | ||||||
|     echo "#                        XT Toolchain v${XTCVER} for Linux                        #" |  | ||||||
|     echo "#               by Rafal Kupiec <belliash@codingworkshop.eu.org>              #" |     if [ ! -f ${XTCDIR}/bin/clang ] || [ "$(which clang)" != "${XTCDIR}/bin/clang" ] || [ $(echo ${XTCVER} | grep "min") ]; then | ||||||
|     echo "###############################################################################" |         XTCHAIN_EXTTOOLS=true | ||||||
|     echo |         for TOOL in {clang,clang++,cmake,lld-link,ninja}; do | ||||||
|     echo |             which ${TOOL} &> /dev/null | ||||||
|     echo "LLVM Compiler Version: $(${XTCDIR}/bin/clang --version | grep 'clang version' | cut -d' ' -f3)" |             if [ $? -ne 0 ]; then | ||||||
|     echo "LLVM Windres Utility Version: $(${XTCDIR}/bin/i686-w64-mingw32-windres -V | cut -d' ' -f6)" |                 echo "ERROR: You are using minimal version of XTChain and '${TOOL}' has been not found in your system!" | ||||||
|     echo "Mingw IDL Compiler Version: $(${XTCDIR}/bin/i686-w64-mingw32-widl -V | grep 'version' | cut -d' ' -f5)" |                 echo "ERROR: Please install all required tools." | ||||||
|     echo "Wine Message Compiler Version: $(${XTCDIR}/bin/wmc -V | grep 'version' | cut -d' ' -f5)" |                 exit 1 | ||||||
|     echo "Wine Resource Compiler Version: $(${XTCDIR}/bin/wrc --version | grep 'version' | cut -d' ' -f5)" |             fi | ||||||
|     echo |         done | ||||||
|  |     fi | ||||||
|  |  | ||||||
|  |     banner | ||||||
|  |     echo -en "\nLLVM/Clang Compiler: $(clang --version | grep 'clang version' | cut -d' ' -f3) ($(which clang))" | ||||||
|  |     echo -en "\nLLVM/LLD Linker: $(lld-link --version | cut -d' ' -f2) ($(which lld-link))" | ||||||
|  |     echo -en "\nWine IDL Compiler: $(widl -V | grep 'version' | cut -d' ' -f5) ($(which widl))" | ||||||
|  |     echo -en "\nWine Message Compiler: $(wmc -V | grep 'version' | cut -d' ' -f5) ($(which wmc))" | ||||||
|  |     echo -en "\nWine Resource Compiler: $(wrc --version | grep 'version' | cut -d' ' -f5) ($(which wrc))" | ||||||
|  |     echo -en "\nXT Resource Compiler: $(windres -V | cut -d' ' -f6) ($(which windres))" | ||||||
|  |     echo -en "\nXT SPEC Compiler: $(xtcspecc --help | grep Version | cut -d' ' -f5) ($(which xtcspecc))" | ||||||
|  |     echo -en "\nCMake Build System: $(cmake --version | grep 'cmake version' | cut -d' ' -f3) ($(which cmake))" | ||||||
|  |     echo -en "\nNinja Build System: $(ninja --version) ($(which ninja))" | ||||||
|  |     echo -en "\n\n" | ||||||
|  |  | ||||||
|     charch ${TARGET:-amd64} |     charch ${TARGET:-amd64} | ||||||
|     chbuild ${BUILD_TYPE:-DEBUG} |     chbuild ${BUILD_TYPE:-DEBUG} | ||||||
|     echo |  | ||||||
|     echo |     echo -en "\n\nFor a list of all supported commands, type 'help'" | ||||||
|  |     echo -en "\n-------------------------------------------------\n\n" | ||||||
| } | } | ||||||
| export -f version | export -f version | ||||||
|  |  | ||||||
| # Builds application (wrapper to Ninja) | # Builds application (wrapper to Ninja) | ||||||
| xbuild() | xbuild() | ||||||
| { | { | ||||||
| 	if [ ! -f build.arch ]; then |         if [ ! -f build.arch ]; then | ||||||
| 		ninja "$@" |                 ninja "$@" | ||||||
| 	else |         else | ||||||
| 		ARCH=$(cat build.arch) |                 ARCH=$(cat build.arch) | ||||||
| 		if [ x"${ARCH}" != x"${TARGET}" ]; then |                 if [ x"${ARCH}" != x"${TARGET}" ]; then | ||||||
| 			echo "Build is configured for '${ARCH}' while current target set to '${TARGET}'!" |                         echo "Build is configured for '${ARCH}' while current target set to '${TARGET}'!" | ||||||
| 			echo "Cannot continue until conflict is resolved ..." |                         echo "Cannot continue until conflict is resolved ..." | ||||||
| 			return 1 |                         return 1 | ||||||
| 		fi |                 fi | ||||||
| 		ninja "$@" |                 ninja "$@" | ||||||
| 	fi |         fi | ||||||
| } | } | ||||||
| export -f xbuild | export -f xbuild | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user