-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
113 lines (88 loc) · 2.85 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
105
106
107
108
109
110
111
112
113
# $Id$
.PHONY: run build clean lint lintrun dist
OS:=$(shell uname -s)
ifeq ($(OS),Darwin)
PYTHONDIR:=/System/Library/Frameworks/Python.framework/Versions/Current
export PYTHONPATH=$(wildcard $(PYTHONDIR)/lib/python*/site-packages)
PYTHONBINPREFIX:=$(PYTHONDIR)/bin/
APPCONTENTS:=derived/openMSX_Catapult.app/Contents
PY_DIR:=$(APPCONTENTS)/MacOS
RES_DIR:=$(APPCONTENTS)/Resources
else
PYTHONBINPREFIX:=
PY_DIR:=derived
RES_DIR:=derived
endif
ICONS:=$(wildcard res/*.png) $(wildcard res/*.icns) $(wildcard res/*.ico)
COPY_ICONS:=$(ICONS:res/%=$(RES_DIR)/%)
SOURCES:=$(wildcard src/*.py)
COPY_SRC:=$(SOURCES:src/%=$(PY_DIR)/%)
UI_DESIGNS:=$(wildcard res/*.ui)
UI_GEN_SRC:=$(UI_DESIGNS:res/%.ui=$(PY_DIR)/ui_%.py)
DIST_FILES:=Makefile $(SOURCES) $(ICONS) $(UI_DESIGNS) win32exe.py
CHANGELOG_REVISION=\
$(shell sed -ne "s/\$$Id: ChangeLog \([^ ]*\).*/\1/p" ChangeLog)
VERSION=prerelease-$(CHANGELOG_REVISION)
# Default to build
build:
run: build
ifeq ($(OS),Darwin)
open derived/openMSX_Catapult.app
else
cd $(PY_DIR) && $(PYTHONBINPREFIX)python3 catapult.py
endif
#TODO make the *.db files dependend on *txt files and generate them
# for now launch autorunfilldb.py manually
dbfiles:
cp tools/autorun.db $(PY_DIR)
cp tools/softdb.db $(PY_DIR)
cp tools/hwimages.db $(PY_DIR)
runcd: build dbfiles
ifeq ($(OS),Darwin)
open derived/openMSX_Catapult.app --cd
else
cd $(PY_DIR) && $(PYTHONBINPREFIX)python3 catapult.py --cd
endif
build: $(COPY_SRC) $(COPY_ICONS) $(UI_GEN_SRC)
$(COPY_SRC): $(PY_DIR)/%.py: src/%.py
@mkdir -p $(@D)
cp $< $@
$(COPY_ICONS): $(RES_DIR)/%: res/%
@mkdir -p $(@D)
cp $< $@
$(UI_GEN_SRC): $(PY_DIR)/ui_%.py: res/%.ui
@mkdir -p $(@D)
cd res && $(PYTHONBINPREFIX)pyuic5 $(<F) -o ../$@
ifeq ($(OS),Darwin)
build: $(APPCONTENTS)/Info.plist $(APPCONTENTS)/PkgInfo $(APPCONTENTS)/MacOS/run.sh
$(APPCONTENTS)/MacOS/run.sh: build/package-darwin/run.sh
mkdir -p $(@D)
cp $< $@
$(APPCONTENTS)/Info.plist: build/package-darwin/Info.plist ChangeLog
mkdir -p $(@D)
sed -e 's/%VERSION%/$(VERSION)/' < $< > $@
$(APPCONTENTS)/PkgInfo:
mkdir -p $(@D)
echo "APPLoMXC" > $@
endif
clean:
rm -rf derived
# Altough the generated sources are not checked, the modules that are checked
# import them and those import statements are checked.
lint: build
cd src && PYTHONPATH=$(PYTHONPATH):../$(PY_DIR) pylint $(SOURCES:src/%.py=%.py)
lintrun: build
@echo "Checking modified sources with PyLint..."
@MODIFIED=`svn st | sed -ne 's/[AM]..... src\/\(.*\.py\)$$/\1/p'` && \
if [ -n "$$MODIFIED" ]; then \
cd src && ! PYTHONPATH=$(PYTHONPATH):../$(PY_DIR) pylint --errors-only $$MODIFIED | grep .; \
fi
make run
precommit: build
@svn diff
@MODIFIED=`svn st | sed -ne 's/[AM]..... src\/\(.*\.py\)$$/\1/p'` && \
if [ -n "$$MODIFIED" ]; then \
cd src && PYTHONPATH=$(PYTHONPATH):../$(PY_DIR) pylint -rn $$MODIFIED; \
fi
dist:
zip catapult-$(VERSION).zip $(DIST_FILES)