aboutsummaryrefslogtreecommitdiff
path: root/contexts/build.mk
blob: dba77019a7803c384e79a1cf70f8dfdcb6db5a1b (plain)
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

# Source Info ##################################################################

# source and resources
data-dir := $(path)/data

# fiveui source directory
fiveui-dir := $(data-dir)/fiveui

lib-dir := $(data-dir)/lib

# packaged extension directory
bin-dir  := $(data-dir)/target


# Extension Staging ############################################################
#
# The purpose of this step is to setup all the compiled scripts necessary for
# both plugins in a common tree.  From this state, we can pick and choose what
# goes into each extension.

stage-dir := $(build-dir)/stage

$(stage-dir): | $(build-dir)
	$(call cmd,mkdir)

$(target-dir): | $(stage-dir)
	$(call cmd,mkdir)

$(stage-dir)/data: | $(stage-dir)
	$(call cmd,mkdir)

$(stage-dir)/data/lib: | $(stage-dir)/data
	$(call cmd,mkdir)

$(stage-dir)/data/fiveui: | $(stage-dir)/data
	$(call cmd,mkdir)

$(stage-dir)/data/fiveui/images: | $(stage-dir)/data/fiveui
	$(call cmd,mkdir)

target-dir := $(stage-dir)/data/target

$(target-dir): | $(stage-dir)/data
	$(call cmd,mkdir)

$(stage-dir)/data/fiveui/images/%: $(fiveui-dir)/images/% \
	                         | $(stage-dir)/data/fiveui/images
	$(call cmd,cp)


# Javascript "Compilation" #####################################################

quiet_cmd_compilejs = JSC        $@
      cmd_compilejs = cat $^ > $@

# generic background script dependencies
background-deps :=                \
  $(underscore)                   \
  $(addprefix $(fiveui-dir)/,     \
    background.js                 \
    settings.js                   \
    messenger.js                  \
    rules.js)

# generic options page dependencies
options-deps := \
  $(underscore) \
  $(addprefix $(fiveui-dir)/, \
    options.js)


# Chrome Extension #############################################################
#
# Use the staged artifacts to build the chrome extension in contexts/fiveui.crx

chrome-dir := $(path)/chrome

all: $(build-dir)/fiveui.crx


# Create the chrome extension
$(build-dir)/fiveui.crx: $(target-dir)/chrome-background.js                 \
                         $(target-dir)/chrome-options.js                    \
                         $(stage-dir)/manifest.json                         \
                         $(stage-dir)/data/fiveui/images/fiveui-icon-16.png \
                       | $(stage-dir)/data/fiveui/images
	$(call label,MAKECRX    $@) (cd $(build-dir)    \
	&& $(topdir)/tools/bin/makecrx stage            \
	       $(topdir)/contexts/chrome/fiveui.pem     \
	       fiveui                                   \
	$(if $(Q),1>/dev/null) )


# install the extension manifest in the stage directory
$(stage-dir)/manifest.json: $(path)/manifest.json | $(stage-dir)
	$(call cmd,cp)

chrome-src := $(fiveui-dir)/chrome

# the chrome-specific background javascript
$(target-dir)/chrome-background.js: $(background-deps)          \
                                    $(chrome-src)/background.js \
                                  | $(target-dir)
	$(call cmd,compilejs)


# the chrome-specific options javascript
$(target-dir)/chrome-options.js: $(options-deps)          \
                                 $(chrome-src)/chrome-options.js \
                               | $(target-dir)
	$(call cmd,compilejs)