amuletml / amulet

An ML-like functional programming language
https://amulet.works/
BSD 3-Clause "New" or "Revised" License
324 stars 14 forks source link

Compilation fails when amuletml is used as a stack dependency #298

Closed s5bug closed 2 years ago

s5bug commented 2 years ago

stack.yaml:

extra-deps:
- github: amuletml/amulet
  commit: 1beab4d6ca3fc53b151fe2ba97bc82e6afa9fc0d
- github: amuletml/hslua
  commit: fb3454f06ab62130fc31d7f40e153a08450999c9
- lsp-1.1.1.0@sha256:c8856e5fc71bc9834301731b5ba8786159e1d7e2d2d8ee07aec4f5421f2cf847,5568
- lsp-types-1.1.0.0@sha256:071289b1c5e2ba8fedf846cfe1931d1cfdaac24a624abdf5dcee52562b1f3e2a,4240
- dependent-map-0.4.0.0@sha256:ca2b131046f4340a1c35d138c5a003fe4a5be96b14efc26291ed35fd08c62221,1657
- dependent-sum-0.7.1.0@sha256:5599aa89637db434431b1dd3fa7c34bc3d565ee44f0519bfbc877be1927c2531,2068
- dependent-sum-template-0.1.0.3@sha256:0bbbacdfbd3abf2a15aaf0cf2c27e5bdd159b519441fec39e1e6f2f54424adde,1682
- constraints-extras-0.3.0.2@sha256:013b8d0392582c6ca068e226718a4fe8be8e22321cc0634f6115505bf377ad26,1853
- some-1.0.1@sha256:26e5bab7276f48b25ea8660d3fd1166c0f20fd497dac879a40f408e23211f93e,2055

package.yaml:

dependencies:
- base >= 4.7 && < 5
- amuletml

stack run on a new example project with these dependencies gives:

amuletml                         > Building executable 'amulet-lsp' for amuletml-1.0.0.0..
amuletml                         > [ 1 of 10] Compiling AmuletLsp.Features
amuletml                         > [ 2 of 10] Compiling AmuletLsp.Diagnostic
amuletml                         > [ 3 of 10] Compiling AmuletLsp.Features.Folding
amuletml                         > [ 4 of 10] Compiling AmuletLsp.Features.Outline
amuletml                         > [ 5 of 10] Compiling AmuletLsp.Features.TypeOverlay
amuletml                         > [ 6 of 10] Compiling AmuletLsp.NameyMT
amuletml                         > [ 7 of 10] Compiling AmuletLsp.Worker
amuletml                         > [ 8 of 10] Compiling AmuletLsp.Loop
amuletml                         > [ 9 of 10] Compiling Version
amuletml                         > [10 of 10] Compiling Main
amuletml                         > fatal: not a git repository (or any of the parent directories): .git
amuletml                         >
amuletml                         > bin\AmuletLsp.hs:26:20: error:
amuletml                         >     • Exception when trying to run compile-time code:
amuletml                         >         readCreateProcess: git "rev-parse" "--short" "@" (exit 128): failed
amuletml                         >       Code: amcVersion
amuletml                         >     • In the untyped splice: $(amcVersion)
amuletml                         >    |
amuletml                         > 26 |       = infoOption $(amcVersion)
amuletml                         >    |                    ^^^^^^^^^^^^^
amuletml                         >
Progress 93/94

--  While building package amuletml-1.0.0.0 (scroll up to its section to see the error) using:
      F:\Win\Stack\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_3.2.1.0_ghc-8.10.4.exe --builddir=.stack-work\dist\274b403a build --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

For more context: I'm attempting to use amuletml as a dependency because I want to parse a type definition file that looks like

type Module <- { name : string, on_load : () -> () }

and generate a C++ header that looks like

#pragma once

struct Module {
    std::string name;
    sol::protected_function on_load;
}

// ... etc methods for checking/getting/pushing Module on/from/to the Lua stack, also autogenerated

and I am guessing that using Haskell with Amulet as a dependency is the easiest way to accomplish this.

SquidDev commented 2 years ago

Hrrm, not sure what the correct behaviour here is. I guess we catch the error and use some "?" version instead.

s5bug commented 2 years ago
amuletml                         > Linking .stack-work\dist\274b403a\build\amc-prove\amc-prove.exe ...
amuletml                         > Preprocessing executable 'amulet-lsp' for amuletml-1.0.0.0..
amuletml                         > Building executable 'amulet-lsp' for amuletml-1.0.0.0..
amuletml                         > [ 1 of 10] Compiling AmuletLsp.Features
amuletml                         > [ 2 of 10] Compiling AmuletLsp.Diagnostic
amuletml                         > [ 3 of 10] Compiling AmuletLsp.Features.Folding
amuletml                         > [ 4 of 10] Compiling AmuletLsp.Features.Outline
amuletml                         > [ 5 of 10] Compiling AmuletLsp.Features.TypeOverlay
amuletml                         > [ 6 of 10] Compiling AmuletLsp.NameyMT
amuletml                         > [ 7 of 10] Compiling AmuletLsp.Worker
amuletml                         > [ 8 of 10] Compiling AmuletLsp.Loop
amuletml                         > [ 9 of 10] Compiling Version
amuletml                         > [10 of 10] Compiling Main
amuletml                         >
amuletml                         > <no location info>: error:
amuletml                         >     .git/logs/HEAD: openBinaryFile: does not exist (No such file or directory)
amuletml                         >
Progress 89/90

--  While building package amuletml-1.0.0.0 (scroll up to its section to see the error) using:
      F:\Win\Stack\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_3.2.1.0_ghc-8.10.4.exe --builddir=.stack-work\dist\274b403a build --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1
SquidDev commented 2 years ago

Ahh, dammit. It hadn't occurred to me that addDependentFile would need it to have the file exist.