diff --git a/conf/templates/gitignore b/conf/templates/gitignore new file mode 100644 index 00000000..9d297dbe --- /dev/null +++ b/conf/templates/gitignore @@ -0,0 +1,55 @@ +{top} +*.a +*.dep.mk +*.dist +*.done +*.jw-secret +*.jw-secret-file +*.ldscript +*.o +*.old +*.orig +*.out +*.pc +*.pyc +*.rep +*.secret +*.so +*.so.* +*.swp +*_generated_* +*tmp* +*~ +-test-out.txt +.cache-project.mk +.exrc +.feedfs_history +.gdb_history +.jw-agit +.mypy_cache +.ruff_cache +__init__.py +__pycache__ +bin/*.bat +bin/*.pl +bin/*.pm +bin/*.py +bin/*.sh +bin/*.tcl +conftest.py +core +dist +ld-*.conf +local.conf +local.mk +local.mk +local.yaml +make/*.pc +mkspec.sh +pr-descr*.txt +pre-local.mk +pyproject.toml +pyrightconfig.json +!*.jw-tmpl +!*.tmpl +{end} diff --git a/make/topdir.mk b/make/topdir.mk index 0a9cb67f..b8eb3e75 100644 --- a/make/topdir.mk +++ b/make/topdir.mk @@ -99,6 +99,9 @@ JW_PKG_TMPL_SEARCH_PATH ?= $(JW_PKG_CONF_BASE_DIR)/templates JW_PKG_TMPL_UPDATE ?= $(PYTHON) $(JWB_SCRIPT_DIR)/jw-pkg.py -p $(PROJECTS_DIR) -t $(TOPDIR) --topdir-format unaltered \ projects create-file --format tmpl --search-path $(subst $(space),:,$(JW_PKG_TMPL_SEARCH_PATH)) --template-name +GITIGNORE_PATTERNS_TOP ?= $(PROJECT) +GITIGNORE_PATTERNS_END ?= $(addprefix !,$(shell git ls-files 2>/dev/null | grep "\(\b$(PROJECT)\b\|__init__.py\)" | xargs)) + all: topdir config test: all @@ -311,3 +314,10 @@ Makefile: ; %: $(TD_COPY_SRC)/% $$(foreach path,$$(TD_COPY_SRC_PATH),$$(wildcard $$(addprefix $$(path)/,$$@))) $$(wildcard $$@.*) cat $^ > $@.tmp mv $@.tmp $@ + +gitignore: + $(JW_PKG_TMPL_UPDATE) gitignore --field-keys top,end \ + $(addprefix --field top=,$(GITIGNORE_PATTERNS_TOP)) \ + $(addprefix --field end=,$(GITIGNORE_PATTERNS_END)) \ + --field-separator='%n' $(PROJECT) | grep -v '^[[:space:]]*$$' > .gitignore.tmp + mv .gitignore.tmp .gitignore