Skip to content

Commit

Permalink
Preliminary support for zinc.
Browse files Browse the repository at this point in the history
To use Zinc with the ant build:
  - install zinc and symlink the installed zinc script to ${basedir}/tools/zinc
    (${basedir} is where build.xml and the rest of your checkout resides)
  - make sure to set ZINC_OPTS to match ANT_OPTS!
  - invoke ant as `ant -Dstarr.version="2.10.1" -Dlocker.skip=1`
    (zinc does not work if locker is only classfiles, needs jars
     TODO rework the build to pack locker and build using that when using zinc?)

Mostly to enable dog fooding of incremental compilation work for now.
  • Loading branch information
adriaanm committed Apr 2, 2013
1 parent ceeb40c commit 7c0e8f0
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ targets exercised:
build-opt nightly test.suite test.continuations.suite test.scaladoc locker.done
-->

<!-- To use Zinc with the ant build:
- install zinc and symlink the installed zinc script to ${basedir}/tools/zinc (${basedir} is where build.xml and the rest of your checkout resides)

This comment has been minimized.

Copy link
@paulp

paulp Apr 2, 2013

If someone has zinc on their path, they shouldn't have to do this manual step.

- make sure to set ZINC_OPTS to match ANT_OPTS!

This comment has been minimized.

Copy link
@paulp

paulp Apr 2, 2013

If this is important, why do we leave it for the user to do?

This comment has been minimized.

Copy link
@adriaanm

adriaanm Apr 2, 2013

Author Owner

True, I felt like pleasure-delaying one last addition to my ant skill set.

- invoke ant as `ant -Dstarr.version="2.10.1" -Dlocker.skip=1`
(zinc needs compiler jars
TODO rework the build to pack locker and build using that when using zinc)
-->


<!-- ===========================================================================
END-USER TARGETS
Expand Down Expand Up @@ -792,6 +800,49 @@ targets exercised:
</sequential>
</macrodef>

<!-- Zinc assumes a one-to-one correspondence of output folder to set of source files.
When compiling different sets of source files in multiple compilations to the same output directory,
Zinc thinks source files that appeared in an earlier compilation but are absent in the current one,
were deleted and thus deletes the corresponding output files.
Note that zinc also requires each arg to scalac to be prefixed by -S.
-->
<macrodef name="zinc">
<attribute name="compilerpathref" />
<attribute name="destdir" />
<attribute name="srcdir" />
<attribute name="srcpath" default="NOT SET"/> <!-- needed to compile the library -->

This comment has been minimized.

Copy link
@paulp

paulp Apr 2, 2013

Is "NOT SET" something you made up or something ant understands? Either way, does it have semantics which are documented somewhere?

This comment has been minimized.

Copy link
@gkossakowski

gkossakowski Apr 2, 2013

Agreed with @paulp.

This comment has been minimized.

Copy link
@gkossakowski

gkossakowski Apr 2, 2013

Actually, if you scroll down you see:

+      <if><not><equals arg1="@{srcpath}" arg2="NOT SET"/></not><then>
+        <property name="args" value="@{params} -sourcepath @{srcpath}"/>
+      </then></if>

So NOT SET seems to be just a dummy value that you'll need to compare against later on. I don't know if there's an ant standard for that but a comment explaining "NOT SET" would help.

<attribute name="buildpathref" />
<attribute name="params" default="" />
<attribute name="java-excludes" default=""/>

<sequential>
<local name="sources"/>
<pathconvert pathsep=" " property="sources">
<fileset dir="@{srcdir}">
<include name="**/*.java"/>
<include name="**/*.scala"/>
<exclude name="@{java-excludes}"/>
</fileset>
</pathconvert>
<local name="args"/>
<local name="sargs"/>
<if><not><equals arg1="@{srcpath}" arg2="NOT SET"/></not><then>
<property name="args" value="@{params} -sourcepath @{srcpath}"/>
</then></if>
<property name="args" value="@{params}"/> <!-- default -->

<!-- HACK: prefix scalac args by -S -->
<script language="javascript">
project.setProperty("sargs", project.getProperty("args").trim().replaceAll(" ", " -S"));
</script>

<exec osfamily="unix" executable="tools/zinc" failifexecutionfails="true" failonerror="true">
<arg line="-nailed -compile-order JavaThenScala -scala-path ${ant.refid:@{compilerpathref}} -d @{destdir} -classpath ${toString:@{buildpathref}} ${sargs} ${sources}"/>
</exec>
</sequential>
</macrodef>

<macrodef name="staged-scalac" >
<attribute name="with"/> <!-- will use path `@{with}.compiler.path` to locate scalac -->
<attribute name="stage"/> <!-- current stage (locker, quick, strap) -->
Expand All @@ -803,6 +854,21 @@ targets exercised:
<attribute name="java-excludes" default=""/>

<sequential>
<!-- use zinc for the quick stage if it's available;
would use it for locker but something is iffy in sbt: get a class cast error on global phase -->

This comment has been minimized.

Copy link
@gkossakowski

gkossakowski Apr 2, 2013

Could it because the last time starr got replaced was in d3095cb which was long before 2.10.0 final and is binary incompatible with final? I believe zinc ships with precompiled compiler interface and does not compile it on demand. Right?

This comment has been minimized.

Copy link
@adriaanm

adriaanm Apr 2, 2013

Author Owner

I haven't double checked, but I think I saw the compiler interface being compiled in zinc as well. However, it could still explain the problem if it cached the compiled interface too eagerly. /cc @pvlugter

This comment has been minimized.

Copy link
@pvlugter

pvlugter Apr 2, 2013

Zinc will compile and cache the compiler interface as needed. The compiler interface is cached under ~/.zinc/$zincVersion/compiler-interface-$scalaActualVersion-$javaClassVersion.

<if><and> <available file="tools/zinc"/>
<equals arg1="@{stage}" arg2="quick"/>
<not><equals arg1="@{project}" arg2="plugins"/></not> <!-- doesn't work in zinc because it requires the quick compiler, which isn't jarred up-->
</and><then>
<zinc taskname="Z.@{stage}.@{project}"
compilerpathref="@{with}.compiler.path"
destdir="${build-@{stage}.dir}/classes/@{destproject}"
srcdir="${src.dir}/@{srcdir}"
srcpath="@{srcpath}"
buildpathref="@{stage}.@{project}.build.path"
params="${scalac.args.@{stage}} @{args}"
java-excludes="@{java-excludes}"/></then>
<else>
<if><equals arg1="@{srcpath}" arg2="NOT SET"/><then>
<scalacfork taskname="@{stage}.@{project}"
jvmargs="${scalacfork.jvmargs}"
Expand All @@ -823,6 +889,7 @@ targets exercised:
<include name="**/*.scala"/>
<compilationpath refid="@{stage}.@{project}.build.path"/></scalacfork></else>
</if>
</else></if>
</sequential>
</macrodef>

Expand Down

0 comments on commit 7c0e8f0

Please sign in to comment.