From 2e28141a5b8dc5666586e3dda37ce464e73d9541 Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Thu, 7 Dec 2023 14:36:11 -0500 Subject: [PATCH] Fix some unusual build conditions, and require RGBDS 0.5.1 - RGBASM version being mid-development or undefined: Use the `__RGBDS_MAJOR/MINOR/PATCH__` constants to get the version instead of the `--version` flag - Bash not being `/bin/bash`: Use `/usr/bin/env bash` (and `set` for the flags to pass to Bash) - RGBDS 0.5.1 is requred, not 0.5.0, for `CHARLEN` and `CHARSUB` support --- .circleci/images/rgbds/Dockerfile | 2 +- Makefile | 19 +++++++++++++------ README.md | 2 +- tools/compare.sh | 4 +++- tools/rgbasm_version.asm | 18 ++++++++++++++++++ tools/stats.sh | 4 +++- 6 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 tools/rgbasm_version.asm diff --git a/.circleci/images/rgbds/Dockerfile b/.circleci/images/rgbds/Dockerfile index b0025dc3..31ad1855 100644 --- a/.circleci/images/rgbds/Dockerfile +++ b/.circleci/images/rgbds/Dockerfile @@ -8,7 +8,7 @@ RUN apt-get install -y git curl ssh tar gzip ca-certificates RUN apt-get install -y build-essential bison pkg-config libpng-dev # Retrieve rgbds -RUN git clone https://github.com/rednex/rgbds.git && \ +RUN git clone https://github.com/gbdev/rgbds.git && \ cd rgbds && \ git fetch --tags && git checkout v0.6.0 diff --git a/Makefile b/Makefile index 0e5d8d9c..efabd9b4 100644 --- a/Makefile +++ b/Makefile @@ -18,17 +18,24 @@ ASFLAGS := \ --preserve-ld # Get assembler version -ASMVER := $(shell $(ASM) --version | cut -f2 -dv) -ASMVERMAJ := $(shell echo $(ASMVER) | cut -f1 -d.) -ASMVERMIN := $(shell echo $(ASMVER) | cut -f2 -d.) +ASMVERMAJ := $(shell $(ASM) tools/rgbasm_version.asm -DMAJOR) +ASMVERMIN := $(shell $(ASM) tools/rgbasm_version.asm -DMINOR) +ASMVERPAT := $(shell $(ASM) tools/rgbasm_version.asm -DPATCH) # Abort if RGBDS version is too low and 'clean' is not the only target ifneq ($(MAKECMDGOALS), "clean") ifeq ($(shell expr \ - \( $(ASMVERMAJ) = 0 \) \&\ - \( $(ASMVERMIN) \< 5 \)\ + \(\ + \( $(ASMVERMAJ) = 0 \) \&\ + \( $(ASMVERMIN) \< 5 \)\ + \) \|\ + \(\ + \( $(ASMVERMAJ) = 0 \) \&\ + \( $(ASMVERMIN) = 5 \) \&\ + \( $(ASMVERPAT) \< 1 \)\ + \)\ ), 1) - $(error Requires RGBDS version >= 0.5.0) + $(error Requires RGBDS version >= 0.5.1) endif endif diff --git a/README.md b/README.md index 24606b30..f72da14a 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Additionally, a wiki includes a [high-level overview of the game engine](https:/ ## Usage -1. Install Python 3 and [rgbds](https://github.com/rednex/rgbds#1-installing-rgbds) (version >= 0.5.0 required); +1. Install Python 3 and [rgbds](https://github.com/gbdev/rgbds#1-installing-rgbds) (version >= 0.5.1 required); 2. `make all`. This will build both the games and their debug symbols. Once built, use [BGB](https://github.com/zladx/LADX-Disassembly/wiki/Tooling-for-reverse-engineering#bgb) to load the debug symbols into the debugger. diff --git a/tools/compare.sh b/tools/compare.sh index e43ddd8d..5755ea23 100755 --- a/tools/compare.sh +++ b/tools/compare.sh @@ -1,4 +1,4 @@ -#!/bin/bash -eu +#!/usr/bin/env bash # # Compare the given files to their reference md5 checksum. # The SUMFILE is expected to be in the `checksum` format. @@ -6,6 +6,8 @@ # Usage: # md5sum.sh SUMFILE FILE [, FILEā€¦] +set -eu + # Parse arguments if [[ "$#" -lt 2 ]]; then echo "Invalid number of arguments." diff --git a/tools/rgbasm_version.asm b/tools/rgbasm_version.asm new file mode 100644 index 00000000..9aeac69f --- /dev/null +++ b/tools/rgbasm_version.asm @@ -0,0 +1,18 @@ +IF (DEF(__RGBDS_MAJOR__) && DEF(__RGBDS_MINOR__) && DEF(__RGBDS_PATCH__)) + IF (__RGBDS_MAJOR__ > 0 || __RGBDS_MINOR__ >= 5) + ; Distinguish RGBDS >= 0.5.0 + IF (DEF(MAJOR)) + PRINT "{d:__RGBDS_MAJOR__}" + ELIF (DEF(MINOR)) + PRINT "{d:__RGBDS_MINOR__}" + ELIF (DEF(PATCH)) + PRINT "{d:__RGBDS_PATCH__}" + ENDC + ELSE + ; RGBDS < 0.5.0 did not support all of 'PRINT', 'd:', and 'ELIF' + PRINTT "0" + ENDC +ELSE + ; RGBDS < 0.3.3 had no defined version + PRINTT "0" +ENDC diff --git a/tools/stats.sh b/tools/stats.sh index 48376a16..431ae2f8 100755 --- a/tools/stats.sh +++ b/tools/stats.sh @@ -1,9 +1,11 @@ -#!/bin/bash -e +#!/usr/bin/env bash # # Output statistics about the project progression. # Usage: # tools/stats [--verbose] +set -e + VERBOSE=${1:-"disabled"} SOURCE_DIR="src/code" SYM_FILE="azle.sym"