-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (64 loc) · 2.34 KB
/
Makefile
File metadata and controls
86 lines (64 loc) · 2.34 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
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
#
# The binaries you need installed globally are node, npm and nw
#
# NB: Create a file named `debug_repository.conf' in the root of the
# project that contains a string - the path to a testing git
# repository. The `run' and `debug' targets will use this path or the
# CWD if not set.
project_name := pharyngitis
sources := $(shell find src -iname '*.iced')
# extra_sources is everything except .iced and .js and hidded files in the scr dir
extra_sources := $(shell find src ! -path '*node_modules*' -a -type f -a ! -iname '*.iced' -a ! -name "\.*")
test_sources := $(shell find test -iname '*.iced')
dist_sources := node_modules
compiled = $(sources:.iced=.js)
test_compiled = $(test_sources:.iced=.js)
distdir := .dist
nw_package := $(project_name).nw
iced := node_modules/.bin/iced
mocha := node_modules/.bin/mocha
# set the path to the debug project
ifneq ($(wildcard debug_repository.conf),) # file exists
phrg_debug_project := $(shell cat debug_repository.conf)
endif
ifeq ($(phrg_debug_project),) # var still empty
phrg_debug_project = $(shell pwd)
endif
all: dist
test: $(compiled) $(test_compiled)
@echo "(target) running tests..."
@$(mocha)
dist: $(nw_package)
test/%.js: test/%.iced src/%.js node_modules
@echo "(compile) test: $<"
@$(iced) -c $<
src/%.js: src/%.iced node_modules
@echo "(compile) source: $<"
@$(iced) -c $<
$(nw_package): node_modules src/package.json $(compiled) $(dist_sources) $(extra_sources)
@echo "(target) generating distribution $(nw_package)"
@rm -rf $(nw_package) $(distdir) && mkdir -p $(distdir)
@cp -r $(dist_sources) $(distdir)
@for f in $(compiled) $(extra_sources); do \
target_path=$(distdir)/`echo $$f | sed -e 's%src/%%'`; \
mkdir -p `dirname $$target_path`; \
cp -f $$f $$target_path; \
done
@cd $(distdir) && zip -qr ../$(nw_package) ./
clean:
@echo "(target) cleaning..."
@rm -rf $(nw_package) $(compiled) $(test_compiled) $(distdir)
distclean:
@echo "(target) distcleaning..."
@rm -rf node_modules
node_modules: package.json
@echo "(target) updating node modules..."
@npm install && touch $@
build: node_modules $(compiled)
debug: build
@echo "(debug) running with git repo set to: $(phrg_debug_project) ..."
@nw src $(phrg_debug_project)
run: dist
@echo "(target) running with git repo set to: $(phrg_debug_project) ..."
nw $(nw_package) $(phrg_debug_project)
.PHONY: clean test run