Permalink
Fetching contributors…
Cannot retrieve contributors at this time
169 lines (157 sloc) 5.16 KB
require tasks/test;
require tasks/doc;
require tasks/semver;
require tasks/semver-git;
require tasks/module;
require tasks/deploy;
require tasks/expand;
# tasks we want to use/test
require tasks/archive;
require tasks/todo;
require tasks/compress;
require tasks/latex;
# task-devel(7) depends upon
# task-project(7) so it is
# automatically available
require tasks/devel;
# external build tool wrappers
# used for testing purposes
require tasks/ext/build/make;
require tasks/ext/build/rake;
require tasks/ext/build/ant;
require tasks/ext/build/mvn;
require tasks/ext/npm;
# exclude these tasks from the default test runner
# this test is used to force failure
tdd.suite.exclude! "task-test";
# this test is slow and should be run manually
tdd.suite.exclude! "jsonlint";
# exclude binary files that are not tests
tdd.suite.exclude! "profile.sh";
tdd.suite.exclude! "global.sh";
tdd.suite.exclude! "custom-install.sh";
taskinfo dist "Run autoreconf and create distribution tarball(s). Use the install sub-command to test installation in the target directory";
tasks.dist() {
local cmd="${1:-}"; shift;
local rule="dist";
if [ -z "$cmd" ]; then
rule="distcheck";
# this allows writing to target
# during the distcheck execution
# as VPATH builds create a read-only
# directory structure
export bake_root="$root";
fi
local name="${framework}";
local fullname="${name}-${project_version}";
local tarball="${fullname}.tar.gz";
local bzip2="${fullname}.tar.bz2";
local xz="${fullname}.tar.xz";
local archive="${target}/${tarball}";
executable.validate autoreconf;
autoreconf -fi;
[[ -f "${target}/${tarball}" ]] && rm "${target}/${tarball}";
[[ -f "${target}/${bzip2}" ]] && rm "${target}/${bzip2}";
[[ -f "${target}/${xz}" ]] && rm "${target}/${xz}";
./configure && make ${rule} \
&& mv "${tarball}" "${target}" \
&& mv "${bzip2}" "${target}" \
&& mv "${xz}" "${target}" \
|| console quit 1 -- "failed to create distribution(s)";
require.once util/checksum;
local algorithm="512";
local sha_name="sha${algorithm}";
(
cd "${target}" \
&& checksum.sha "${algorithm}" \
"${tarball}" >| "${tarball}.${sha_name}" \
&& checksum.sha "${algorithm}" \
"${bzip2}" >| "${bzip2}.${sha_name}" \
&& checksum.sha "${algorithm}" \
"${xz}" >| "${xz}.${sha_name}" \
|| false
) \
|| console quit 1 "could not generate checksums";
if [ -n "${cmd:-}" ]; then
local commands_namespace="dist.commands";
if ! method.exists? "${commands_namespace}.${cmd}"; then
console quit 1 -- "unknown dist sub-command %s" "${cmd}";
fi
delegate "${commands_namespace}" "${cmd}" $@;
fi
cd "${root}" && make distclean 2> /dev/null;
}
dist.commands.install() {
cd "${target}" \
&& tar -xvf "${tarball}" \
&& cd "${fullname}" \
|| console quit 1 -- "failed to extract %s and change to %s" \
"${archive}" "${target}/${fullname}";
console info -- "pwd %s" "$( pwd )";
local prefix="${target}/install";
if [ -d "${prefix}" ]; then
local opts="-rf";
$verbose && opts+="v";
rm $opts "${prefix}";
fi
mkdir -p "${prefix}";
console info -- "./configure %s" "--prefix=${prefix}";
./configure --prefix="${prefix}";
make && make install && make installcheck;
}
taskinfo jsoncc "Compile json checker source";
tasks.jsoncc() {
executable.validate gcc;
local exename="jsoncheck";
"${executables[gcc]}" etc/json-checker/*.c etc/json-checker/*.h \
-o "target/$exename" \
|| console quit 1 -- "could not compile json-checker source";
}
taskinfo boilerplate "Install the boilerplate.sh file, if it exists in PATH it is overwritten with the current version, otherwise you may select a directory from PATH";
tasks.boilerplate() {
local name="boilerplate.sh";
local source="${root}/bin/${name}";
install() {
local source="$1";
local destination="$2";
local cpopts="-f";
$verbose && cpopts+="v";
cp $cpopts "${source}" "${destination}" \
|| console quit 1 -- "could not install %s to %s" \
"${source}" "${destination}";
console success "installed %s" "${destination}";
}
local boilerplate=$( command -v "${name}" );
if [ -n "${boilerplate}" ]; then
console info -- "location is %s" "${boilerplate}";
install "${source}" "${boilerplate}";
else
console info --prefix="[${name}]" \
"choose an installation directory:";
selection.valid() {
local directory="${1:-}";
[[ ! -d "${directory}" ]] && console quit 1 -- \
"%s is not a directory" "${directory}";
install "${source}" "${directory}/${name}";
}
selection.error() {
local value="${1:-}";
console error -- "invalid selection %s" "${value:-}";
}
selection.range() {
local value="${1:-}";
console error -- "invalid selection %s, must be in the range %s-%s" \
"${value}" "1" "${#PROMPT_SELECTION[@]}";
}
local IFS=":";
local paths=( $PATH );
unset IFS;
declare -ag PROMPT_SELECTION=( "${paths[@]}" );
process_name="${name}";
console prompt --program '';
prompt select --id=selection \
--select=selection.valid \
--select-error=selection.error \
--select-range-error=selection.range;
fi
}