-
Notifications
You must be signed in to change notification settings - Fork 79
Enhance Makefile with improved portability and dependency handling #500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,15 @@ UUID = "forge@jmmaranan.com" | |||||||||||||||||||||||||||||
| INSTALL_PATH = $(HOME)/.local/share/gnome-shell/extensions/$(UUID) | ||||||||||||||||||||||||||||||
| MSGSRC = $(wildcard po/*.po) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| .PHONY: all clean install schemas uninstall enable disable log debug patchcss | ||||||||||||||||||||||||||||||
| # Shell configuration - use POSIX /bin/sh for better portability | ||||||||||||||||||||||||||||||
| SHELL := /bin/sh | ||||||||||||||||||||||||||||||
| .SHELLFLAGS := -ec | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # Tool detection (using POSIX redirection) | ||||||||||||||||||||||||||||||
| HAS_XGETTEXT := $(shell command -v xgettext >/dev/null 2>&1 && echo yes || echo no) | ||||||||||||||||||||||||||||||
| HAS_MSGFMT := $(shell command -v msgfmt >/dev/null 2>&1 && echo yes || echo no) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| .PHONY: all clean install schemas uninstall enable disable log debug patchcss check-deps | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| all: build install enable restart | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -19,12 +27,25 @@ schemas/gschemas.compiled: schemas/*.gschema.xml | |||||||||||||||||||||||||||||
| patchcss: | ||||||||||||||||||||||||||||||
| # TODO: add the script to update css tag when delivering theme.js | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| metadata: | ||||||||||||||||||||||||||||||
| echo "export const developers = Object.entries([" > lib/prefs/metadata.js | ||||||||||||||||||||||||||||||
| git shortlog -sne || echo "" >> lib/prefs/metadata.js | ||||||||||||||||||||||||||||||
| awk -i inplace '!/dependabot|noreply/' lib/prefs/metadata.js | ||||||||||||||||||||||||||||||
| sed -i 's/^[[:space:]]*[0-9]*[[:space:]]*\(.*\) <\(.*\)>/ {name:"\1", email:"\2"},/g' lib/prefs/metadata.js | ||||||||||||||||||||||||||||||
| echo "].reduce((acc, x) => ({ ...acc, [x.email]: acc[x.email] ?? x.name }), {})).map(([email, name]) => name + ' <' + email + '>')" >> lib/prefs/metadata.js | ||||||||||||||||||||||||||||||
| @echo "Generating developer metadata..." | ||||||||||||||||||||||||||||||
| @echo "export const developers = [" > lib/prefs/metadata.js | ||||||||||||||||||||||||||||||
| @git shortlog -sne --all \ | ||||||||||||||||||||||||||||||
| | (grep -vE 'dependabot|noreply' || true) \ | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| | (grep -vE 'dependabot|noreply' || true) \ | |
| | (grep -v 'dependabot' | grep -v 'noreply' || true) \ |
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The awk script will generate a trailing comma after the last developer entry. JavaScript arrays are generally tolerant of trailing commas in modern environments, but this could potentially cause issues with older parsers. Consider using awk's END block or tracking whether it's the first entry to avoid the trailing comma, or verify that all target environments support trailing commas in arrays.
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build target depends on 'compilemsgs', but when HAS_MSGFMT is 'no', the compilemsgs target only prints a warning and doesn't create any .mo files. This means the build will succeed even without translations, but the for loop at lines 62-70 may try to copy non-existent .mo files. While the if check at line 63 handles this gracefully, the build target's dependency on compilemsgs suggests translations are required. Consider whether the build should fail if required translation tools are missing, or if the current graceful degradation is intentional.
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When xgettext is not available, the target creates an empty forge.pot file with 'touch'. This could cause issues with msgmerge in the compilemsgs target (line 98) which expects a valid POT file format. If HAS_XGETTEXT is 'no' but HAS_MSGFMT is 'yes', msgmerge will fail when trying to merge with an empty POT file. Consider creating a minimal valid POT file header or ensuring compilemsgs also checks for xgettext availability.
| @touch ./po/forge.pot | |
| @printf '%s\n' \ | |
| '# SOME DESCRIPTIVE TITLE.' \ | |
| '# Copyright (C) YEAR THE PACKAGE'\''S COPYRIGHT HOLDER' \ | |
| '# This file is distributed under the same license as the Forge package.' \ | |
| '# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.' \ | |
| '#' \ | |
| 'msgid ""' \ | |
| 'msgstr ""' \ | |
| '"Project-Id-Version: Forge\\n"' \ | |
| '"MIME-Version: 1.0\\n"' \ | |
| '"Content-Type: text/plain; charset=UTF-8\\n"' \ | |
| '"Content-Transfer-Encoding: 8bit\\n"' \ | |
| > ./po/forge.pot |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The clean target now attempts to remove "$(UUID).zip" without checking if it exists first. While the -f flag prevents errors if the file doesn't exist, combining multiple rm operations on one line means if the first file removal has any unexpected issues, the entire command could fail. The old version had explicit error handling with || echo "Nothing to delete". Consider whether silent failure with -f is the desired behavior or if explicit feedback is preferred.
| rm -f lib/prefs/metadata.js "$(UUID).zip" | |
| @if [ -e "lib/prefs/metadata.js" ]; then rm -f "lib/prefs/metadata.js"; else echo "lib/prefs/metadata.js: Nothing to delete"; fi | |
| @if [ -e "$(UUID).zip" ]; then rm -f "$(UUID).zip"; else echo "$(UUID).zip: Nothing to delete"; fi |
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The enable target now provides helpful user feedback, which is good. However, the logic assumes that if the extension is in the list, it can be enabled. There could be a case where the extension is listed but enabling fails for other reasons. Consider checking the exit status of the enable command separately from the list check, or handling the case where 'gnome-extensions enable' fails even when the extension is listed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting .SHELLFLAGS to '-ec' means that any command failure will cause the shell script to exit immediately, and undefined variables won't be caught. The '-e' flag is good for catching errors, but consider if '-u' should also be added to catch undefined variable usage, or if this would break existing recipes. This is a behavior change that could affect error handling throughout the Makefile.