mmake
mmake copied to clipboard
WIP to export Makefiles that replace include with file content
This spike is to transpile makefiles to replace include statements with their file contents.
This will solve 2 issues:
- Wanting a way to export Makefile into transpiled Makefile that has inlined includes (Issue #18)
- Providing help output that includes targets from
include
makefiles (Issue #31)
I spiked it out in ruby for easy of scripting: https://gist.github.com/zph/8b3f6afd7a56613a80ef09319c20c7be
mmake export
will read the Makefile, then parse it line by line for include statements, then each include will be recursively filled in with the file content of the include
Makefile, which will be recursively parsed for include statements...
So running mmake export
on the Makefile at root of this project would yield a portable Makefile like:
#- start=include github.com/tj/make/golang
#- start=include github.com/tj/make/cloc
# Output source statistics.
cloc:
@cloc --exclude-dir=client,vendor .
.PHONY: cloc
#- end=include github.com/tj/make/cloc
#- start=include github.com/tj/make/todo
# Output to-do items per file.
todo:
@grep \
--exclude-dir=./vendor \
--exclude-dir=./client/node_modules \
--text \
--color \
-nRo ' TODO:.*' .
.PHONY: todo
#- end=include github.com/tj/make/todo
# Run all tests.
test:
@go test -cover ./...
.PHONY: test
# Install the commands.
install:
@go install ./cmd/...
.PHONY: install
# Release binaries to GitHub.
release:
@goreleaser --rm-dist --config .goreleaser.yml
.PHONY: release
# Show size of imports.
size:
@curl -sL https://gist.githubusercontent.com/tj/04e0965e23da00ca33f101e5b2ed4ed4/raw/9aa16698b2bc606cf911219ea540972edef05c4b/gistfile1.txt | bash
.PHONY: size
#- end=include github.com/tj/make/golang
That full Makefile output can then be used for mmake help
to correctly report all targets :D.
Anyway, it looked fun and caught my attention. Now I need to do the actual work of transcribing and re-implementing.
So the current mmake export
output for Makefile
from room of this project is:
#- start=include github.com/tj/make/golang
#- start=include github.com/tj/make/cloc
# Output source statistics.
cloc:
@cloc --exclude-dir=client,vendor .
.PHONY: cloc
#- end=include github.com/tj/make/cloc
#- start=include github.com/tj/make/todo
# Output to-do items per file.
todo:
@grep \
--exclude-dir=./vendor \
--exclude-dir=./client/node_modules \
--text \
--color \
-nRo ' TODO:.*' .
.PHONY: todo
#- end=include github.com/tj/make/todo
# Run all tests.
test:
@go test -cover ./...
.PHONY: test
# Install the commands.
install:
@go install ./cmd/...
.PHONY: install
# Release binaries to GitHub.
release:
@goreleaser --rm-dist --config .goreleaser.yml
.PHONY: release
# Show size of imports.
size:
@curl -sL https://gist.githubusercontent.com/tj/04e0965e23da00ca33f101e5b2ed4ed4/raw/9aa16698b2bc606cf911219ea540972edef05c4b/gistfile1.txt | bash
.PHONY: size
#- end=include github.com/tj/make/golang