Makefile & BSDmakefile changes #7455

Merged
earl-warren merged 6 commits from Matlib/Forgejo:#7358 into forgejo 2025-04-27 12:04:36 +02:00
Contributor

This set of commits fixes multiple issues with both make scripts. It started with #7358 and digging into it I found more problems.

@Gusted commented:

I do think the place where verify-version gets called should likely be backend instead and the error should likely include extra details on how to fix the error, but that can be discussed in the PR.

I think it should be closest to where $(FORGEJO_VERSION) is used and that's part of $(LDFLAGS), so I added it where the latter is used.

When it comes to wording feel free to make suggestions.

I haven't tested docker builds.

I believe the most optimal way to do it is to create POSIX-compliant shell script where all those conditionals and variable expansion may be placed, and then that script should generate POSIX-compliant Makefile.

Testing

BSDMakefile

Should be launched from a BSD OS. You need to add -f BSDMakefile on OpenBSD.

  • make show-version-major show-version-minor
    Should display two lines with version numbers.
  • make TAGS=bindata
    Should launch the building process once.

Makefile

  • make TAGS=bindata
    Should do the same as make build.
  • make target
    Should build given target like it used to.
  • Copy everything except .git and VERSION to a separate directory.
    make TAGS=bindata
    Should fail with error “Could not determine FORGEJO_VERSION...”
  • Copy everything except .git and VERSION to a separate directory.
    make clean
    Should execute correctly.
This set of commits fixes multiple issues with both make scripts. It started with #7358 and digging into it I found more problems. @Gusted [commented](https://codeberg.org/forgejo/forgejo/issues/7358#issuecomment-3145145): > I do think the place where verify-version gets called should likely be backend instead and the error should likely include extra details on how to fix the error, but that can be discussed in the PR. I think it should be closest to where `$(FORGEJO_VERSION)` is used and that's part of `$(LDFLAGS)`, so I added it where the latter is used. When it comes to wording feel free to make suggestions. **I haven't tested docker builds.** I believe the most optimal way to do it is to create POSIX-compliant shell script where all those conditionals and variable expansion may be placed, and then that script should generate POSIX-compliant Makefile. # Testing ## BSDMakefile Should be launched from a BSD OS. You need to add `-f BSDMakefile` on OpenBSD. * `make show-version-major show-version-minor` Should display two lines with version numbers. * `make TAGS=bindata` Should launch the building process once. ## Makefile * `make TAGS=bindata` Should do the same as `make build`. * `make `*target* Should build given target like it used to. * Copy everything except *.git* and *VERSION* to a separate directory. `make TAGS=bindata` Should fail with error “Could not determine FORGEJO_VERSION...” * Copy everything except *.git* and *VERSION* to a separate directory. `make clean` Should execute correctly.
earl-warren changed title from WIP: Makefile & BSDmakefile changes to WIP: Makefile & BSDmakefile changes [skip ci] 2025-04-04 05:33:39 +02:00
Contributor

I find this a good safeguard. Regarding testing, instructions like this added to the description of the PR will be good enough:

Testing

  • step 1
  • step 2
  • etc.
I find this a good safeguard. Regarding testing, instructions like this added to the description of the PR will be good enough: ## Testing - step 1 - step 2 - etc.
Gusted left a comment
Owner

Otherwise LGTM, many thanks!

Otherwise LGTM, many thanks!
Makefile Outdated
@ -845,3 +861,3 @@
@echo "NOT NEEDED: THIS IS A NOOP AS OF Forgejo 7.0 BUT KEPT FOR BACKWARD COMPATIBILITY"
$(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ)
$(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ) | verify-version
Owner

Why an order-only-prerequisite?

Why an order-only-prerequisite?
Author
Contributor

verify-version is never satisfied (these is no file by that name, and in fact it is a .PHONY target) thus it would force compilation every time.

Try this simple Makefile:

.PHONY: verify-version
verify-version:
	@echo 'Version Verified!'
all: | verify-version
	@echo Gotta create all
	@touch all

The output is:

$ rm -f all
$ make all
Version Verified!
Gotta create all
$ make all
Version Verified!
$
...

If you remove |, then all is executed every time:

$ rm -f all
$ make all
Version Verified!
Gotta create all
$ make all
Version Verified!
Gotta create all
$
...
`verify-version` is never satisfied (these is no file by that name, and in fact it is a .PHONY target) thus it would force compilation every time. Try this simple Makefile: ```makefile .PHONY: verify-version verify-version: @echo 'Version Verified!' all: | verify-version @echo Gotta create all @touch all ``` The output is: ``` $ rm -f all $ make all Version Verified! Gotta create all $ make all Version Verified! $ ... ``` If you remove |, then *all* is executed every time: ``` $ rm -f all $ make all Version Verified! Gotta create all $ make all Version Verified! Gotta create all $ ... ```
Owner

Ah that's interesting, thank you!

Ah that's interesting, thank you!
Gusted marked this conversation as resolved
Author
Contributor
FreeBSD two targets
matlib@m-002:~/src/forgejo-git$ make show-version-major show-version-minor
12
12.0
FreeBSD no explicit target
matlib@m-002:~/src/forgejo-git$ make TAGS=bindata
Running go generate...
bindata for migration already up-to-date
bindata for options already up-to-date
bindata for public already up-to-date
bindata for templates already up-to-date
FreeBSD no VERSION
matlib@m-002:~/src/forgejo-test$ rm -rf VERSION gitea .git
matlib@m-002:~/src/forgejo-test$ make clean
rm -rf gitea dist modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go modules/public/bindata.go.hash modules/options/bindata.go.hash modules/templates/bindata.go.hash \
    integrations*.test \
    e2e*.test \
    tests/integration/gitea-integration-* \
    tests/integration/indexers-* \
    tests/mysql.ini tests/pgsql.ini man/ \
    tests/e2e/gitea-e2e-*/ \
    tests/e2e/indexers-*/ \
    tests/e2e/reports/ tests/e2e/test-artifacts/ tests/e2e/test-snapshots/
matlib@m-002:~/src/forgejo-test$ make
Running go generate...
Error: Could not determine FORGEJO_VERSION; version file VERSION not present and no suitable git tag found
gmake[1]: *** [Makefile:276: verify-version] Error 1
*** Error code 2

Stop.
make: stopped in /usr/home/matlib/src/forgejo-test

OpenBSD two targets
matlib@m-006:~/src/forgejo-git$ make -f BSDmakefile show-version-major show-version-minor
12
12.0
OpenBSD no VERSION
matlib@m-006:~/src/forgejo-test$ make -f BSDmakefile clean
rm -rf gitea dist modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go modules/public/bindata.go.hash modules/options/bindata.go.hash modules/templates/bindata.go.hash \
    integrations*.test \
    e2e*.test \
    tests/integration/gitea-integration-* \
    tests/integration/indexers-* \
    tests/mysql.ini tests/pgsql.ini man/ \
    tests/e2e/gitea-e2e-*/ \
    tests/e2e/indexers-*/ \
    tests/e2e/reports/ tests/e2e/test-artifacts/ tests/e2e/test-snapshots/
matlib@m-006:~/src/forgejo-test$ make -f BSDmakefile backend
Running go generate...
Error: Could not determine FORGEJO_VERSION; version file VERSION not present and no suitable git tag found
gmake: *** [Makefile:276: verify-version] Error 1
*** Error 2 in /home/matlib/src/forgejo-test (BSDmakefile:55 'backend': "gmake"  "--no-print-directory"  backend)
<details> <summary>FreeBSD two targets</summary> <pre> matlib@m-002:~/src/forgejo-git$ make show-version-major show-version-minor 12 12.0 </pre> </details> <details> <summary>FreeBSD no explicit target</summary> <pre> matlib@m-002:~/src/forgejo-git$ make TAGS=bindata Running go generate... bindata for migration already up-to-date bindata for options already up-to-date bindata for public already up-to-date bindata for templates already up-to-date </pre> </details> <details> <summary>FreeBSD no VERSION</summary> <pre> matlib@m-002:~/src/forgejo-test$ rm -rf VERSION gitea .git matlib@m-002:~/src/forgejo-test$ make clean rm -rf gitea dist modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go modules/public/bindata.go.hash modules/options/bindata.go.hash modules/templates/bindata.go.hash \ integrations*.test \ e2e*.test \ tests/integration/gitea-integration-* \ tests/integration/indexers-* \ tests/mysql.ini tests/pgsql.ini man/ \ tests/e2e/gitea-e2e-*/ \ tests/e2e/indexers-*/ \ tests/e2e/reports/ tests/e2e/test-artifacts/ tests/e2e/test-snapshots/ matlib@m-002:~/src/forgejo-test$ make Running go generate... Error: Could not determine FORGEJO_VERSION; version file VERSION not present and no suitable git tag found gmake[1]: *** [Makefile:276: verify-version] Error 1 *** Error code 2 Stop. make: stopped in /usr/home/matlib/src/forgejo-test </pre> </details> <details> <summary>OpenBSD two targets</summary> <pre> matlib@m-006:~/src/forgejo-git$ make -f BSDmakefile show-version-major show-version-minor 12 12.0 </pre> </details> <details> <summary>OpenBSD no VERSION</summary> <pre> matlib@m-006:~/src/forgejo-test$ make -f BSDmakefile clean rm -rf gitea dist modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go modules/public/bindata.go.hash modules/options/bindata.go.hash modules/templates/bindata.go.hash \ integrations*.test \ e2e*.test \ tests/integration/gitea-integration-* \ tests/integration/indexers-* \ tests/mysql.ini tests/pgsql.ini man/ \ tests/e2e/gitea-e2e-*/ \ tests/e2e/indexers-*/ \ tests/e2e/reports/ tests/e2e/test-artifacts/ tests/e2e/test-snapshots/ matlib@m-006:~/src/forgejo-test$ make -f BSDmakefile backend Running go generate... Error: Could not determine FORGEJO_VERSION; version file VERSION not present and no suitable git tag found gmake: *** [Makefile:276: verify-version] Error 1 *** Error 2 in /home/matlib/src/forgejo-test (BSDmakefile:55 'backend': "gmake" "--no-print-directory" backend) </pre> </details>
Matlib changed title from WIP: Makefile & BSDmakefile changes [skip ci] to Makefile & BSDmakefile changes [skip ci] 2025-04-08 01:22:47 +02:00
Makefile Outdated
@ -279,0 +273,4 @@
verify-version:
ifeq ($(FORGEJO_VERSION),)
@echo "Error: Could not determine FORGEJO_VERSION; version file $(STORED_VERSION_FILE) not present and no suitable git tag found"
@false
Owner

Alright lets try to add a extra echo here with details how it can be fixed.

@echo "In most cases this likely means you forgot to fetch git tags, you can fix this by executing `git fetch --tags`. If this is not possible and this is part of a custom build process, then you can set a specific version by writing it to $(STORED_VERSION_FILE) (This must be a semver compatible version)"
Alright lets try to add a extra echo here with details how it can be fixed. ```sh @echo "In most cases this likely means you forgot to fetch git tags, you can fix this by executing `git fetch --tags`. If this is not possible and this is part of a custom build process, then you can set a specific version by writing it to $(STORED_VERSION_FILE) (This must be a semver compatible version)" ```
Author
Contributor
matlib@m-002:~/src/forgejo-test$ make
Running go generate...
Error: Could not determine FORGEJO_VERSION; version file VERSION not present and no suitable git tag found
In most cases this likely means you forgot to fetch git tags, you can fix this by executing `git fetch --tags`. If this is not possible and this is part of a custom build process, then you can set a specific version by writing it to VERSION (This must be a semver compatible version).
gmake[1]: *** [Makefile:277: verify-version] Error 1
*** Error code 2

Stop.
make: stopped in /usr/home/matlib/src/forgejo-test
``` matlib@m-002:~/src/forgejo-test$ make Running go generate... Error: Could not determine FORGEJO_VERSION; version file VERSION not present and no suitable git tag found In most cases this likely means you forgot to fetch git tags, you can fix this by executing `git fetch --tags`. If this is not possible and this is part of a custom build process, then you can set a specific version by writing it to VERSION (This must be a semver compatible version). gmake[1]: *** [Makefile:277: verify-version] Error 1 *** Error code 2 Stop. make: stopped in /usr/home/matlib/src/forgejo-test ```
Gusted marked this conversation as resolved
Gusted approved these changes 2025-04-09 21:35:22 +02:00
Gusted left a comment
Owner

Thank you.

Thank you.
earl-warren changed title from Makefile & BSDmakefile changes [skip ci] to Makefile & BSDmakefile changes 2025-04-27 12:02:51 +02:00
earl-warren force-pushed #7358 from 01b18ce055
All checks were successful
issue-labels / release-notes (pull_request_target) Has been skipped
requirements / merge-conditions (pull_request) Successful in 3s
to a30d86b7ec
All checks were successful
issue-labels / release-notes (pull_request_target) Has been skipped
requirements / merge-conditions (pull_request) Successful in 3s
issue-labels / backporting (pull_request_target) Has been skipped
milestone / set (pull_request_target) Successful in 4s
Integration tests for the release process / release-simulation (pull_request) Successful in 6m28s
2025-04-27 12:03:23 +02:00
Compare
Sign in to join this conversation.
No reviewers
No labels
arch
riscv64
backport/v1.19
backport/v1.20
backport/v1.21/forgejo
backport/v10.0/forgejo
backport/v11.0/forgejo
backport/v12.0/forgejo
backport/v13.0/forgejo
backport/v14.0/forgejo
backport/v7.0/forgejo
backport/v8.0/forgejo
backport/v9.0/forgejo
breaking
bug
bug
confirmed
bug
duplicate
bug
needs-more-info
bug
new-report
bug
reported-upstream
code/actions
code/api
code/auth
code/auth/faidp
code/auth/farp
code/email
code/federation
code/git
code/migrations
code/packages
code/wiki
database
MySQL
database
PostgreSQL
database
SQLite
dependency-upgrade
dependency
certmagic
dependency
chart.js
dependency
Chi
dependency
Chroma
dependency
citation.js
dependency
codespell
dependency
css-loader
dependency
devcontainers
dependency
dropzone
dependency
editorconfig-checker
dependency
elasticsearch
dependency
enmime
dependency
F3
dependency
ForgeFed
dependency
garage
dependency
Git
dependency
git-backporting
dependency
Gitea
dependency
gitignore
dependency
go-ap
dependency
go-enry
dependency
go-gitlab
dependency
Go-org
dependency
go-rpmutils
dependency
go-sql-driver mysql
dependency
go-swagger
dependency
go-version
dependency
go-webauthn
dependency
gocron
dependency
Golang
dependency
goldmark
dependency
goquery
dependency
Goth
dependency
grpc-go
dependency
happy-dom
dependency
Helm
dependency
image-spec
dependency
jsonschema
dependency
KaTeX
dependency
lint
dependency
MariaDB
dependency
Mermaid
dependency
minio-go
dependency
misspell
dependency
Monaco
dependency
PDFobject
dependency
playwright
dependency
postcss
dependency
postcss-plugins
dependency
pprof
dependency
prometheus client_golang
dependency
protobuf
dependency
relative-time-element
dependency
renovate
dependency
reply
dependency
ssh
dependency
swagger-ui
dependency
tailwind
dependency
temporal-polyfill
dependency
terminal-to-html
dependency
tests-only
dependency
text-expander-element
dependency
urfave
dependency
vfsgen
dependency
vite
dependency
Woodpecker CI
dependency
x tools
dependency
XORM
Discussion
duplicate
enhancement/feature
forgejo/accessibility
forgejo/branding
forgejo/ci
forgejo/commit-graph
forgejo/documentation
forgejo/furnace cleanup
forgejo/i18n
forgejo/interop
forgejo/moderation
forgejo/privacy
forgejo/release
forgejo/scaling
forgejo/security
forgejo/ui
Gain
High
Gain
Nice to have
Gain
Undefined
Gain
Very High
good first issue
i18n/backport-stable
impact
large
impact
medium
impact
small
impact
unknown
Incompatible license
issue
closed
issue
do-not-exist-yet
issue
open
manual test
Manually tested during feature freeze
OS
FreeBSD
OS
Linux
OS
macOS
OS
Windows
problem
QA
regression
release blocker
Release Cycle
Feature Freeze
release-blocker
v7.0
release-blocker
v7.0.1
release-blocker
v7.0.2
release-blocker
v7.0.3
release-blocker
v7.0.4
release-blocker
v8.0.0
release-blocker/v9.0.0
run-all-playwright-tests
run-end-to-end-tests
test
manual
test
needed
test
needs-help
test
not-needed
test
present
untested
User research - time-tracker
valuable code
worth a release-note
User research - Accessibility
User research - Blocked
User research - Community
User research - Config (instance)
User research - Errors
User research - Filters
User research - Future backlog
User research - Git workflow
User research - Labels
User research - Moderation
User research - Needs input
User research - Notifications/Dashboard
User research - Rendering
User research - Repo creation
User research - Repo units
User research - Security
User research - Settings (in-app)
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
forgejo/forgejo!7455
No description provided.