Created
March 6, 2018 16:32
-
-
Save bitwisecook/3b941b4f468ee62869ecb74fa126e164 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Be aware to first setup a valid Python 3 environment with the proper requirements installed. | |
# Also activate your Python installation/venv before executing those commands. | |
VER=0.19.4 | |
PROGS?=app1 app2 app3 app4 | |
PROGS_PY:=$(addsuffix .py,$(PROGS)) | |
PROGS_EXE:=$(addsuffix .exe,$(PROGS)) | |
NUITKA?=nuitka | |
BUILD_BASE?=build | |
DIST_BASE?=dist | |
UPX_COMP?=-1 | |
UPX_OPTS?=-f | |
UPX:=upx $(UPX_COMP) $(UPX_OPTS) | |
# we can use the ComSpec environment variable to check for Windows | |
ifdef ComSpec | |
ENV:=win | |
PATHSEP2=\\ | |
PATHSEP=$(strip $(PATHSEP2)) | |
CMDSEP=&& | |
CP=copy | |
MV=move | |
RM=if exist $(1) del $(1) | |
RMDIR=rmdir /s /q | |
MKDIR=mkdir | |
ZIP=zip | |
SED=sed | |
# because Windows is a pain with GNU make we need both the unix and the windows style paths | |
BUILD_DIR=$(BUILD_BASE)/win | |
PLAT_BUILD_DIR=$(BUILD_BASE)\\win | |
DIST_DIR=$(BUILD_BASE)/fullapp-win | |
PLAT_DIST_DIR=$(BUILD_BASE)\\fullapp-win | |
REQUIRED_LIBS=aepic.dll chakra.dll comppkgsup.dll coremessaging.dll coreuicomponents.dll cryptnet.dll cryptngc.dll dbgcore.dll dmcmnutils.dll dmpushproxy.dll dsreg.dll edputil.dll efscore.dll efswrt.dll fwbase.dll fwpolicyiomgr.dll ieapfltr.dll iri.dll mi.dll miutils.dll msvcp110_win.dll msvcp_win.dll msvcrt.dll ncaapi.dll omadmapi.dll policymanager.dll python36.dll rtworkq.dll sfc_os.dll srpapi.dll tpmcoreprovisioning.dll vcruntime140.dll wdscore.dll wer.dll win32u.dll wpaxholder.dll wpcwebfilter.dll | |
INSTALL_DIR= | |
AU3WRAP="%PROGRAMFILES%\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" | |
AUT2EXE="%PROGRAMFILES%\AutoIt3\aut2exe\aut2exe_x64.exe" | |
AU3CHECK= | |
AU3STRIPPER= | |
PYTHON3=python | |
MAKENSIS="%PROGRAMFILES%\NSIS\makensis.exe" | |
DIST_EXE=$(addprefix $(DIST_DIR)/,$(PROGS_EXE)) | |
DIST_LIB=$(addprefix $(DIST_DIR)/,$(REQUIRED_LIBS)) | |
else | |
ENV:=mac | |
PATHSEP2=/ | |
PATHSEP=$(strip $(PATHSEP2)) | |
CMDSEP=; | |
OS=unix | |
CP=cp -f | |
MV=mv | |
RM=rm -f $(1) | |
RMDIR=rm -rf $(1) | |
MKDIR=mkdir -p | |
ZIP=zip | |
SED=sed | |
BUILD_DIR=$(BUILD_BASE)/mac | |
PLAT_BUILD_DIR=$(BUILD_BASE)/mac | |
DIST_DIR=$(BUILD_BASE)/fullapp-mac | |
PLAT_DIST_DIR=$(BUILD_BASE)/fullapp-mac | |
REQUIRED_LIBS=Python _asyncio.so _bisect.so _blake2.so _bz2.so _codecs_cn.so _codecs_hk.so _codecs_iso2022.so _codecs_jp.so _codecs_kr.so _codecs_tw.so _crypt.so _csv.so _ctypes.so _curses.so _curses_panel.so _datetime.so _dbm.so _decimal.so _elementtree.so _gdbm.so _hashlib.so _heapq.so _json.so _lsprof.so _lzma.so _multibytecodec.so _multiprocessing.so _opcode.so _pickle.so _posixsubprocess.so _random.so _scproxy.so _sha3.so _socket.so _sqlite3.so _ssl.so _struct.so _tkinter.so array.so audioop.so binascii.so fcntl.so grp.so libcrypto.1.0.0.dylib math.so mmap.so pyexpat.so readline.so select.so termios.so unicodedata.so zlib.so | |
PACK_LIBS= | |
INSTALL_DIR=/usr/local/opt/fullapp/bin | |
PYTHON3=python3 | |
DIST_EXE=$(addprefix $(DIST_DIR)/,$(PROGS)) | |
DIST_LIB=$(addprefix $(DIST_DIR)/,$(REQUIRED_LIBS)) | |
endif | |
SRC?=fullapp | |
SRC_SUBDIRS:=$(addprefix $(SRC)$(PATHSEP),parser model appthing util) | |
SRC_DIRS:=$(SRC) $(SRC_SUBDIRS) | |
PY_SUB_DEPS:=$(addsuffix $(PATHSEP)*.py,$(SRC_SUBDIRS)) | |
PYCACHE:=$(addsuffix $(PATHSEP)__pycache__,$(SRC_DIRS)) | |
NUITKA_FLAGS=--show-scons --standalone --lto --remove-output --output-dir=$(BUILD_DIR) | |
.PHONY: all all-mac all-win | |
all: all-$(ENV) test | |
all-mac: $(DIST_BASE)/fullapp-mac-v$(VER).pkg $(DIST_BASE)/portable-fullapp-mac-v$(VER).zip | |
all-win: $(DIST_BASE)/setup-fullapp-v$(VER).exe $(DIST_BASE)/portable-fullapp-win-v$(VER).zip | |
.PHONY: clean clean-% | |
clean:: clean-$(ENV) | |
-$(RM) *.pyc | |
-$(RM) $(subst /,$(PATHSEP),$(TESTSRC)/.*.pkl) | |
-$(RM) $(subst /,$(PATHSEP),$(DIST_BASE)/portable-fullapp-$(ENV)-v$(VER).zip) | |
-$(RMDIR) $(PYCACHE) | |
-$(RMDIR) $(subst /,$(PATHSEP),$(BUILD_DIR)) | |
-$(RMDIR) $(subst /,$(PATHSEP),$(DIST_DIR)) | |
clean-win:: | |
-$(RM) $(subst /,$(PATHSEP),$(BUILD_BASE)/fullapp.nsi) | |
-$(RM) $(subst /,$(PATHSEP),$(DIST_BASE)/setup-fullapp-v$(VER).exe) | |
clean-mac:: | |
-$(RM) $(BUILD_BASE)/fullapp.pkgproj | |
-$(RM) $(subst /,$(PATHSEP),$(DIST_BASE)/fullapp-mac-v$(VER).pkg) | |
$(BUILD_BASE): | |
$(MKDIR) $(subst /,$(PATHSEP),$(BUILD_BASE)) | |
$(DIST_BASE): | |
$(MKDIR) $(subst /,$(PATHSEP),$(DIST_BASE)) | |
$(BUILD_DIR): $(BUILD_BASE) | |
$(MKDIR) $(subst /,$(PATHSEP),$(BUILD_DIR)) | |
$(DIST_DIR): $(DIST_BASE) | |
$(MKDIR) $(subst /,$(PATHSEP),$(DIST_DIR)) | |
# the nuitka build is precious because Make can't automatically delete directories | |
.PRECIOUS: $(BUILD_DIR)/%.dist | |
$(BUILD_DIR)/%.dist: $(SRC)/%.py | $(BUILD_DIR) | |
$(NUITKA) $(NUITKA_FLAGS) $< | |
# read the .exe out of the Nuitka prog.dist/prog.exe into the target | |
$(DIST_DIR)/%.exe: $(BUILD_DIR)/%.dist | $(DIST_DIR) | |
copy $(subst /,$(PATHSEP),$<$(PATHSEP)$*.exe) $(subst /,$(PATHSEP),$@) | |
# $(UPX) $(subst /,$(PATHSEP),$<$(PATHSEP)$*.exe) -o$(subst /,$(PATHSEP),$@) | |
$(DIST_DIR)/%: $(BUILD_DIR)/%.dist | $(DIST_DIR) | |
cp $(subst /,$(PATHSEP),$<$(PATHSEP)$*.exe) $(subst /,$(PATHSEP),$@) | |
# $(UPX) $(subst /,$(PATHSEP),$<$(PATHSEP)$*.exe) -o$(subst /,$(PATHSEP),$@) | |
# grab the dependencies out of whichever program was listed first | |
# get just the filename out of the target and stick the first dependency on it | |
# which is the Nuitka prog.dist/ directory | |
$(DIST_DIR)/Python $(DIST_DIR)/%.dylib $(DIST_DIR)/%.dll $(DIST_DIR)/%.so: $(BUILD_DIR)/$(firstword $(PROGS)).dist | $(DIST_DIR) | |
$(CP) $(subst /,$(PATHSEP),$<$(PATHSEP)$(@F)) $(subst /,$(PATHSEP),$@) | |
$(DIST_DIR)/sols.conf: $(SRC)/model/sols.json | $(DIST_DIR) | |
$(CP) $(subst /,$(PATHSEP),fullapp$(PATHSEP)model$(PATHSEP)sols.json) $(subst /,$(PATHSEP),$(DIST_DIR)$(PATHSEP)sols.conf) | |
$(SRC)/model/sols.json: $(SRC)/version.py | |
-$(PYTHON3) fullapp$(PATHSEP)updatesols.py -f fullapp$(PATHSEP)model$(PATHSEP)sols.json | |
$(BUILD_DIR)/apptoolkit.au3: $(SRC)/version.py | $(BUILD_DIR) | |
$(SED) -e "s/#VER#/$(VER)/" $(SRC)\wingui\apptoolkit.au3 > $(subst /,$(PATHSEP),$(BUILD_DIR)$(PATHSEP)apptoolkit.au3) | |
$(DIST_DIR)/apptoolkit.exe: $(BUILD_DIR)/apptoolkit.au3 | |
$(AUT2EXE) /in $(subst /,$(PATHSEP),"$(BUILD_DIR)$(PATHSEP)apptoolkit.au3") /out $(subst /,$(PATHSEP),"$(BUILD_DIR)$(PATHSEP)apptoolkit.exe") /comp 4 /nopack /unicode | |
copy $(subst /,$(PATHSEP),"$(BUILD_DIR)$(PATHSEP)apptoolkit.exe") $(subst /,$(PATHSEP),$@) | |
# $(UPX) --compress-icons=0 --keep-resource=10/SCRIPT $(subst /,$(PATHSEP),"$(BUILD_DIR)$(PATHSEP)apptoolkit.exe") -o$(subst /,$(PATHSEP),$@) | |
$(BUILD_BASE)/fullapp.pkgproj: $(SRC)/version.py $(addprefix $(SRC)$(PATHSEP),$(PROGS_PY)) $(PY_SUB_DEPS) | $(BUILD_BASE) | |
cat $(SRC)/buildsrc/fullapp.pkgproj.top.tmpl > $(BUILD_BASE)/fullapp.pkgproj | |
$(foreach lib,$(REQUIRED_LIBS),$(SED) -E "s/#FILE#/$(lib)/" $(SRC)/buildsrc/fullapp.pkgproj.file.tmpl >> $(BUILD_BASE)/fullapp.pkgproj ; ) | |
$(foreach prog,$(PROGS),$(SED) -E "s/#FILE#/$(prog)/" $(SRC)/buildsrc/fullapp.pkgproj.file.tmpl >> $(BUILD_BASE)/fullapp.pkgproj ; ) | |
$(SED) -E "s/#VER#/$(VER)/" $(SRC)/buildsrc/fullapp.pkgproj.tail.tmpl >> $(BUILD_BASE)/fullapp.pkgproj | |
$(BUILD_BASE)/fullapp.nsi: $(BUILD_BASE) $(SRC)/version.py $(addprefix $(SRC)$(PATHSEP),$(PROGS_PY)) | $(BUILD_BASE) | |
$(SED) -e "s/#VER#/$(VER)/" $(SRC)\buildsrc\fullapp.nsi.top.tmpl > $(BUILD_BASE)\fullapp.nsi | |
$(foreach lib,$(REQUIRED_LIBS),$(SED) -e "s/#FILE#/$(lib)/; s/#DIST#/$(PLAT_DIST_DIR)/" $(SRC)\buildsrc\fullapp.nsi.file.tmpl >> $(BUILD_BASE)\fullapp.nsi && ) echo . | |
$(foreach prog,$(PROGS),$(SED) -e "s/#FILE#/$(prog).exe/; s/#DIST#/$(PLAT_DIST_DIR)/" $(SRC)\buildsrc\fullapp.nsi.file.tmpl >> $(BUILD_BASE)\fullapp.nsi && ) echo . | |
$(SED) -e "s/#FILE#/apptoolkit.exe/; s/#DIST#/$(PLAT_DIST_DIR)/" $(SRC)\buildsrc\fullapp.nsi.file.tmpl >> $(BUILD_BASE)\fullapp.nsi | |
$(SED) -e "s/#FILE#/logo.ico/; s/#DIST#/$(PLAT_DIST_DIR)/" $(SRC)\buildsrc\fullapp.nsi.file.tmpl >> $(BUILD_BASE)\fullapp.nsi | |
$(SED) -e "s/#FILE#/logo.jpg/; s/#DIST#/$(PLAT_DIST_DIR)/" $(SRC)\buildsrc\fullapp.nsi.file.tmpl >> $(BUILD_BASE)\fullapp.nsi | |
$(SED) -e "s/#VER#/$(VER)/" $(SRC)\buildsrc\fullapp.nsi.mid.tmpl >> $(BUILD_BASE)\fullapp.nsi | |
$(foreach lib,$(REQUIRED_LIBS),$(SED) -e "s/#FILE#/$(lib)/; s/#DIST#/$(PLAT_DIST_DIR)/" $(SRC)\buildsrc\fullapp.nsi.delfile.tmpl >> $(BUILD_BASE)\fullapp.nsi && ) echo . | |
$(foreach prog,$(PROGS),$(SED) -e "s/#FILE#/$(prog).exe/; s/#DIST#/$(PLAT_DIST_DIR)/" $(SRC)\buildsrc\fullapp.nsi.delfile.tmpl >> $(BUILD_BASE)\fullapp.nsi && ) echo . | |
$(SED) -e "s/#FILE#/apptoolkit.exe/; s/#DIST#/$(PLAT_DIST_DIR)/" $(SRC)\buildsrc\fullapp.nsi.delfile.tmpl >> $(BUILD_BASE)\fullapp.nsi | |
$(SED) -e "s/#FILE#/logo.ico/; s/#DIST#/$(PLAT_DIST_DIR)/" $(SRC)\buildsrc\fullapp.nsi.delfile.tmpl >> $(BUILD_BASE)\fullapp.nsi | |
$(SED) -e "s/#FILE#/logo.jpg/; s/#DIST#/$(PLAT_DIST_DIR)/" $(SRC)\buildsrc\fullapp.nsi.delfile.tmpl >> $(BUILD_BASE)\fullapp.nsi | |
$(SED) -e "s/#VER#/$(VER)/" $(SRC)\buildsrc\fullapp.nsi.tail.tmpl >> $(BUILD_BASE)\fullapp.nsi | |
$(DIST_DIR)/logo.ico: | $(DIST_DIR) | |
$(CP) $(SRC)\wingui\logo_2_256px.ico $(PLAT_DIST_DIR)\logo.ico | |
$(DIST_DIR)/logo.jpg: | $(DIST_DIR) | |
$(CP) $(SRC)\wingui\logo_2.jpg $(PLAT_DIST_DIR)\logo.jpg | |
$(BUILD_BASE)/$(DIST)/setup-fullapp-v$(VER).exe: $(DIST_DIR)/sols.conf $(DIST_DIR)/logo.ico $(DIST_DIR)/logo.jpg $(BUILD_BASE)/fullapp.nsi $(DIST_DIR)/apptoolkit.exe $(DIST_EXE) $(DIST_LIB) | |
$(MAKENSIS) $(BUILD_BASE)\fullapp.nsi | |
$(DIST_BASE)/setup-fullapp-v$(VER).exe: $(BUILD_BASE)/$(DIST)/setup-fullapp-v$(VER).exe | $(DIST_BASE) | |
cmd /S /C "move /Y $(BUILD_BASE)\dist\setup-fullapp-v$(VER).exe dist" | |
$(DIST_BASE)/portable-fullapp-$(ENV)-v$(VER).zip: | $(DIST_BASE) | |
$(ZIP) -9jvr $(DIST_BASE)/portable-fullapp-$(ENV)-v$(VER).zip $(DIST_DIR)/* LICENSE.TXT | |
$(BUILD_BASE)/$(DIST_BASE)/fullapp-v$(VER).pkg: $(BUILD_BASE)/fullapp.pkgproj $(DIST_DIR)/sols.conf $(DIST_EXE) $(DIST_LIB) | |
/usr/local/bin/packagesbuild -v -F . ./$(BUILD_BASE)/fullapp.pkgproj | |
$(DIST_BASE)/fullapp-mac-v$(VER).pkg: $(BUILD_BASE)/$(DIST_BASE)/fullapp-v$(VER).pkg | $(DIST_BASE) | |
$(CP) $(BUILD_BASE)/$(DIST_BASE)/fullapp-v$(VER).pkg $(DIST_BASE)/fullapp-mac-v$(VER).pkg | |
.PHONY: test test-% | |
# test -> test-ENV -> PROGS(test-env-$prog) | |
test: test-$(ENV) | |
test-mac:: EXT:= | |
test-mac:: EXEDIR:=..$(PATHSEP)$(DIST_DIR)$(PATHSEP) | |
test-mac:: TESTSRC:=..$(PATHSEP)testsrc$(PATHSEP) | |
test-mac:: TESTPATHPREFIX:=PATH=/bin:/usr/bin ; cd rubbish ; | |
test-win:: EXT:=.exe | |
test-win:: EXEDIR:=$(subst /,$(PATHSEP),../$(DIST_DIR)/) | |
test-win:: TESTSRC:=..$(PATHSEP)testsrc$(PATHSEP) | |
test-win:: TESTPATHPREFIX:=set PATH=c:\windows\system32 && cd rubbish && | |
test-$(ENV):: $(addprefix test-$(ENV)-,$(PROGS)) | |
test-$(ENV)-app1: | |
$(TESTPATHPREFIX) $(EXEDIR)app1$(EXT) $(TESTSRC)base.dat base1.dat | |
test-$(ENV)-%: | |
@echo !!! No tests for $* | |
# ============== | |
# Bump version | |
# ============== | |
.PHONY: release | |
VERSION?=minor | |
# target: release - Bump version | |
release: | |
@pip install bumpversion | |
@bumpversion $(VERSION) | |
.PHONY: minor | |
minor: release | |
.PHONY: patch | |
patch: | |
make release VERSION=patch | |
.PHONY: major | |
major: | |
make release VERSION=major |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment