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

# 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

$(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)