aboutsummaryrefslogtreecommitdiff
path: root/contexts/build.mk
blob: 6b3e63213d25b7cb413a039aedd23745747ac9f6 (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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177

# 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)

$(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" #####################################################
#
# In order to turn a number of different javascript modules into a single one,
# we just concatenate them all together.  This should be fine, as all of the
# modules we define just provide functions, or register callbacks.

quiet_cmd_compilejs = JSC        $(call drop-prefix,$@)
      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)


# CSS Staging ##################################################################

css-bundle := $(topdir)/tools/bin/css-bundle.py

quiet_cmd_cssbundle = CSSC       $(call drop-prefix,$@)
      cmd_cssbundle = ( cd $(dir $(TARGET)) && \
                        $(css-bundle) $(notdir $(TARGET)) $@ $(redir) )

$(stage-dir)/data/bundled.css: TARGET := $(lib-dir)/jquery/css/ui-lightness/jquery-ui.css
$(stage-dir)/data/bundled.css:                                      \
    $(wildcard $(lib-dir)/jquery/css/ui-lightness/*.css)        \
    $(wildcard $(lib-dir)/jquery/css/ui-lightness/images/*.png) \
  | $(stage-dir)/data
	$(call cmd,cssbundle)


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

chrome-dir := $(path)/chrome

all: $(topdir)/fiveui.crx

clean::
	$(RM) $(topdir)/fiveui.crx

$(topdir)/fiveui.crx: $(build-dir)/fiveui.crx
	$(call cmd,cp)

# 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/bundled.css                      \
                       | $(stage-dir)/data/fiveui/images
	$(call label,MAKECRX    $(call drop-prefix,$@)) ( cd $(build-dir)   \
	&& $(topdir)/tools/bin/makecrx stage                                \
	       $(topdir)/contexts/chrome/fiveui.pem fiveui                  \
	   $(redir) )


# 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)


# Firefox Compilation ##########################################################

addon-sdk := $(topdir)/tools/addon-sdk

all: $(topdir)/fiveui.xpi

clean::
	$(RM) $(topdir)/fiveui.xpi

$(topdir)/fiveui.xpi: $(build-dir)/fiveui.xpi
	$(call cmd,cp)


# wrapper for setting up the environment for the running the cfx command
cfx = ( cd $(addon-sdk) $(redir) && \
        . bin/activate  $(redir) && \
        cd $(build-dir) $(redir) && \
        cfx $1 $(redir) )

# build the actual extension
$(build-dir)/fiveui.xpi:          \
    $(stage-dir)/package.json     \
    $(target-dir)/firefox-main.js \
  | $(topdir)/profiles/firefox
	$(call label,XPI        $(call drop-prefix,$@))\
	  $(call cfx,xpi -p $(topdir)/profiles/firefox \
	                 --pkgdir=$(stage-dir) )

# stage the package description
$(stage-dir)/package.json: $(path)/package.json | $(stage-dir)
	$(call cmd,cp)

# build the main script
$(target-dir)/firefox-main.js: \
    $(fiveui-dir)/settings.js        \
    $(fiveui-dir)/messenger.js       \
    $(fiveui-dir)/rules.js           \
    $(fiveui-dir)/background.js      \
    $(fiveui-dir)/utils.js           \
  | $(target-dir)
	$(call cmd,compilejs)