stefan-hoeck / idris2-pack

BSD 3-Clause "New" or "Revised" License
100 stars 27 forks source link

Feature request: Allow custom compiler bootstrap scripts for external backends #146

Open jonathanrlouie opened 2 years ago

jonathanrlouie commented 2 years ago

When specifying the idris-jvm backend as the idris2 url for a package set, building an Idris2 project with pack causes the build to fail with the following error:

43/95: Building Debug.Trace (Debug/Trace.idr)
Error: The given specifier '["jvm:toString(java/lang/Object java/lang/String),java/util/Objects"]' was not accepted
by any backend. Available backends:
  chez, chez-sep, racket, node, javascript, refc, gambit, vmcode-interp
Some backends have additional specifier rules, refer to their documentation.

This is because the pack bootstrapping process does not use a previous version of the idris-jvm compiler to build the idris-jvm compiler. Instead, it will try to run make bootstrap as part of Pack.Runner.Install.mkIdris, which idris-jvm does not use. Idris-jvm bootstraps the compiler by running the following commands (as seen in its GitHub Actions install workflow):

export IDRIS2_TESTS_CG=jvm
export PREVIOUS_VERSION=0.5.1
export IDRIS2_PREFIX=$HOME/bin/idris2-$PREVIOUS_VERSION/lib
export PREFIX=$IDRIS2_PREFIX
mvn dependency:copy -Dartifact=io.github.mmhelloworld:idris-jvm-compiler:$PREVIOUS_VERSION:zip -DoutputDirectory=. -U
unzip idris-jvm-compiler-*.zip -d $HOME/bin
echo "::add-path::$HOME/bin/idris2-$PREVIOUS_VERSION/bin"
mvn -B install -Dinteractive= -Didris.tests="only=jvm"

These commands use Maven to download a previous version of the Idris2 compiler from Maven Central, and then use that downloaded compiler to build the new compiler.

I think pack should allow a custom bootstrapping script to be specified to allow external backends like idris-jvm to be used with pack.

stefan-hoeck commented 2 years ago

Yes, we definitely need this (and other ways for custom installations).