Search code examples
scalatuplesscala-2.11scala-compiler

How to compile scala 2.11.2 with bigger tupes?


I tried to build scala 2.11.2 with bigger tuples (arity over 22) by following this guide: http://blog.rogach.org/2013/02/scala-tuplicity-comes-to-210.html

I have no previous experience with building the scala library & compiler and the ant build tool, so I just tried to run the script on a fresh git clone of tag v2.11.2 and hoped it will work. It didn't.

I got an error on line ant replacelocker:

BUILD FAILED
Target "replacelocker" does not exist in the project "sabbus".

Seems like the way scala 2.11 is built has changed. I was not able to find any specific info on how to replace the ant replacelocker line.

Is it possible to build scala 2.11.2 with bigger tuples like it is possible for 2.9 and 2.10? What has to be done differently?


Solution

  • I managed to compile scala with 64-arity tuples using this script, though it's probably not the optimal way (first compilation fails on missing classes above 22-arity, second pass finishes OK):

    #!/bin/bash -vx
    
    ARITY=64
    
    #mv scala scala-`date +%y%m%d-%H%M%S`
    #git clone https://github.com/scala/scala.git
    #cp -R scala-fresh scala
    #cd scala
    git checkout -b 2.11.2-local tags/v2.11.2
    export ANT_OPTS="-Xmx7G -Xss25M -Xms4G -XX:MaxPermSize=512M"
    #VERS="-Dbuild.release=true -Dversion.number=2.11.2-local -Dmaven.version.number=2.11.2-local"
    VERS="-Dbuild.release=true"
    sed -i "s/\(val MaxTupleArity, .*\) 22/\1 $ARITY/" src/reflect/scala/reflect/internal/Definitions.scala
    ant build $VERS
    sed -i "s/22/$ARITY/" src/library/scala/runtime/ScalaRunTime.scala
    sed -i "s/\(MAX_ARITY .*\) 22/\1 $ARITY/" src/build/genprod.scala
    sed -i 's/import scala.language.postfixOps//' src/build/genprod.scala
    echo 'genprod.main(Array("src/library/scala/"))' >> src/build/genprod.scala
    scala src/build/genprod.scala
    ant build $VERS