Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: e1580c9736
Fetching contributors…

Cannot retrieve contributors at this time

executable file 104 lines (84 sloc) 2.679 kb
# FourK - Concatenative, stack based, Forth like language optimised for
# non-interactive 4KB size demoscene presentations.
# Copyright (C) 2009, 2010 Wojciech Meyer, Josef P. Bernhart
# 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, either version 3 of the License, or
# (at your option) any later version.
# 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 <http://www.gnu.org/licenses/>.
#!/bin/bash
quiet_job=
dirty_job=
verbose=
small=
in_file=
out_file=a.out
self=${0}
#bootstrap=src/bootstrap.4k
image4k=bin/image4k
fourk=bin/4k-party
ref_suffix=-ref
function usage()
{
echo "4K - an interactive tool for non-interactive 4KB presentations"
echo "Compiler front end."
echo "Idea at the Function 2009."
echo "Please use with precatious, might compress the Universe into 4k."
echo
echo "Syntax: ${0} [-q] [-o <out file name prefix> <sources>"
echo
echo "Options: "
echo " -q - quiet job control. Suppress stupid messages."
echo " -d - dirty job mode(sometimes called debug mode). Don't clean up any temporary files."
echo " -o <file name> - generate output file name, instead of ./4k"
echo
echo
}
function msg()
{
if [[ -z "${quiet_job}" ]]; then
echo "${*}"
fi
}
function fatal()
{
echo "Error: ${self}: ${1}" >&2;exit 1
}
# Standard house keeping, boring part
if [ "$#" -eq "0" ]; then
usage
exit 0
fi
while getopts "dqo:" opt; do
case ${opt} in
q) quiet_job=yes;;
d) dirty_job=yes;;
o) out_file=${OPTARG};;
*) fatal "Unrecognized option: ${opt}";;
esac
done
shift $(( ${OPTIND}-1 ))
rm -f boot.4k
##rm -f boot${ref_suffix}.4k
cat $1 >> boot.4k
##cat $1 >> boot${ref_suffix}.4k
echo "save-image boot.4ki" >> boot.4k
##echo "save-image boot${ref_suffix}.4ki" >> boot${ref_suffix}.4k
${fourk} < boot.4k
##${fourk}${ref_suffix} < boot${ref_suffix}.4k
cp ${fourk} temp
##${image4k} -link boot.4ki boot${ref_suffix}.4ki temp
${image4k} -link boot.4ki temp
cp temp ${out_file}
${image4k} -strip temp
# Compress it
cp unpack.header ${out_file}
lzma -c9 temp >> ${out_file}
chmod +x ${out_file}
msg $(ls -l temp | awk '{ print "Un-compressed size: " $5}')
msg $(ls -l ${out_file} | awk '{ print "Compressed size: " $5}')
Jump to Line
Something went wrong with that request. Please try again.