Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/nml-problem-matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"problemMatcher": [
{
"owner": "nml",
"pattern": [
{
"regexp": "^.*nmlc (\\w+): \"(.*)\", line (\\d+): (.*)$",
"file": 2,
"line": 3,
"severity": 1,
"message": 4
}
]
}
]
}
22 changes: 22 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Release

on:
release:
types:
- published
schedule:
- cron: '0 1 * * 1' # Run every Monday at 01:00 UTC; as GitLFS isn't free, reduce the number of nightlies.
workflow_dispatch:

jobs:
release:
name: Release
uses: OpenTTD/actions/.github/workflows/rw-entry-release-baseset.yml@v5
secrets: inherit
with:
apt-packages: git
lfs: true
name: opengfx2_classic
pip-packages: nml pillow blend-modes numpy scikit-image tqdm
problem-matcher: .github/workflows/nml-problem-matcher.json
python-version: "3.13"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ previews/

# temporary files for pip
*.tmp

# outputs for CI
opengfx2_classic-*
2 changes: 1 addition & 1 deletion docs/building-opengfx2.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ These notes are for if you want to build OpenGFX2 from the source files. If you

Requires `git lfs` for large file handling. Once `git lfs` is installed then clone using `git` as normal.

Requires a system with `make`, `nmlc`, `git` and `python3` with `PIL`, `blend-modes`, `numpy`, `skimage`, `tqdm`. This has been developed using Windows Subsystem for Linux (WSL) and might have peculiarities (eg. incorrect file permissions) on a real Linux install.
Requires a system with `make`, `nmlc`, `git` and `python3` (3.11+) with `PIL`, `blend-modes`, `numpy`, `scikit-image`, `tqdm`. This has been developed using Windows Subsystem for Linux (WSL) and might have peculiarities (eg. incorrect file permissions) on a real Linux install.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not strictly true, python3 3.10 works, but there is some odd interplay with numpy which makes this good advice.


### To build
Clone the repository, navigate to the repository root directory and run `make all`. It will take a long time...
Expand Down
111 changes: 111 additions & 0 deletions findversion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/bin/sh

# This file is part of OpenTTD.
# OpenTTD 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, version 2.
# OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.


# Arguments given? Show help text.
if [ "$#" != "0" ]; then
cat <<EOF
Usage: ./findversion.sh
Finds the current revision and if the code is modified.

Output: <VERSION>\t<ISODATE>\t<MODIFIED>\t<HASH>
VERSION
a string describing what version of the code the current checkout is
based on.
This also includes the commit date, an indication of whether the checkout
was modified and which branch was checked out. This value is not
guaranteed to be sortable, but is mainly meant for identifying the
revision and user display.

If no revision identifier could be found, this is left empty.
ISODATE
the commit date of the revision this checkout is based on.
The commit date may differ from the author date.
This can be used to decide upon the age of the source.

If no timestamp could be found, this is left empty.
MODIFIED
Whether (the src directory of) this checkout is modified or not. A
value of 0 means not modified, a value of 2 means it was modified.

A value of 1 means that the modified status is unknown, because this
is not an git checkout for example.

HASH
the git revision hash

By setting the AWK environment variable, a caller can determine which
version of "awk" is used. If nothing is set, this script defaults to
"awk".
EOF
exit 1;
fi

# Allow awk to be provided by the caller.
if [ -z "$AWK" ]; then
AWK=awk
fi

# Find out some dirs
cd `dirname "$0"`
ROOT_DIR=`pwd`

# Determine if we are using a modified version
# Assume the dir is not modified
MODIFIED="0"
if [ -f "$ROOT_DIR/.ottdrev" ]; then
# We are an exported source bundle
cat $ROOT_DIR/.ottdrev
exit
elif [ -d "$ROOT_DIR/.git" ] || [ -f "$ROOT_DIR/.git" ]; then
# We are a git checkout
# Refresh the index to make sure file stat info is in sync, then look for modifications
git update-index --refresh >/dev/null
if [ -n "`git diff-index HEAD`" ]; then
MODIFIED="2"
fi
HASH=`LC_ALL=C git rev-parse --verify HEAD 2>/dev/null`
SHORTHASH=`echo ${HASH} | cut -c1-10`
ISODATE=`LC_ALL=C git show -s --pretty='format:%ci' HEAD | "$AWK" '{ gsub("-", "", $1); print $1 }'`
BRANCH="`git symbolic-ref -q HEAD 2>/dev/null | sed 's@.*/@@'`"
TAG="`git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null | sed 's@\^0$@@'`"

if [ "$MODIFIED" -eq "0" ]; then
hashprefix="-g"
elif [ "$MODIFIED" -eq "2" ]; then
hashprefix="-m"
else
hashprefix="-u"
fi

if [ -n "$TAG" ]; then
VERSION="${TAG}"
ISTAG="1"
if [ -n "`echo \"${TAG}\" | grep \"^[0-9.]*$\"`" ]; then
ISSTABLETAG="1"
else
ISSTABLETAG="0"
fi
else
VERSION="${ISODATE}-${BRANCH}${hashprefix}${SHORTHASH}"
ISTAG="0"
ISSTABLETAG="0"
fi
else
# We don't know
MODIFIED="1"
HASH=""
SHORTHASH=""
BRANCH=""
ISODATE=""
TAG=""
VERSION=""
ISTAG="0"
ISSTABLETAG="0"
fi

echo "$VERSION $ISODATE $MODIFIED $HASH $ISTAG $ISSTABLETAG"
32 changes: 31 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Always run version detection, so we always have an accurate modified
# flag
REPO_VERSIONS := $(shell AWK="$(AWK)" "./findversion.sh")
REPO_MODIFIED := $(shell echo "$(REPO_VERSIONS)" | cut -f 3 -d' ')

# Use autodetected revisions
REPO_VERSION := $(shell echo "$(REPO_VERSIONS)" | cut -f 1 -d' ')
REPO_DATE := $(shell echo "$(REPO_VERSIONS)" | cut -f 2 -d' ')
REPO_HASH := $(shell echo "$(REPO_VERSIONS)" | cut -f 4 -d' ')

# Versions
# nice user-facing version naming
NAMING_VERSION := 0.7
NAMING_VERSION := $(REPO_VERSION)
NAMING_CDN := opengfx2_classic

# Default target
.PHONY: all
Expand Down Expand Up @@ -142,4 +153,23 @@ clean_graphics:
find graphics -type d -name "__pycache__" -exec rm -rf {} +
rm -rf graphics/fonts/openttd-ttf

# Glue to work like OpenGFX Makefile
.PHONY: maintainer-clean
maintainer-clean: clean

# Glue to work like OpenGFX Makefile
.PHONY: bundle_zip
bundle_zip: baseset/OpenGFX2_Classic-$(NAMING_VERSION).zip
cp baseset/OpenGFX2_Classic-$(NAMING_VERSION).zip $(NAMING_CDN)-$(NAMING_VERSION)-all.zip

# Glue to work like OpenGFX Makefile
.PHONY: bundle_xsrc
bundle_xsrc:
mkdir -p $(NAMING_CDN)-$(NAMING_VERSION)-source
git archive --format=tar HEAD | tar xf - -C $(NAMING_CDN)-$(NAMING_VERSION)-source/
rm -rf $(NAMING_CDN)-$(NAMING_VERSION)-source/.git $(NAMING_CDN)-$(NAMING_VERSION)-source/.gitattributes $(NAMING_CDN)-$(NAMING_VERSION)-source/.gitignore $(NAMING_CDN)-$(NAMING_VERSION)-source/.github
./findversion.sh > $(NAMING_CDN)-$(NAMING_VERSION)-source/.ottdrev
tar -cf $(NAMING_CDN)-$(NAMING_VERSION)-source.tar $(NAMING_CDN)-$(NAMING_VERSION)-source
xz -ef $(NAMING_CDN)-$(NAMING_VERSION)-source.tar

FORCE: ;