2018-12-02 12:41:25 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# Make sure the current directory is the location of this script to simplify matters
|
|
|
|
cd "$(dirname $(readlink -f $0))";
|
|
|
|
################
|
|
|
|
### Settings ###
|
|
|
|
################
|
|
|
|
|
|
|
|
# The name of this project
|
|
|
|
project_name="RhinoReminds";
|
|
|
|
|
|
|
|
# The path to the lantern build engine git submodule
|
|
|
|
lantern_path="./lantern-build-engine";
|
|
|
|
|
|
|
|
###
|
|
|
|
# Custom Settings
|
|
|
|
###
|
|
|
|
|
|
|
|
# Put any custom settings here.
|
|
|
|
build_output_folder="./dist";
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
# Check out the lantern git submodule if needed
|
2019-02-08 00:40:04 +00:00
|
|
|
if [ ! -f "${lantern_path}/lantern.sh" ]; then
|
2019-02-08 00:38:50 +00:00
|
|
|
echo "Checking out lantern";
|
|
|
|
git submodule update --init "${lantern_path}";
|
|
|
|
fi
|
2018-12-02 12:41:25 +00:00
|
|
|
|
|
|
|
source "${lantern_path}/lantern.sh";
|
|
|
|
|
|
|
|
if [[ "$#" -lt 1 ]]; then
|
|
|
|
echo -e "${FBLE}${project_name}${RS} build script";
|
|
|
|
echo -e " by Starbeamrainbowlabs";
|
|
|
|
echo -e "${LC}Powered by the lantern build engine, v${version}${RS}";
|
|
|
|
echo -e "";
|
|
|
|
echo -e "${CSECTION}Usage${RS}";
|
|
|
|
echo -e " ./build ${CTOKEN}{action}${RS} ${CTOKEN}{action}${RS} ${CTOKEN}{action}${RS} ...";
|
|
|
|
echo -e "";
|
|
|
|
echo -e "${CSECTION}Available actions${RS}";
|
2019-02-12 19:43:40 +00:00
|
|
|
echo -e " ${CACTION}setup${RS} - Perform initial setup";
|
|
|
|
echo -e " ${CACTION}build${RS} - Restore nuget packages & compile project";
|
|
|
|
echo -e " ${CACTION}ci${RS} - Perform CI tasks";
|
2019-02-17 23:35:06 +00:00
|
|
|
echo -e " ${CACTION}package${RS} - Pack latest build for package managers";
|
2019-02-12 19:43:40 +00:00
|
|
|
echo -e " ${CACTION}archive${RS} - Construct binary archives";
|
2018-12-02 12:41:25 +00:00
|
|
|
echo -e "";
|
|
|
|
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
function task_setup {
|
|
|
|
task_begin "Checking environment";
|
|
|
|
|
|
|
|
check_command git true;
|
2019-02-08 00:27:49 +00:00
|
|
|
check_command mono true;
|
2018-12-02 12:41:25 +00:00
|
|
|
check_command msbuild true;
|
|
|
|
check_command nuget true;
|
2019-02-12 20:22:28 +00:00
|
|
|
check_command mktemp true;
|
2018-12-02 12:41:25 +00:00
|
|
|
|
|
|
|
task_end 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function task_build {
|
|
|
|
task_begin "Restoring nuget packages";
|
|
|
|
nuget restore;
|
|
|
|
task_end $?;
|
|
|
|
|
|
|
|
task_begin "Building";
|
2019-02-12 20:22:28 +00:00
|
|
|
debug_logfile="$(mktemp --suffix ".rhinoreminds.debug.log")";
|
|
|
|
release_logfile="$(mktemp --suffix ".rhinoreminds.release.log")";
|
|
|
|
(
|
|
|
|
execute msbuild /consoleloggerparameters:ForceConsoleColor >"${debug_logfile}" 2>&1
|
|
|
|
release_exit_code=$!;
|
|
|
|
) &
|
|
|
|
(
|
|
|
|
execute msbuild /consoleloggerparameters:ForceConsoleColor /p:Configuration=Release >"${release_logfile}" 2>&1
|
|
|
|
debug_exit_code=$!;
|
|
|
|
) &
|
|
|
|
|
|
|
|
wait
|
|
|
|
|
|
|
|
# FUTURE: Grab the
|
|
|
|
stage_begin "Debug compilation output";
|
|
|
|
cat "${debug_logfile}";
|
|
|
|
stage_end "${release_exit_code}";
|
|
|
|
|
|
|
|
stage_begin "Release compilation output";
|
|
|
|
cat "${release_logfile}";
|
|
|
|
stage_end "${debug_exit_code}";
|
|
|
|
|
|
|
|
echo "";
|
|
|
|
|
|
|
|
rm "${debug_logfile}" "${release_logfile}";
|
|
|
|
|
|
|
|
|
2018-12-02 12:41:25 +00:00
|
|
|
task_end $?;
|
|
|
|
}
|
|
|
|
|
2019-02-12 19:43:40 +00:00
|
|
|
function task_archive {
|
|
|
|
task_begin "Deleting extra files";
|
2019-02-12 19:59:57 +00:00
|
|
|
execute find RhinoReminds/bin -iname "*.xml" -delete;
|
2019-02-12 19:43:40 +00:00
|
|
|
task_end $?;
|
|
|
|
|
|
|
|
task_begin "Setting permissions";
|
2019-02-12 20:01:15 +00:00
|
|
|
find RhinoReminds/bin -type f -print0 | xargs -0 -P4 chmod -c -x;
|
|
|
|
find RhinoReminds/bin -type f -iname "*.exe" -print0 | xargs -0 -P4 chmod -c +x;
|
2019-02-12 19:43:40 +00:00
|
|
|
task_end $?;
|
|
|
|
|
|
|
|
task_begin "Creating Archives";
|
2019-02-12 19:59:57 +00:00
|
|
|
execute cp -ral RhinoReminds/bin/Debug RhinoReminds-Debug;
|
|
|
|
execute cp -ral RhinoReminds/bin/Release RhinoReminds-Release;
|
|
|
|
execute cp -al README.md RhinoReminds-Debug/README.md;
|
|
|
|
execute cp -al README.md RhinoReminds-Release/README.md;
|
2019-02-12 19:43:40 +00:00
|
|
|
|
2019-02-12 19:59:57 +00:00
|
|
|
execute tar -caf RhinoReminds-Debug.tar.gz RhinoReminds-Debug;
|
|
|
|
execute tar -caf RhinoReminds-Release.tar.gz RhinoReminds-Release;
|
2019-02-12 19:43:40 +00:00
|
|
|
|
2019-02-12 19:59:57 +00:00
|
|
|
execute rm -r RhinoReminds-{Debug,Release};
|
2019-02-12 19:43:40 +00:00
|
|
|
task_end $?;
|
|
|
|
|
|
|
|
if [ "${ARCHIVE}" != "" ]; then
|
|
|
|
task_begin "CI environment detected - moving archives to specified CI archive directory";
|
|
|
|
|
2019-02-12 19:59:57 +00:00
|
|
|
execute mv RhinoReminds-{Debug,Release}.tar.gz "${ARCHIVE}";
|
2019-02-12 19:43:40 +00:00
|
|
|
|
|
|
|
task_end $?;
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-02-17 23:35:06 +00:00
|
|
|
function task_package {
|
|
|
|
task_begin "Preparing for packaging";
|
|
|
|
check_command fpm true;
|
|
|
|
|
|
|
|
package_dir="$(mktemp -d --suffix "-rhinoreminds-ci-fpm-package")";
|
|
|
|
|
|
|
|
echo "Error: Not implemented yet :-/";
|
|
|
|
exit 1;
|
|
|
|
|
|
|
|
task_end $?;
|
|
|
|
}
|
|
|
|
|
2018-12-02 12:41:25 +00:00
|
|
|
function task_ci {
|
|
|
|
tasks_run setup;
|
|
|
|
|
|
|
|
task_begin "Environment Information";
|
|
|
|
execute uname -a;
|
2019-02-08 00:27:49 +00:00
|
|
|
execute git --version;
|
|
|
|
execute mono --version;
|
2018-12-02 12:41:25 +00:00
|
|
|
execute nuget help | head -n1;
|
|
|
|
task_end 0;
|
|
|
|
|
2019-02-12 19:44:37 +00:00
|
|
|
tasks_run build archive;
|
2018-12-02 12:41:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
tasks_run $@;
|