From 2b1bdc67f795c51811f4e305e1eb6f9d63e7f0aa Mon Sep 17 00:00:00 2001 From: "eddie.hsu" Date: Mon, 4 Sep 2023 00:20:51 +0800 Subject: [PATCH 1/4] Upgrade Makefile, it can build single html now We still need to make all once, and then we can build single html. --- Makefile | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Makefile b/Makefile index 3f9c041ab0..3c3cdc1b09 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,26 @@ all: $(VENV)/bin/sphinx-build $(VENV)/bin/blurb clone ## Automatically build an for file in *.po */*.po; do ln -f $$file $(LC_MESSAGES)/$$file; done . $(VENV)/bin/activate; $(MAKE) -C $(CPYTHON_CLONE)/Doc/ SPHINXOPTS='-j$(JOBS) -D locale_dirs=locales -D language=$(LANGUAGE) -D gettext_compact=0' $(MODE) +.PHONY: build +build/%: $(VENV)/bin/sphinx-build $(VENV)/bin/blurb clone ## Automatically build an html local version + @if [ ! -f "$*.po" ] ; then \ + echo "\x1B[1;31m""ERROR: $*.po not exist""\x1B[m"; exit 1; \ + exit 1; \ + fi + @mkdir -p $(LC_MESSAGES) + @$(eval dir=`echo $* | xargs -n1 dirname`) ## Get dir +# If the build target is in under directory +# We should make direcotry in $(LC_MESSAGES) and link the file. + @if [ $(dir) != "." ]; then \ + echo "mkdir -p $(LC_MESSAGES)/$(dir)"; \ + mkdir -p $(LC_MESSAGES)/$(dir); \ + echo "ln -f ./$*.po $(LC_MESSAGES)/$*.po"; \ + ln -f ./$*.po $(LC_MESSAGES)/$*.po; \ + fi +# Build + @echo "----" + @. $(VENV)/bin/activate; $(MAKE) -C $(CPYTHON_CLONE)/Doc/ SPHINXOPTS='-j$(JOBS) -D language=$(LANGUAGE) -D locale_dirs=locales -D gettext_compact=0' SOURCES='$*.rst' html + help: @python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) From 2eba6d7737f717a59714fc8c7d7d7e7b507d3259 Mon Sep 17 00:00:00 2001 From: "eddie.hsu" Date: Tue, 5 Sep 2023 21:59:44 +0800 Subject: [PATCH 2/4] Upgrade Makefile Remove redundant 'exit 1' --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3c3cdc1b09..a6dce1bf5a 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ all: $(VENV)/bin/sphinx-build $(VENV)/bin/blurb clone ## Automatically build an .PHONY: build build/%: $(VENV)/bin/sphinx-build $(VENV)/bin/blurb clone ## Automatically build an html local version @if [ ! -f "$*.po" ] ; then \ - echo "\x1B[1;31m""ERROR: $*.po not exist""\x1B[m"; exit 1; \ + echo "\x1B[1;31m""ERROR: $*.po not exist""\x1B[m"; \ exit 1; \ fi @mkdir -p $(LC_MESSAGES) From 1c47138427e8d9aeb17152b6d5cbf41d77cd3a2f Mon Sep 17 00:00:00 2001 From: "eddie.hsu" Date: Sun, 17 Sep 2023 23:15:35 +0800 Subject: [PATCH 3/4] Upgrade Makefile - Get argument as build target. - Check extension. - Prevent throwing error when no rule to make target. --- Makefile | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index a6dce1bf5a..a39a144147 100644 --- a/Makefile +++ b/Makefile @@ -54,24 +54,33 @@ all: $(VENV)/bin/sphinx-build $(VENV)/bin/blurb clone ## Automatically build an . $(VENV)/bin/activate; $(MAKE) -C $(CPYTHON_CLONE)/Doc/ SPHINXOPTS='-j$(JOBS) -D locale_dirs=locales -D language=$(LANGUAGE) -D gettext_compact=0' $(MODE) .PHONY: build -build/%: $(VENV)/bin/sphinx-build $(VENV)/bin/blurb clone ## Automatically build an html local version - @if [ ! -f "$*.po" ] ; then \ - echo "\x1B[1;31m""ERROR: $*.po not exist""\x1B[m"; \ +build: $(VENV)/bin/sphinx-build $(VENV)/bin/blurb clone ## Automatically build an html local version + @$(eval target=$(filter-out $@,$(MAKECMDGOALS))) + @if [ -z $(target) ]; then \ + echo "\x1B[1;31m""Please provide a file argument.""\x1B[m"; \ + exit 1; \ + fi + @if [ "$(suffix $(target))" != ".po" ]; then \ + echo "\x1B[1;31m""Incorrect file extension. Only '.po' files are allowed.""\x1B[m"; \ + exit 1; \ + fi + @if [[ ! -f "$(target)" ]] ; then \ + echo "\x1B[1;31m""ERROR: $(target) not exist.""\x1B[m"; \ exit 1; \ fi @mkdir -p $(LC_MESSAGES) - @$(eval dir=`echo $* | xargs -n1 dirname`) ## Get dir + @$(eval dir=`echo $(target) | xargs -n1 dirname`) ## Get dir # If the build target is in under directory # We should make direcotry in $(LC_MESSAGES) and link the file. @if [ $(dir) != "." ]; then \ echo "mkdir -p $(LC_MESSAGES)/$(dir)"; \ mkdir -p $(LC_MESSAGES)/$(dir); \ - echo "ln -f ./$*.po $(LC_MESSAGES)/$*.po"; \ - ln -f ./$*.po $(LC_MESSAGES)/$*.po; \ + echo "ln -f ./$(target) $(LC_MESSAGES)/$(target)"; \ + ln -f ./$(target) $(LC_MESSAGES)/$(target); \ fi # Build @echo "----" - @. $(VENV)/bin/activate; $(MAKE) -C $(CPYTHON_CLONE)/Doc/ SPHINXOPTS='-j$(JOBS) -D language=$(LANGUAGE) -D locale_dirs=locales -D gettext_compact=0' SOURCES='$*.rst' html + @. $(VENV)/bin/activate; $(MAKE) -C $(CPYTHON_CLONE)/Doc/ SPHINXOPTS='-j$(JOBS) -D language=$(LANGUAGE) -D locale_dirs=locales -D gettext_compact=0' SOURCES='$(target).rst' html help: @python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) @@ -150,3 +159,7 @@ fuzzy: ## Find fuzzy strings .PHONY: rm_cpython rm_cpython: ## Remove cloned cpython repo rm -rf $(CPYTHON_CLONE) + +# This allows us to accept extra arguments (by doing nothing when we get a job that doesn't match, rather than throwing an error) +%: + @: From 611c9e8c237744196ba5e0a7de66a9e6dd6a4bfe Mon Sep 17 00:00:00 2001 From: Josix Date: Tue, 9 Apr 2024 23:58:02 +0800 Subject: [PATCH 4/4] Update Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a39a144147..e78d3d7518 100644 --- a/Makefile +++ b/Makefile @@ -80,7 +80,7 @@ build: $(VENV)/bin/sphinx-build $(VENV)/bin/blurb clone ## Automatically build a fi # Build @echo "----" - @. $(VENV)/bin/activate; $(MAKE) -C $(CPYTHON_CLONE)/Doc/ SPHINXOPTS='-j$(JOBS) -D language=$(LANGUAGE) -D locale_dirs=locales -D gettext_compact=0' SOURCES='$(target).rst' html + @. $(VENV)/bin/activate; $(MAKE) -C $(CPYTHON_CLONE)/Doc/ SPHINXOPTS='-j$(JOBS) -D language=$(LANGUAGE) -D locale_dirs=locales -D gettext_compact=0' SOURCES='$(basename $(target)).rst' html help: @python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)