Skip to content

Commit 56d000b

Browse files
authored
Merge pull request #643 from griiid/feature/upgrade-makefile
Upgrade Makefile, it can build single html now
2 parents c9ce39d + 5443800 commit 56d000b

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

Makefile

+33
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,35 @@ all: $(VENV)/bin/sphinx-build $(VENV)/bin/blurb clone ## Automatically build an
5353
for file in *.po */*.po; do ln -f $$file $(LC_MESSAGES)/$$file; done
5454
. $(VENV)/bin/activate; $(MAKE) -C $(CPYTHON_CLONE)/Doc/ SPHINXOPTS='-j$(JOBS) -D locale_dirs=locales -D language=$(LANGUAGE) -D gettext_compact=0' $(MODE)
5555

56+
.PHONY: build
57+
build: $(VENV)/bin/sphinx-build $(VENV)/bin/blurb clone ## Automatically build an html local version
58+
@$(eval target=$(filter-out $@,$(MAKECMDGOALS)))
59+
@if [ -z $(target) ]; then \
60+
echo "\x1B[1;31m""Please provide a file argument.""\x1B[m"; \
61+
exit 1; \
62+
fi
63+
@if [ "$(suffix $(target))" != ".po" ]; then \
64+
echo "\x1B[1;31m""Incorrect file extension. Only '.po' files are allowed.""\x1B[m"; \
65+
exit 1; \
66+
fi
67+
@if [[ ! -f "$(target)" ]] ; then \
68+
echo "\x1B[1;31m""ERROR: $(target) not exist.""\x1B[m"; \
69+
exit 1; \
70+
fi
71+
@mkdir -p $(LC_MESSAGES)
72+
@$(eval dir=`echo $(target) | xargs -n1 dirname`) ## Get dir
73+
# If the build target is in under directory
74+
# We should make direcotry in $(LC_MESSAGES) and link the file.
75+
@if [ $(dir) != "." ]; then \
76+
echo "mkdir -p $(LC_MESSAGES)/$(dir)"; \
77+
mkdir -p $(LC_MESSAGES)/$(dir); \
78+
echo "ln -f ./$(target) $(LC_MESSAGES)/$(target)"; \
79+
ln -f ./$(target) $(LC_MESSAGES)/$(target); \
80+
fi
81+
# Build
82+
@echo "----"
83+
@. $(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
84+
5685
help:
5786
@python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
5887

@@ -133,3 +162,7 @@ rm_cpython: ## Remove cloned cpython repo
133162
.PHONY: lint
134163
lint: $(VENV)/bin/sphinx-lint ## Run sphinx-lint
135164
$(VENV)/bin/sphinx-lint --enable default-role
165+
166+
# This allows us to accept extra arguments (by doing nothing when we get a job that doesn't match, rather than throwing an error)
167+
%:
168+
@:

0 commit comments

Comments
 (0)