aboutsummaryrefslogtreecommitdiff
path: root/src/js/firefox/build.mk
blob: 36fad923619d01a65261445da56fc7d383bf1b5f (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

# Firefox Extension ############################################################

all: stage-firefox

package: $(build-dir)/fiveui.xpi


firefox-dir := $(path)

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

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


# Generic Extension ############################################################

$(eval $(call stage-fiveui,$(firefox-build),stage-firefox))


# Firefox File Staging #########################################################

# copy in firefox scripts
$(firefox-build)/data/js/%: $(firefox-dir)/js/% | $(firefox-build)/data/js
	$(call cmd,cp)

# copy in firefox scripts
$(firefox-build)/data/injected/%: $(firefox-dir)/injected/% \
                                | $(firefox-build)/data/injected
	$(call cmd,cp)

$(firefox-build)/data/icons/%: $(firefox-dir)/icons/% \
                             | $(firefox-build)/data/icons
	$(call cmd,cp)

$(firefox-build)/data/icons: | $(firefox-build)/data
	$(call cmd,mkdir)

$(firefox-build)/data/%: $(firefox-dir)/lib/% | $(firefox-build)/data
	$(call cmd,cp)


$(firefox-build)/%: $(firefox-dir)/% | $(firefox-build)
	$(call cmd,cp)


# Wrapper 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 $^ > $@

# we have to build one big source for the firefox main.js, as we can't really
# share reuse the CommonJS module system in the chrome version.
$(firefox-build)/data/main.js:     \
    $(firefox-dir)/lib/main.js     \
    $(fiveui-dir)/js/set.js        \
    $(fiveui-dir)/js/settings.js   \
    $(fiveui-dir)/js/messenger.js  \
    $(fiveui-dir)/js/state.js      \
    $(fiveui-dir)/js/utils.js      \
    $(fiveui-dir)/js/rules.js      \
    $(fiveui-dir)/js/background.js \
  | $(firefox-build)/data
	$(call cmd,compilejs)


# Packaging ####################################################################

.PHONY: stage-firefox
stage-firefox:                                    \
    $(firefox-build)/package.json                 \
    $(firefox-build)/data/main.js                 \
    $(firefox-build)/data/ajax.js                 \
    $(firefox-build)/data/storage-wrapper.js      \
    $(firefox-build)/data/tabIds.js               \
    $(firefox-build)/data/icons/fiveui-icon.html  \
    $(firefox-build)/data/icons/fiveui-icon.js    \
    $(firefox-build)/data/icons/options-icon.html \
    $(firefox-build)/data/icons/options-icon.js   \
  | $(firefox-build)

$(build-dir)/fiveui.xpi: stage-firefox \
                       | $(topdir)/profiles/firefox  $(addon-sdk-unpacked)
	$(call label,XPI        $(call drop-prefix,$@))\
	  $(call cfx,$(build-dir),xpi -p $(topdir)/profiles/firefox \
	                 --pkgdir=$(firefox-build) )


# Testing ######################################################################

run-firefox: stage-firefox | $(addon-sdk-unpacked)
	$(call label,RUNFF)$(call cfx,$(firefox-build),run)