joeybuild/helpers/GCC.helper
2023-01-12 21:31:03 -06:00

111 lines
2.5 KiB
Bash

#!/bin/bash
#
# JoeyBuild
# Copyright (C) 2018-2023 Scott Duensing <scott@kangaroopunch.com>
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would be
# appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
#
function assembleGCC() {
local ARCH=$1
local PASS=$2
local LOG=$3
local AFILES=(${*:4})
local OFILES=""
local FILE=
local O=
# Assemble ASM files and generate object list.
for FILE in "${AFILES[@]}"; do
O=${G_TEMP}/${FILE%.*}
OFILES="${OFILES} ${O}"
# as
#gcc -static -nostdlib -nostartfiles ${FILE} -o ${O}
done
echo ${OFILES}
}
function compileGCC() {
local ARCH=$1
local PASS=$2
local LOG=$3
local CFILES=(${*:4})
local OFILES=""
local FILE=
local O=
rm -rf "${G_TEMP}" || true
mkdir -p "${G_TEMP}"
# Compile C files and generate object list.
for FILE in "${CFILES[@]}"; do
O=${G_TEMP}/$(basename ${FILE%.*}).o
OFILES="${OFILES} ${O}"
${CC} ${CFLAGS} -c ${FILE} -o ${O}
done
echo ${OFILES}
}
function linkGCC() {
local OS=$1
local ARCH=$2
local PASS=$3
local EXT=$4
local LOG=$5
local OFILES=(${*:6})
local LIB="${G_EHOME}/dist/${OS}-${ARCH}/${PASS}"
local DIR=${G_BUILD_RESULTS}/${OS}-${ARCH}/${PASS}
mkdir -p ${DIR}
${LD} ${CFLAGS} -o ${DIR}/${G_BUILD_PROJECT}${EXT} ${OFILES[@]} ${LIB}/libjoeylib.a ${LDFLAGS}
}
function packageGCC() {
local OS=$1
local ARCH=$2
local PASS=$3
local LOG=$4
local DFILES=(${*:5})
local DIR=${G_BUILD_RESULTS}/${OS}-${ARCH}/${PASS}/data
local FILE=
local O=
local EXTENSION=
#***TODO*** Maybe copy source code for everything to the disk in DEBUG so there are symbols to view?
mkdir -p ${DIR}
# Copy game data.
for FILE in "${DFILES[@]}"; do
# Data conversion.
EXTENSION="${FILE##*.}"
case ${EXTENSION,,} in
*)
O=${DIR}/$(basename ${FILE})
cp -f ${FILE} ${O}
;;
esac
done
}