cenotelie / hime

Apache License 2.0
27 stars 4 forks source link

Probably wrong script variable or my mistake? #66

Closed aleksmelnikov closed 4 years ago

aleksmelnikov commented 4 years ago

Environment:

$ cd /tmp
$ git clone https://github.com/cenotelie/hime.git
$ git clone https://github.com/cenotelie/hime-grams.git
$ cd hime/
$ sh .releng/build.sh
$ sh .releng/release.sh
$ /tmp/hime/.releng/standalone/himecc /tmp/hime-grams/ebnf/EBNF.gram -t:rust -o:assembly
Cannot open assembly '/tmp/hime/.releng/standalone/net461/himecc.exe': No such file or directory.
$ find /tmp -name himecc.exe
/tmp/hime/himecc/obj/Release/net461/himecc.exe
/tmp/hime/himecc/obj/Release/net20/himecc.exe
/tmp/hime/himecc/bin/Release/net461/publish/himecc.exe
/tmp/hime/himecc/bin/Release/net461/himecc.exe
/tmp/hime/himecc/bin/Release/net20/publish/himecc.exe
/tmp/hime/himecc/bin/Release/net20/himecc.exe
$cat /tmp/hime/.releng/standalone/himecc
#!/bin/sh

# Copyright (c) 2017 Association Cénotélie (cenotelie.fr)
# Licensed under LGPLv3
#
# This frontend-script is used to run the himecc program with
# different .Net runtimes depending on the environment.

SCRIPT="$(readlink -f "$0")"
ROOT="$(dirname "$SCRIPT")"                             <-----------

# Try to run with Mono runtime
MONO=$(which mono)
if [ ! -z "$MONO" ]
then
  mono "$ROOT/net461/himecc.exe" $@               <-----------
  exit $?
fi

# Try to run with .Net Core runtime
CORE=$(which dotnet)
if [ ! -z "$CORE" ]
then
  (export HimeLocalNuget="$ROOT/nuget" ; dotnet "$ROOT/netcore20/himecc.dll" $@)
  exit $?
fi

echo "Failed to find a .Net runtime (either Mono or .Net Core)."
aleksmelnikov commented 4 years ago

If I try to run without shell script I get:

$mono /tmp/hime/himecc/bin/Release/net461/himecc.exe /tmp/hime-grams/ebnf/EBNF.gram -t:rust -o:assembly
[INFO] Hime.SDK 3.4.2.0
[INFO] Reading input /tmp/hime-grams/ebnf/EBNF.gram ...
[INFO] Loading grammar EBNF ...
[INFO] Preparing grammar EBNF ...
[INFO] Preparing EBNF lexer's data ...
[INFO] Preparing EBNF parser's data ...
[INFO] Exporting lexer data at EBNFLexer.bin ...
[INFO] Exporting lexer code at EBNF.rs ...
[INFO] Exporting parser data at EBNFParser.bin ...
[INFO] Exporting parser code at EBNF.rs ...
[INFO] Building assembly EBNF.crate ...
[INFO] Assembling into /tmp/8avfc7nt.q5b
[INFO] Executing command cargo build --release --manifest-path /tmp/8avfc7nt.q5b/Cargo.toml
    Updating crates.io index
error: failed to select a version for the requirement `hime_redist = "^3.4.2"`
  candidate versions found which didn't match: 3.4.1, 3.4.0, 3.3.2, ...
  location searched: crates.io index
required by package `hime_generated v3.4.2 (/tmp/8avfc7nt.q5b)`
[ERROR] System.IO.FileNotFoundException: Could not find file '/tmp/8avfc7nt.q5b/target/release/libhime_generated.so'.
File name: '/tmp/8avfc7nt.q5b/target/release/libhime_generated.so'
  at System.IO.File.Move (System.String sourceFileName, System.String destFileName) [0x0007c] in <a1ae6166591d4020b810288d19af38d4>:0
  at Hime.SDK.Output.EmitterForRust.EmitAssembly () [0x000ae] in <4aeeeb2d5b964f91970f8460654916f4>:0
  at Hime.SDK.Output.EmitterBase.Emit () [0x000b9] in <4aeeeb2d5b964f91970f8460654916f4>:0
  at Hime.SDK.CompilationTask.ExecuteDoEmitSingleUnit (Hime.SDK.Output.Unit unit) [0x00054] in <4aeeeb2d5b964f91970f8460654916f4>:0
  at Hime.SDK.CompilationTask.ExecuteDoEmit (System.Collections.Generic.List`1[T] units) [0x00011] in <4aeeeb2d5b964f91970f8460654916f4>:0
  at Hime.SDK.CompilationTask.ExecuteDo () [0x00054] in <4aeeeb2d5b964f91970f8460654916f4>:0
  at Hime.SDK.CompilationTask.Execute () [0x00000] in <4aeeeb2d5b964f91970f8460654916f4>:0
aleksmelnikov commented 4 years ago

Crates.io doesn't have hime_redist = "^3.4.2".

woutersl commented 4 years ago

There are multiple issues here.

First, the /tmp/hime/.releng/standalone/himecc bash script is designed to work only in the downloadable distribution. It is not designed to be used in the context of the repository. What you can do is what you did, i.e. directly invoke the built binary : /tmp/hime/himecc/bin/Release/net461/himecc.exe in your case.

Second, the last release of hime is 3.4.1, see https://github.com/cenotelie/hime/releases. 3.4.2 is a next version, it is not yet published. In the code base this is the version that appear. The easiest way to fix the version problem is to download and use himecc v3.4.1, the generated Rust code will depend on hime_redist 3.4.1 Rust package. If you want to use the repository version, there is a little trick that can be used to point to the local sources of the hime rust runtime: mono /tmp/hime/himecc/bin/Release/net461/himecc.exe /tmp/hime-grams/ebnf/EBNF.gram -t:rust /tmp/hime/runtime-rust -o:assembly The -t:rust option can actually take an optional argument that is the directory that contains the sources of the local runtime to use. This is most notably used in tests to point to the newest runtime. This relies on the patching mechanism of cargo for the resolution of dependencies.

aleksmelnikov commented 4 years ago

So I did:

  1. mono /tmp/hime/himecc/bin/Release/net461/himecc.exe /tmp/hime-grams/ebnf/EBNF.gram -t:rust /tmp/hime/runtime-rust -o:assembly
  2. cat /tmp/hime-grams/ebnf/sample.txt | ./target/release/parseit ./EBNF.so ebnf > sample.json.txt and I've got sample.json.txt (please see the attachment)

all right? sample.json.txt

woutersl commented 4 years ago

Yes, this looks fine.

aleksmelnikov commented 4 years ago

@woutersl , it's good. So, I can close the issue.