blob: 1fd914dc7f61072d9007eda20a677700250013b4 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project basedir="." default="netbeans" name="rust/rust.grammar">
<description>Builds, tests, and runs the project org.netbeans.modules.rust.grammar</description>
<import file="../../nbbuild/templates/projectized.xml"/>
<!-- Antlr Tool classpath -->
<path id="antlr.path">
<fileset dir="../../ide/libs.antlr4.runtime/external" includes="*.jar"/>
<fileset dir="../../ide/libs.antlr3.runtime/external" includes="antlr-runtime-*.jar"/>
</path>
<!-- Prepares Antlr variables -->
<target name="init-antlr">
<property name="antlr.apt.output.dir" location="src/org/netbeans/modules/rust/grammar/antlr4" />
<property name="antlr.apt.grammar.dir" location="src/org/netbeans/modules/rust/grammar/antlr4/g4" />
</target>
<!-- Checks if Antlr needs to be run or not (to force you may remove file "RustParser.tokens" -->
<target name="check-antlr-uptodate">
<uptodate property="antlr-uptodate" targetfile="${antlr.apt.output.dir}/RustParser.tokens">
<srcfiles dir="${antlr.apt.grammar.dir}" includes="*.g4"/>
</uptodate>
<echo message="antlr check-antlr-uptodate result: ${antlr-uptodate}"/>
</target>
<!-- Runs antlr4 for RustLexer.g4 and RustParser.g4 -->
<target name="antlr" depends="init-antlr, check-antlr-uptodate" unless="antlr-uptodate">
<echo message="Generating lexer from RustLexer.g4..." />
<java classname="org.antlr.v4.Tool" fork="true" failonerror="true">
<arg value="-Xexact-output-dir"/>
<arg value="-package" />
<arg value="org.netbeans.modules.rust.grammar.antlr4" />
<arg value="-o"/>
<arg value="${antlr.apt.output.dir}"/>
<arg value="${antlr.apt.grammar.dir}/RustLexer.g4"/>
<classpath refid="antlr.path" />
</java>
<echo message="Generating parser from RustParser.g4..." />
<java classname="org.antlr.v4.Tool" fork="true" failonerror="true">
<arg value="-Xexact-output-dir"/>
<arg value="-package" />
<arg value="org.netbeans.modules.rust.grammar.antlr4" />
<arg value="-no-listener"/>
<arg value="-visitor"/>
<arg value="-o"/>
<arg value="${antlr.apt.output.dir}"/>
<arg value="${antlr.apt.grammar.dir}/RustParser.g4"/>
<classpath refid="antlr.path" />
</java>
<delete>
<fileset dir="${antlr.apt.output.dir}" includes="*.interp" />
<fileset dir="${antlr.apt.output.dir}" includes="*.tokens" />
</delete>
</target>
<!-- Compiles as usual, but invokes "antlr" first if needed -->
<target name="compile" depends="antlr,projectized-common.compile"/>
</project>