forked from tunnelvisionlabs/antlrworks2
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.xml
149 lines (128 loc) · 6.62 KB
/
build.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
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
<!-- for some information on what you could do (e.g. targets to override). -->
<!-- If you delete this file and reopen the project it will be recreated. -->
<project name="org.antlr.works.editor" default="netbeans" basedir=".">
<description>Builds, tests, and runs the project org.antlr.works.editor.</description>
<import file="nbproject/build-impl.xml"/>
<target name="init-complete-artifact">
<property name="artifact.name" value="antlr4-complete"/>
<property name="artifact.commit" value="4.5.3"/>
<property name="grammar.resources.dir" value="src/org/antlr/works/editor/grammar/resources"/>
<property name="modules.cache.dir" value="lib/cache"/>
<property name="artifact.intermediatefile" value="${modules.cache.dir}/${artifact.name}-${artifact.commit}.jar"/>
<property name="complete-artifact.file" value="${grammar.resources.dir}/${artifact.name}.jar"/>
</target>
<target name="download-complete-artifact" depends="init-complete-artifact,harness.build-init">
<mkdir dir="${grammar.resources.dir}"/>
<mkdir dir="${modules.cache.dir}"/>
<get src="http://tunnelvisionlabs.com/downloads/antlr/build/${artifact.name}-${artifact.commit}.jar"
dest="${artifact.intermediatefile}"
skipexisting="true"/>
<copy file="${artifact.intermediatefile}" tofile="${complete-artifact.file}"/>
</target>
<target name="clean-generated-sources">
<delete failonerror="true" includeemptydirs="true">
<fileset dir="${basedir}" includes="src/**/generated/**"/>
</delete>
</target>
<target name="clean" depends="init-complete-artifact,projectized-common.clean,clean-generated-sources">
<delete file="${complete-artifact.file}"/>
</target>
<target name="antlr-init" depends="harness.build-init">
<property name="antlr4.jar" value="${basedir}/../org-antlr-v4/release/modules/ext/antlr4.jar"/>
<property name="antlr4_runtime.jar" value="${basedir}/../org-antlr-v4-runtime/release/modules/ext/antlr4_runtime.jar"/>
<property name="st4.jar" value="${basedir}/../org-stringtemplate-v4/release/modules/ext/st4.jar"/>
<property name="antlr3_runtime.jar" value="${basedir}/../org-antlr-runtime/release/modules/ext/antlr3_runtime.jar"/>
<path id="cp.antlr4">
<pathelement location="${antlr4.jar}"/>
<pathelement location="${antlr4_runtime.jar}"/>
<pathelement location="${st4.jar}"/>
<pathelement location="${antlr3_runtime.jar}"/>
</path>
<property name="antlr4.touch" value="${build.dir}/antlr4.touch" />
</target>
<target name="build-init" depends="antlr-init,harness.build-init,download-complete-artifact"/>
<target name="antlr4-up-to-date" depends="antlr-init">
<uptodate targetfile="${antlr4.touch}" property="is.antlr4.uptodate">
<!-- TODO: rebuild grammars if we switch to a new build of the tool -->
<srcfiles dir="${src.dir}">
<include name="**/*.g4"/>
<include name="**/*.tokens"/>
<exclude name="**/generated/**"/>
</srcfiles>
</uptodate>
</target>
<target name="up-to-date" depends="antlr4-up-to-date,projectized-common.up-to-date">
<condition property="is.all.uptodate">
<and>
<istrue value="${is.jar.uptodate}"/>
<istrue value="${is.antlr4.uptodate}"/>
</and>
</condition>
<scriptdef name="propertyreset" language="javascript"
description="Allows to assign @{property} new value">
<attribute name="name"/>
<attribute name="value"/>
project.setProperty(attributes.get("name"), attributes.get("value"));
</scriptdef>
<propertyreset name="${is.jar.uptodate}" value="${is.all.uptodate}" />
</target>
<target name="compile" depends="init,up-to-date,antlr4,projectized-common.compile" unless="is.jar.uptodate" />
<macrodef name="antlr4">
<attribute name="srcpath"/>
<element name="args" optional="true"/>
<sequential>
<local name="package"/>
<local name="paths.antlr4.local"/>
<pathconvert property="package" dirsep=".">
<path location="${src.dir}/@{srcpath}"/>
<map from="${src.dir}/" to=""/>
</pathconvert>
<path id="sources.antlr4.@{srcpath}">
<fileset dir="${src.dir}/@{srcpath}" includes="*.g4"/>
</path>
<pathconvert property="paths.antlr4.local" refid="sources.antlr4.@{srcpath}" pathsep=" ">
<map from="${src.dir}/@{srcpath}/" to=""/>
</pathconvert>
<java classname="org.antlr.v4.Tool" fork="true" failonerror="true" dir="${src.dir}/@{srcpath}">
<arg value="-o"/>
<arg value="generated"/>
<arg value="-package"/>
<arg value="${package}.generated"/>
<args/>
<arg line="${paths.antlr4.local}"/>
<classpath>
<path refid="cp.antlr4"/>
<pathelement location="${java.class.path}"/>
</classpath>
</java>
</sequential>
</macrodef>
<target name="antlr4" depends="antlr-init,harness.build-init,antlr4-up-to-date" unless="is.antlr4.uptodate">
<path id="sources.antlr4">
<fileset dir="${src.dir}" includes="**/*.g4"/>
</path>
<pathconvert pathsep="${line.separator} " property="echo.sources.antlr4" refid="sources.antlr4">
<map from="${src.dir}/" to=""/>
</pathconvert>
<echo message="Generating ANTLR 4 grammars:${line.separator} ${echo.sources.antlr4}"/>
<parallel threadsperprocessor="1" failonany="true">
<antlr4 srcpath="org/antlr/works/editor/grammar/experimental">
<args>
<arg value="-visitor"/>
<arg value="-Xforce-atn"/>
</args>
</antlr4>
<antlr4 srcpath="org/antlr/works/editor/grammar/highlighter"/>
<antlr4 srcpath="org/antlr/works/editor/st4/experimental">
<args>
<arg value="-visitor"/>
<arg value="-Xforce-atn"/>
</args>
</antlr4>
<antlr4 srcpath="org/antlr/works/editor/st4/highlighter"/>
</parallel>
<touch file="${antlr4.touch}" mkdirs="true"/>
</target>
</project>