144 lines
5.2 KiB
Bash
144 lines
5.2 KiB
Bash
# shellcheck shell=bash
|
|
# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
|
|
# See LICENSE.md for license information.
|
|
# SPDX-License-Identifier: MIT
|
|
#
|
|
# DVX, the DOS desktop JoeyLib's dvx port runs in: the runtime the gates and
|
|
# joey-run boot (dvx.exe with its libraries, widgets, programs, settings and
|
|
# system files) and its SDK (the headers, sdk.mk and the host tools every DVX
|
|
# program is built with). Both are unpacked from a DVX tree's distribution:
|
|
# dist/dvx.zip is the DVX installation and dist/sdk.zip the SDK (all of it
|
|
# under DVX-SDK/). A tree whose dist/ has no sdk.zip gives its built SDK,
|
|
# bin/sdk, instead. The builds and the emulator runs use the copy in
|
|
# toolchains/opt/dvx and never touch the DVX project itself.
|
|
#
|
|
# `install.sh --dvx-dir PATH` names the DVX tree (remembered); the default is
|
|
# a dvxgui checkout beside this repository. The pin is the zips' checksums, so
|
|
# a new dvx.zip or sdk.zip there makes this component out of date, and
|
|
# `install dvx` unpacks it again.
|
|
|
|
compDescription="DVX: desktop runtime + SDK, unpacked from a DVX tree's dist/ zips (--dvx-dir)"
|
|
# Optional: it needs a DVX tree of your own, so `all` and `toolchains` leave
|
|
# it out; `install dvx` (or toolchain:dvx) asks for it.
|
|
compGroups="toolchain:dvx optional"
|
|
compRequires="host djgpp"
|
|
compHostDeps="unzip"
|
|
|
|
dvxDir="$(cat "$JOEY_STATE/dvxDir" 2>/dev/null || true)"
|
|
if [ -z "$dvxDir" ]; then
|
|
dvxDir="$(cd "$JOEY_REPO/.." && pwd)/dvxgui"
|
|
fi
|
|
dvxRuntimeZip="$dvxDir/dist/dvx.zip"
|
|
dvxSdkZip="$dvxDir/dist/sdk.zip"
|
|
# The folder sdk.zip holds the SDK in.
|
|
dvxSdkZipRoot="DVX-SDK"
|
|
# The SDK as DVX's build leaves it: used only when dist/ has no sdk.zip.
|
|
dvxSdkTree="$dvxDir/bin/sdk"
|
|
# Where the SDK goes in the install.
|
|
dvxSdk="sdk"
|
|
|
|
|
|
# dvxSdkPin -- what the SDK comes from: sdk.zip's checksum, or without it
|
|
# every file of bin/sdk with its size and time.
|
|
dvxSdkPin() {
|
|
if [ -f "$dvxSdkZip" ]; then
|
|
printf 'zip:%s\n' "$(sha256Of "$dvxSdkZip")"
|
|
elif [ -d "$dvxSdkTree" ]; then
|
|
printf 'tree:%s\n' "$(find "$dvxSdkTree" -type f -printf '%P %s %T@\n' | sort | sha1sum | cut -d' ' -f1)"
|
|
fi
|
|
}
|
|
|
|
|
|
compPin="dir:$dvxDir:dvx:$([ -f "$dvxRuntimeZip" ] && sha256Of "$dvxRuntimeZip"):sdk:$(dvxSdkPin):foldcase"
|
|
|
|
|
|
# dvxFoldCase DIR -- DOS names are case-blind, and dvx.zip has folders that
|
|
# differ only by case (system/ and SYSTEM/PACKAGES/): fold each into its
|
|
# lower-case one, all the way down, so the tree is one DVX as DOS sees it.
|
|
dvxFoldCase() {
|
|
local dir="$1"
|
|
local entry
|
|
local name
|
|
local lower
|
|
for entry in "$dir"/*/; do
|
|
[ -d "$entry" ] || continue
|
|
name="$(basename "$entry")"
|
|
lower="${name,,}"
|
|
if [ "$name" != "$lower" ] && [ -d "$dir/$lower" ]; then
|
|
cp -a "$dir/$name/." "$dir/$lower/"
|
|
rm -rf "${dir:?}/${name:?}"
|
|
fi
|
|
done
|
|
for entry in "$dir"/*/; do
|
|
if [ -d "$entry" ]; then
|
|
dvxFoldCase "${entry%/}"
|
|
fi
|
|
done
|
|
}
|
|
|
|
|
|
compInstall() {
|
|
local tmp
|
|
[ -f "$dvxRuntimeZip" ] || die "$dvxDir has no dist/dvx.zip; make DVX's distribution there, or point --dvx-dir at a DVX tree that has one"
|
|
rm -rf "$compDir"
|
|
extractArchive "$dvxRuntimeZip" "$compDir"
|
|
dvxFoldCase "$compDir"
|
|
if [ -f "$dvxSdkZip" ]; then
|
|
tmp="$(freshBuildDir "$compId")"
|
|
extractArchive "$dvxSdkZip" "$tmp"
|
|
[ -f "$tmp/$dvxSdkZipRoot/sdk.mk" ] || die "$dvxSdkZip has no $dvxSdkZipRoot/sdk.mk"
|
|
mv "$tmp/$dvxSdkZipRoot" "$compDir/$dvxSdk"
|
|
dropBuildDir "$compId"
|
|
else
|
|
[ -f "$dvxSdkTree/sdk.mk" ] || die "$dvxDir has neither dist/sdk.zip nor a built SDK (bin/sdk/sdk.mk)"
|
|
warn "$dvxDir has no dist/sdk.zip: copying its built SDK (bin/sdk) instead"
|
|
cp -a "$dvxSdkTree" "$compDir/$dvxSdk"
|
|
fi
|
|
}
|
|
|
|
|
|
compInstalled() {
|
|
[ -f "$compDir/dvx.exe" ] &&
|
|
[ -f "$compDir/system/DVX.INI" ] &&
|
|
[ -f "$compDir/$dvxSdk/sdk.mk" ] &&
|
|
[ -x "$compDir/$dvxSdk/bin/dvxhlpc" ] &&
|
|
[ -x "$compDir/$dvxSdk/bin/dvxres" ]
|
|
}
|
|
|
|
|
|
# Build a one-window DVX program with the SDK and JoeyLib's DJGPP: proves the
|
|
# SDK, its host tools and the compiler work together.
|
|
compVerify() {
|
|
local tmp
|
|
local status=1
|
|
verifyLinked "$compDir/$dvxSdk/bin" || return 1
|
|
tmp="$(mktemp -d)"
|
|
cat > "$tmp/smoke.c" <<'EOF'
|
|
#include "dvxApp.h"
|
|
#include "shellApp.h"
|
|
|
|
int32_t appMain(DxeAppContextT *ctx);
|
|
|
|
SHELL_APP_DESCRIPTOR(.name = "Smoke", .hasMainLoop = false, .multiInstance = false, .stackSize = SHELL_STACK_DEFAULT, .priority = TS_PRIORITY_NORMAL);
|
|
|
|
|
|
int32_t appMain(DxeAppContextT *ctx) {
|
|
return dvxCreateWindowCentered(ctx->shellCtx, "Smoke", 200, 100, false) != NULL ? 0 : -1;
|
|
}
|
|
EOF
|
|
printf '.topic smoke.overview\n.title Smoke\n.toc 0 Smoke\n.default\n\n.h1 Smoke\n\nA test.\n' > "$tmp/smoke.dhs"
|
|
printf 'SDK_DIR = %s\nKIND = app\nNAME = smoke\ninclude $(SDK_DIR)/sdk.mk\n' "$compDir/$dvxSdk" > "$tmp/Makefile"
|
|
if make -s -C "$tmp" DJGPP_PREFIX="$JOEY_OPT/djgpp" > "$tmp/make.log" 2>&1 && [ -s "$tmp/smoke.app" ] && [ -s "$tmp/smoke.hlp" ]; then
|
|
status=0
|
|
else
|
|
cat "$tmp/make.log" >&2
|
|
fi
|
|
rm -rf "$tmp"
|
|
return $status
|
|
}
|
|
|
|
|
|
compEnv() {
|
|
envVar DVX_ROOT "$compDir"
|
|
envVar DVX_SDK "$compDir/$dvxSdk"
|
|
}
|