Skip to content

Commit

Permalink
Fix: Name tagged builds correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
orudge committed Feb 25, 2021
1 parent 36b8c5a commit ea5c500
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -132,24 +132,28 @@ UNIX2DOS_FLAGS ?= $(shell [ -n $(UNIX2DOS) ] && $(UNIX2DOS) -q --version 1>&2 2>
# 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' ')
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' ')

# Days of commit since 2000-01-01. REPO_DATE is in format YYYYMMDD.
REPO_DATE_YEAR := $(shell echo "${REPO_DATE}" | cut -b1-4)
REPO_DATE_MONTH := $(shell echo "${REPO_DATE}" | cut -b5-6 | sed s/^0//)
REPO_DATE_DAY := $(shell echo "${REPO_DATE}" | cut -b7-8 | sed s/^0//)
REPO_DAYS_SINCE_2000 := $(shell $(PYTHON) -c "from datetime import date; print( (date($(REPO_DATE_YEAR),$(REPO_DATE_MONTH),$(REPO_DATE_DAY))-date(2000,1,1)).days)")

REPO_TAGS ?= $(REPO_VERSION)

# The version reported to OpenTTD. Usually days since 2000 + branch offset
NEWGRF_VERSION := $(shell let x="$(REPO_DAYS_SINCE_2000) + 65536 * $(REPO_BRANCH_VERSION)"; echo "$$x")
NEWGRF_VERSION ?= $(shell let x="$(REPO_DAYS_SINCE_2000) + 65536 * $(REPO_BRANCH_VERSION)"; echo "$$x")

# The shown version is either a tag, or in the absence of a tag the revision.
REPO_VERSION_STRING ?= $(shell [ -n "$(REPO_TAGS)" ] && echo $(REPO_TAGS) || echo $(REPO_DATE)$(REPO_BRANCH_STRING) \($(NEWGRF_VERSION):$(REPO_HASH)\))

# The title consists of name and version
REPO_TITLE := $(REPO_NAME) $(REPO_VERSION)
REPO_TITLE ?= $(REPO_NAME) $(REPO_VERSION_STRING)

# Remove the @ when you want a more verbose output.
_V ?= @
Expand Down Expand Up @@ -336,8 +340,8 @@ GRFID_FLAGS ?= -m
# followed by an M, if the source repository is not a clean version.

# Common to all filenames
FILE_VERSION_STRING ?= $(shell echo "$(REPO_BRANCH_STRING)$(NEWGRF_VERSION)$(REPO_MODIFIED)")
DIR_NAME := $(shell echo $(BASE_FILENAME))
FILE_VERSION_STRING ?= $(shell [ -n "$(REPO_TAGS)" ] && echo "$(REPO_TAGS)" || echo "$(REPO_BRANCH_STRING)$(NEWGRF_VERSION)")
DIR_NAME := $(shell [ -n "$(REPO_TAGS)" ] && echo $(BASE_FILENAME)-$(FILE_VERSION_STRING) || echo $(BASE_FILENAME))
VERSIONED_FILENAME := $(BASE_FILENAME)-$(FILE_VERSION_STRING)
DIR_NAME_SRC := $(VERSIONED_FILENAME)-source

Expand Down Expand Up @@ -422,14 +426,14 @@ Makefile.fordist:
$(_V) echo '# Definitions needed for tar releases' >> $@
$(_V) echo '# This part is automatically generated' >> $@
$(_V) echo '################################################################' >> $@
$(_V) echo 'REPO_VERSION := $(REPO_VERSION)' >> $@
$(_V) echo 'REPO_REVISION := $(NEWGRF_VERSION)' >> $@
$(_V) echo 'NEWGRF_VERSION := $(NEWGRF_VERSION)' >> $@
$(_V) echo 'REPO_HASH := $(REPO_HASH)' >> $@
$(_V) echo 'REPO_VERSION_STRING := $(REPO_VERSION_STRING)' >> $@
$(_V) echo 'REPO_TITLE := $(REPO_TITLE)' >> $@
$(_V) echo 'REPO_DATE := $(REPO_DATE)' >> $@
$(_V) echo 'REPO_BRANCH := $(REPO_BRANCH)' >> $@
$(_V) echo 'REPO_MODIFIED := $(REPO_MODIFIED)' >> $@
$(_V) echo 'GIT := :' >> $@
$(_V) echo 'PYTHON := :' >> $@

Expand Down

0 comments on commit ea5c500

Please sign in to comment.