mirror of
https://github.com/engineer-man/piston.git
synced 2025-04-22 21:16:29 +02:00
pkg: new build system
This commit is contained in:
parent
d1b41e3c2f
commit
eba1d3abcd
3 changed files with 24 additions and 114 deletions
|
@ -1,40 +1,29 @@
|
|||
# Wraps all other Makefiles
|
||||
PACKAGES=$(shell find * -maxdepth 0 -type d)
|
||||
BUILD_PLATFORM=$(or ${PLATFORM},baremetal-$(shell grep -oP "^ID=\K.+" /etc/os-release))
|
||||
|
||||
# Variables
|
||||
PKG_FILES=$(filter-out common.mk,$(wildcard *.mk))
|
||||
PKG_SLUGS=$(foreach pkg, ${PKG_FILES}, $(addprefix $(shell make -f ${pkg} name VERSION=UNKNOWN)-, $(shell make -f ${pkg} versions VERSION=UNKNOWN)))
|
||||
help:
|
||||
@echo "You probably don't want to build all package"
|
||||
@echo "If you do run $`make build-all$`"
|
||||
@echo
|
||||
@echo "Run $`make [language]-[version].pkg.tar.gz$` to build a specific language"
|
||||
|
||||
# Functions
|
||||
CALL_MAKE=$(shell make -f $1 $2 VERSION=UNKNOWN)
|
||||
build build-all: $(addsuffix .pkg.tar.gz, ${PACKAGES})
|
||||
clean clean-all: $(addprefix clean-, ${PACKAGES})
|
||||
|
||||
define pkg_info
|
||||
$(eval PKG_SLUG=$(patsubst $1-%,%,$2))
|
||||
$(eval PKG_VERSION=$(lastword $(subst -, ,${PKG_SLUG})))
|
||||
$(eval PKG_NAME=$(patsubst %-${PKG_VERSION},%,${PKG_SLUG}))
|
||||
$(eval PKG_FILE=$(shell grep '^VERSIONS\s*=.*${PKG_VERSION}' $(shell grep "NAME\s*=\s*${PKG_NAME}" ${PKG_FILES} -l) -l))
|
||||
endef
|
||||
clean-%: %/
|
||||
rm -rf $</build $</output
|
||||
|
||||
%.pkg.tar.gz: %/output %/run %/environment %/pkg-info.json
|
||||
rm -f $@
|
||||
tar czf $@ -C $* $(patsubst $*/%,%,output run environment pkg-info.json $(shell find $*/compile)) --transform='s|output|$*|;s|environment|$*/environment|'
|
||||
|
||||
%/pkg-info.json: %/metadata.json
|
||||
jq '.build_platform="${BUILD_PLATFORM}"' $< > $@
|
||||
|
||||
%/output: %/ %/build.sh
|
||||
cd $< && chmod +x ./build.sh && ./build.sh
|
||||
|
||||
define per-lang
|
||||
build-$(call CALL_MAKE, $1, name):: $$(addprefix build-$(call CALL_MAKE, $1, name)-, $$(call CALL_MAKE, $1, versions))
|
||||
clean-$(call CALL_MAKE, $1, name):: $$(addprefix clean-$(call CALL_MAKE, $1, name)-, $$(call CALL_MAKE, $1, versions))
|
||||
endef
|
||||
|
||||
|
||||
# Targets
|
||||
|
||||
$(foreach e,${PKG_FILES}, $(eval $(call per-lang,${e})))
|
||||
|
||||
build build-all: $(foreach pkg, ${PKG_FILES}, build-$(call CALL_MAKE, ${pkg}, name))
|
||||
|
||||
$(addprefix build-, ${PKG_SLUGS}):
|
||||
$(call pkg_info,build,$@)
|
||||
$(MAKE) -f ${PKG_FILE} VERSION=${PKG_VERSION} build
|
||||
|
||||
clean clean-all: $(foreach pkg, ${PKG_FILES}, clean-$(call CALL_MAKE, ${pkg}, name))
|
||||
rm -rf build/
|
||||
|
||||
$(addprefix clean-, ${PKG_SLUGS}):
|
||||
$(call pkg_info,clean,$@)
|
||||
$(MAKE) -f ${PKG_FILE} VERSION=${PKG_VERSION} clean
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue