-
Notifications
You must be signed in to change notification settings - Fork 17
/
build-node.xml
155 lines (133 loc) · 3.74 KB
/
build-node.xml
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
<?xml version="1.0"?>
<!DOCTYPE project>
<project name="build-nodejs" xmlns:antelope="antlib:ise.antelope.tasks">
<import file="build-common.xml" />
<macrodef name="node-execute">
<attribute name="command"/>
<attribute default="${user.dir}" name="working.dir" />
<sequential>
<exec dir="@{working.dir}" executable="${basedir}/tools/node-v${nodejs.version}/bin/@{command}">
<arg line="${node.args}"/>
</exec>
</sequential>
</macrodef>
<target name="download-node">
<if>
<os arch="x86_32" family="mac" />
<then>
<propertycopy from="nodejs.url[osx32]" name="nodejs.url" />
</then>
<elseif>
<os arch="x86_64" family="mac" />
<then>
<propertycopy from="nodejs.url[osx64]" name="nodejs.url" />
</then>
</elseif>
<elseif>
<os arch="amd" family="unix" />
<then>
<propertycopy from="nodejs.url[linux32]" name="nodejs.url" />
</then>
</elseif>
<elseif>
<os arch="amd64" family="unix" />
<then>
<propertycopy from="nodejs.url[linux64]" name="nodejs.url" />
</then>
</elseif>
<elseif>
<os arch="x86" family="windows" />
<then>
<propertycopy from="nodejs.url[windows32]" name="nodejs.url" />
</then>
</elseif>
<elseif>
<os arch="amd64" family="windows" />
<then>
<propertycopy from="nodejs.url[windows64]" name="nodejs.url" />
</then>
</elseif>
</if>
<if>
<not>
<isset property="nodejs.url" />
</not>
<then>
<fail>
.
Unable to automatically detect the current operating system and architecture.
Please manually set the property "nodejs.url" in build.properties to the
location of NodeJS. An example value for OSX on a 64 bit architecture is
${nodejs.url[osx64]}.
</fail>
</then>
</if>
<if>
<not>
<available file="tools/node-v${nodejs.version}" />
</not>
<then>
<antelope:stringutil string="${nodejs.url}" property="nodejs.file.beginindex">
<antelope:lastindexof string="/" />
</antelope:stringutil>
<math
datatype="int"
operand1="${nodejs.file.beginindex}"
operand2="1"
operation="+"
result="nodejs.file.beginindex"
/>
<antelope:stringutil string="${nodejs.url}" property="nodejs.file">
<antelope:substring beginindex="${nodejs.file.beginindex}" />
</antelope:stringutil>
<mirrors-get dest="${nodejs.file}" src="${nodejs.url}" />
<if>
<contains string="${nodejs.file}" substring=".tar.gz" />
<then>
<exec executable="tar">
<arg line="xfz ${nodejs.file} -C tools"/>
</exec>
<antelope:stringutil string="${nodejs.file}" property="nodejs.dir.endindex">
<antelope:lastindexof string=".tar.gz" />
</antelope:stringutil>
<antelope:stringutil string="${nodejs.file}" property="nodejs.dir">
<antelope:substring endindex="${nodejs.dir.endindex}" />
</antelope:stringutil>
<delete dir="tools/node-v${nodejs.version}" />
<move file="tools/${nodejs.dir}" tofile="tools/node-v${nodejs.version}" />
<mkdir dir="tools/node-v${nodejs.version}/node_modules" />
<delete file="${nodejs.file}" />
</then>
<else>
<move file="${nodejs.file}" todir="tools/node-v${nodejs.version}" />
</else>
</if>
<if>
<os family="windows" />
<then>
<mirrors-get
dest="npm.zip"
src="${nodejs.npm.url}"
/>
<unzip
dest="tools/node-v${nodejs.version}"
src="npm.zip"
/>
<delete file="npm.zip" />
</then>
</if>
</then>
</if>
</target>
<target name="node-execute" depends="download-node">
<node-execute
command="node"
/>
</target>
<target name="npm-execute" depends="download-node">
<node-execute
command="npm"
working.dir="tools/node-v${nodejs.version}"
/>
</target>
</project>