-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
104 lines (89 loc) · 3.31 KB
/
Makefile
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Set the shell explicitly for UNIX-like systems
SHELL := /bin/bash
# Detect the operating system
ifeq ($(OS),Windows_NT)
DETECTED_OS := Windows
DEL_CMD := del /s /q
RMDIR_CMD := rmdir /s /q
MKDIR_CMD := mkdir
SLASH := \\
else
DETECTED_OS := $(shell uname)
DEL_CMD := rm -rf
RMDIR_CMD := rm -rf
MKDIR_CMD := mkdir -p
SLASH := /
endif
PLATFORM_INTERFACE_DIR := ./minigpu_platform_interface/
FFI_DIR := .$(SLASH)minigpu_ffi$(SLASH)
WEB_DIR := .$(SLASH)minigpu_web$(SLASH)
minigpu_DIR := .$(SLASH)minigpu$(SLASH)
EXAMPLE_DIR := .$(SLASH)minigpu$(SLASH)example$(SLASH)
SRC_DIR := .$(SLASH)minigpu_ffi$(SLASH)src$(SLASH)
BUILD_DIR := .$(SLASH)minigpu_ffi$(SLASH)src$(SLASH)build$(SLASH)
BUILD_WEB_DIR := .$(SLASH)minigpu_ffi$(SLASH)src$(SLASH)build_web$(SLASH)
VERSION ?= 1.0.0
default: run
pubspec_local:
@echo " Switching our pubspecs for local dev with version ${VERSION}."
@python update_pubspecs.py ${VERSION}
pubspec_release:
@echo " Switching our pubspecs for release with version ${VERSION}."
@python update_pubspecs.py ${VERSION} --release
clean:
@echo " Cleaning Example."
@cd $(EXAMPLE_DIR) && flutter clean
run:
ifeq ($(DETECTED_OS), Windows)
@echo " Running example on Windows..."
@cd $(EXAMPLE_DIR) && cmd /c flutter run -d Windows
else ifeq ($(DETECTED_OS), Linux)
@echo " Running example on $(DETECTED_OS)..."
@cd $(EXAMPLE_DIR) && flutter run -d Linux
else ifeq ($(DETECTED_OS), Darwin)
@echo " Running example on $(DETECTED_OS)..."
@cd $(EXAMPLE_DIR) && flutter run -d MacOS
else
@echo "Unsupported OS: $(DETECTED_OS)"
endif
run_device:
@echo " Running example on device..."
@cd $(EXAMPLE_DIR) && flutter run
run_web: build_weblib
@echo " Running web example..."
@cd $(EXAMPLE_DIR) && flutter run -d chrome --web-browser-flag "--enable-features=SharedArrayBuffer" --web-browser-flag "--enable-unsafe-webgpu" --web-browser-flag "--disable-dawn-features=diallow_unsafe_apis"
ffigen:
@echo "Generating dart ffi bindings..."
@cd $(FFI_DIR) && dart run ffigen
build_weblib:
@echo "Building ffi lib to web via emscripten..."
@cd $(BUILD_WEB_DIR) && emcmake cmake .. && cmake --build .
build_ffilib:
@echo "Building ffi lib to native via emscripten..."
@cd $(BUILD_DIR) && cmake cmake .. --fresh && cmake --build .
clean_weblib:
@echo "Cleaning web lib dir..."
@$(DEL_CMD) "$(BUILD_WEB_DIR)*"
@$(RMDIR_CMD) "$(BUILD_WEB_DIR)*"
clean_ffilib:
@echo "Cleaning lib dir..."
@$(RMDIR_CMD) "$(BUILD_DIR)"
@$(MKDIR_CMD) "$(BUILD_DIR)"
clean_weblib:
@echo "Cleaning web lib dir..."
@$(RMDIR_CMD) "$(BUILD_WEB_DIR)"
@$(MKDIR_CMD) "$(BUILD_WEB_DIR)"
help:
@echo ** Available Commands **
@echo * make pubspec_local: Switches pubspecs for local dev."
@echo * make pubspec_release: Switches pubspecs for release."
@echo * make clean: Cleans the example project."
@echo * make run: Runs the example project on current OS."
@echo * make run_device: Runs the example project on chosen device."
@echo * make run_web: Runs the web example project."
@echo * make ffigen: Generates dart ffi bindings."
@echo * make build_weblib: Builds the ffi lib to web via emscripten."
@echo * make build_ffilib: Builds the ffi lib to native."
@echo * make clean_weblib: Cleans the web lib."
@echo * make clean_ffilib: Cleans the native lib."
@echo * make help: Shows this help message."