-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmakefile
More file actions
54 lines (45 loc) · 1.8 KB
/
Copy pathmakefile
File metadata and controls
54 lines (45 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Makefile for building portable flask exe with static react files.
# Requires that you have a .venv python setup in the same directory as this file.
# Requires that you have npm on your system and package.json in the same directory as this file.
REACT_DIR ?= .\public
FLASK_DIR ?= .\Flask
REACT_BUILD_OUTPUT_DIR ?= .\build
REACT_IN_FLASK_DIR ?= $(FLASK_DIR)\build
PYINSTALLER_SPEC_FILE ?= packCO2PRT.spec
PACKAGE_BASENAME ?= Smart_CO2_Transport
PYINSTALLER_DIST_DIR ?= .\dist
VENV_DIR ?= .\.venv
NODE_MODULES_DIR ?= .\node_modules
NPM = npm
XCOPY = xcopy
RMDIR = rmdir /S /Q
DEL = del /Q
MKDIR = mkdir
PYI = PyInstaller
PY = $(VENV_DIR)/Scripts/python.exe
POWERSHELL = powershell -Command
.PHONY: all build_react copy_frontend build_pyinstaller package clean
all: build_pyinstaller
build_react:
@echo --- Building React Frontend ---
$(NPM) install && $(NPM) run build
@echo --- React Frontend Build Complete ---
copy_frontend: build_react
@echo --- Copying React build to Flask project ---
-$(RMDIR) "$(REACT_IN_FLASK_DIR)"
-$(MKDIR) "$(REACT_IN_FLASK_DIR)"
-$(XCOPY) $(REACT_BUILD_OUTPUT_DIR) $(REACT_IN_FLASK_DIR) /E /I /Y
build_pyinstaller: copy_frontend
@echo --- Building PyInstaller Bundle ---
$(PY) -m $(PYI) $(PYINSTALLER_SPEC_FILE) -y
@echo --- PyInstaller Bundle Build Complete ---
package:
@echo --- Packaging Application ---
$(POWERSHELL) "$$timestamp = Get-Date -Format 'MMddyyyy_HHmmss'; $$zipFileName = '$(PACKAGE_BASENAME)_$$timestamp.zip'; Compress-Archive -Path 'dist\$(PACKAGE_BASENAME)' -DestinationPath $$zipFileName;"
@echo --- Packaging Complete ---
clean:
@echo --- Cleaning Project ---
-$(RMDIR) "$(REACT_IN_FLASK_DIR)"
-$(RMDIR) "$(REACT_BUILD_OUTPUT_DIR)"
-$(RMDIR) "$(PYINSTALLER_DIST_DIR)"
-$(RMDIR) "$(NODE_MODULES_DIR)"