informarte / yuck

Yuck is a local-search constraint solver with FlatZinc interface
Other
56 stars 11 forks source link

How to build? #8

Closed yurivict closed 2 years ago

yurivict commented 3 years ago

Are there build/install instructions?

I am trying mill compile - it seems to build.

But mill yuck.launcher doesn't install anything.

How to install it such that MiniZinc can see it?

informarte commented 3 years ago

From https://github.com/informarte/yuck#running:

Use make stage to create the script out/yuck/launcher/dest/run. To use this script with the MiniZinc toolchain, create a solver configuration file from the template resources/mzn/yuck.msc.in and move it a to a place where the MiniZinc toolchain can find it.

I am working on Linux and I have my solver configuration files in ~/.minizinc/solvers. In particular, ~/.minizinc/solvers/yuck-stage.msc contains:

{
    "id": "yuck",
    "name": "Yuck",
    "description": "Local-search solver with FlatZinc interface",
    "version": "stage",
    "executable": "/home/informarte/Workspaces/yuck/out/yuck/launcher/dest/run",
    "mznlib": "/home/informarte/Workspaces/yuck/resources/mzn/lib/yuck",
    "tags": ["cbls", "int", "set", "restart"],
    "stdFlags": ["-a", "-f", "-p", "-r", "-v"],
    "supportsMzn": false,
    "supportsFzn": true,
    "needsSolns2Out": true,
    "needsMznExecutable": false,
    "needsStdlibDir": false,
    "isGUIApplication": false
}

With this setup, minizinc --solvers yields:

Available solver configurations:
  ...
  Yuck 20210501 (yuck, cbls, int, set, restart)
  Yuck stage (yuck, cbls, int, set, restart)
Search path for solver configurations:
  /home/informarte/.minizinc/solvers
  /home/informarte/Software/lib/MiniZincIDE-2.5.5-bundle-linux-x86_64/share/minizinc/solvers
  /usr/local/share/minizinc/solvers
  /usr/share/minizinc/solvers

You can see that I have two versions of Yuck configured: the staged version and the latest release 20210501 installed from the Debian package. To make sure that MiniZinc uses the right version, specify it together with the solver, e.g. --solver yuck@stage. (You can leave out the version but MiniZinc will not complain about the ambiguity; it will just use some version.)

yurivict commented 3 years ago

Do you happen to know how to specify the cache directory for build? It uses /home/{user}/.cache regardless of the HOME variable.

informarte commented 3 years ago

I am not sure what you mean by "cache directory for build". Class files and everything else end up in out. Or do you mean the Coursier package cache? I never tried to move it but I found a page with relevant information: https://get-coursier.io/docs/cache

Notice that mill caches a lot of information about the environment in the out directory AND in the running mill daemon. For example, try grep -R coursier out/. AFAIK, there is only one way to inform mill about changes in the environment: Kill the daemon and remove the out directory, in that order.

yurivict commented 3 years ago

Or do you mean the Coursier package cache?

Yes. I already found that XDG_CACHE_HOME sets the cache directory.

In order for software to be packageable build shouldn't download anything, because build should be reproducible and all downloaded files should be fingerprinted. This is why cache should be saved and then fed to the build.


The run file looks like this:

@ 2>/dev/null # 2>nul & echo off & goto BOF^M
:
exec /usr/local/openjdk8/bin/java -Xmx2G -Djava.lang.Integer.IntegerCache.high=10000 -XX:+UseParallelGC $JAVA_OPTS -cp "/usr/ports/math/yuck/work/yuck-20210501/out/yuck/compile/dest/classes:/usr/ports/math/yuck/work/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.5/scala-library-2.13.5.jar:/usr/ports/math/yuck/work/coursier/v1/https/repo1.maven.org/maven2/com/conversantmedia/rtree/1.0.5/rtree-1.0.5.jar:/usr/ports/math/yuck/work/coursier/v1/https/repo1.maven.org/maven2/com/github/scopt/scopt_2.13/3.7.1/scopt_2.13-3.7.1.jar:/usr/ports/math/yuck/work/coursier/v1/https/repo1.maven.org/maven2/io/spray/spray-json_2.13/1.3.5/spray-json_2.13-1.3.5.jar:/usr/ports/math/yuck/work/coursier/v1/https/repo1.maven.org/maven2/org/jgrapht/jgrapht-core/1.4.0/jgrapht-core-1.4.0.jar:/usr/ports/math/yuck/work/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/modules/scala-parser-combinators_2.13/1.1.2/scala-parser-combinators_2.13-1.1.2.jar:/usr/ports/math/yuck/work/coursier/v1/https/repo1.maven.org/maven2/org/jheaps/jheaps/0.11/jheaps-0.11.jar" 'yuck.flatzinc.runner.FlatZincRunner' "$@"
exit
^M
:BOF^M
setlocal^M
@echo off^M
/usr/local/openjdk8/bin/java -Xmx2G -Djava.lang.Integer.IntegerCache.high=10000 -XX:+UseParallelGC %JAVA_OPTS% -cp "/usr/ports/math/yuck/work/yuck-20210501/out/yuck/compile/dest/classes;/usr/ports/math/yuck/work/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.5/scala-library-2.13.5.jar;/usr/ports/math/yuck/work/coursier/v1/https/repo1.maven.org/maven2/com/conversantmedia/rtree/1.0.5/rtree-1.0.5.jar;/usr/ports/math/yuck/work/coursier/v1/https/repo1.maven.org/maven2/com/github/scopt/scopt_2.13/3.7.1/scopt_2.13-3.7.1.jar;/usr/ports/math/yuck/work/coursier/v1/https/repo1.maven.org/maven2/io/spray/spray-json_2.13/1.3.5/spray-json_2.13-1.3.5.jar;/usr/ports/math/yuck/work/coursier/v1/https/repo1.maven.org/maven2/org/jgrapht/jgrapht-core/1.4.0/jgrapht-core-1.4.0.jar;/usr/ports/math/yuck/work/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/modules/scala-parser-combinators_2.13/1.1.2/scala-parser-combinators_2.13-1.1.2.jar;/usr/ports/math/yuck/work/coursier/v1/https/repo1.maven.org/maven2/org/jheaps/jheaps/0.11/jheaps-0.11.jar" yuck.flatzinc.runner.FlatZincRunner %*^M
endlocal^M
exit /B %errorlevel%^M

Is this only for Windows?

informarte commented 3 years ago

The run script is generated by mill built-in magic, it is not part of the Yuck build, and it is not intended for distribution! It runs fine on Linux and I hope it works on Windows, too, but I never tested it.

To generate an official, non-Debian start-up script, run make zip or ./mill yuck.universalPackage. You'll find the result in out/yuck/universalPackage/dest.

What exactly are you working on? It seems that you are trying to create a package for some distribution.

yurivict commented 3 years ago

What exactly are you working on? It seems that you are trying to create a package for some distribution.

I am creating the FreeBSD port. It is already working, I am working out some kinks.

informarte commented 3 years ago

Cool, when you are done with the port, would you mind to add a comment to this issue with a link to the package? Thank you!

yurivict commented 3 years ago

Will do.

yurivict commented 3 years ago

The port works, but mill is broken - it fails in a VM: https://github.com/com-lihaoyi/mill/issues/1316 Need to wait until this is resolved.

yurivict commented 3 years ago

mill is broken. The upstream itself doesn't know how to fix it. mill exists in the ports tree but nobody uses it. You seem to be the first user.

Are there alternative ways to build yuck?

informarte commented 3 years ago

I would not conclude that mill is broken; it's just that you are using it in unexpected ways. Also, if you want help from the mill community, you need to provide them with context and precise reproduction steps.

Regarding Yuck, you need mill to build it, there is not other way.