datum-lang / scie

基于正则表达式的通用语言转换器。An interpreter for grammar files as defined by TextMate with Rust
MIT License
29 stars 7 forks source link

Fail to build #3

Closed cyw3 closed 3 years ago

cyw3 commented 3 years ago

When I run just tests:

> just tests
cargo test --all
   Compiling scie-onig v0.1.0 (/Users/xxx/scie/scie-onig)
error: failed to run custom build command for `scie-onig v0.1.0 (/Users/xxx/scie/scie-onig)`

Caused by:
  process didn't exit successfully: `/Users/xxx/scie/target/debug/build/scie-onig-7c8bf481eed54f4b/build-script-build` (exit code: 101)
  --- stderr
  libonigvs/onigvs.c:8:10: fatal error: 'oniguruma/src/oniguruma.h' file not found
  libonigvs/onigvs.c:8:10: fatal error: 'oniguruma/src/oniguruma.h' file not found, err: true
  thread 'main' panicked at 'bindgen: ()', scie-onig/build.rs:245:39
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: Recipe `tests` failed on line 2 with exit code 101
phodal commented 3 years ago

需要 初始化一下 submodule

cyw3 commented 3 years ago

需要 初始化一下 submodule

第一个问题解决了。不过出现了另外的问题:


test scanner::utf_string::tests::should_convert_utf_string_success ... ok
test scanner::utf_string::tests::should_handle_normal_string ... ok
test scanner::scie_scanner::tests::should_handle_unicode1 ... FAILED

failures:

---- scanner::scie_scanner::tests::should_handle_unicode1 stdout ----
thread 'scanner::scie_scanner::tests::should_handle_unicode1' panicked at 'assertion failed: `(left == right)`
  left: `"{\"index\":1,\"capture_indices\":[{\"start\":4,\"end\":5,\"length\":1}]}"`,
 right: `"{\"index\":1,\"capture_indices\":[{\"start\":6,\"end\":7,\"length\":1}]}"`', scie-scanner/src/scanner/scie_scanner.rs:219:9
stack backtrace:
   0:        0x102bdd324 - std::backtrace_rs::backtrace::libunwind::trace::h6df1416181381e81
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/../../backtrace/src/backtrace/libunwind.rs:96
   1:        0x102bdd324 - std::backtrace_rs::backtrace::trace_unsynchronized::h792524067a83cded
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/../../backtrace/src/backtrace/mod.rs:66
   2:        0x102bdd324 - std::sys_common::backtrace::_print_fmt::he614892186429f3f
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:79
   3:        0x102bdd324 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hcfc48256a5ab8835
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:58
   4:        0x102bfcf70 - core::fmt::write::haf3903118f694c48
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/fmt/mod.rs:1080
   5:        0x102abd70a - std::io::Write::write_fmt::h15aa2f50e681f5ef
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/io/mod.rs:1516
   6:        0x102bd7678 - std::io::impls::<impl std::io::Write for alloc::boxed::Box<W>>::write_fmt::h60f8c617b1dd6b36
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/io/impls.rs:179
   7:        0x102bdeedf - std::sys_common::backtrace::_print::ha64a9740ea6183e6
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:61
   8:        0x102bdeedf - std::sys_common::backtrace::print::h1fad353b070e1eef
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:48
   9:        0x102bdeedf - std::panicking::default_hook::{{closure}}::h91bd4c58cf71392b
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:208
  10:        0x102bdeb5e - std::panicking::default_hook::h7bd29c87df967048
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:224
  11:        0x102bdf61b - std::panicking::rust_panic_with_hook::hae2b05f08a320721
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:577
  12:        0x102bdf16b - std::panicking::begin_panic_handler::{{closure}}::h72d68d3a77e0b718
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:484
  13:        0x102bdd798 - std::sys_common::backtrace::__rust_end_short_backtrace::h7c5e286792f94edb
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:153
  14:        0x102bdf12a - rust_begin_unwind
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:483
  15:        0x102bdf0db - std::panicking::begin_panic_fmt::h6826a3ebe3a95a51
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:437
  16:        0x102a9856e - scie_scanner::scanner::scie_scanner::tests::should_handle_unicode1::h2b4005173c8a0b3c
                               at /Users/xxx/Applications/gitSpace/scie/scie-scanner/src/scanner/scie_scanner.rs:219
  17:        0x102aa87e1 - scie_scanner::scanner::scie_scanner::tests::should_handle_unicode1::{{closure}}::hd2d2513f9dd8619c
                               at /Users/xxx/Applications/gitSpace/scie/scie-scanner/src/scanner/scie_scanner.rs:214
  18:        0x102ab1641 - core::ops::function::FnOnce::call_once::he31af764654bc987
                               at /Users/xxx/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:227
  19:        0x102ae394a - core::ops::function::FnOnce::call_once::h8a5d8c592178429e
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/ops/function.rs:227
  20:        0x102ae394a - test::__rust_begin_short_backtrace::h8c20647892dadc50
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/test/src/lib.rs:516
  21:        0x102ae20f1 - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h8df67f0990a35131
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/alloc/src/boxed.rs:1042
  22:        0x102ae20f1 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::hf09671a739eb25fc
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panic.rs:308
  23:        0x102ae20f1 - std::panicking::try::do_call::hf1dc9cac489107de
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:381
  24:        0x102ae20f1 - std::panicking::try::h9599bce4aaa8bbbf
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:345
  25:        0x102ae20f1 - std::panic::catch_unwind::h203582ef7b5c1ee7
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panic.rs:382
  26:        0x102ae20f1 - test::run_test_in_process::h8ad05dbe22ef66ba
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/test/src/lib.rs:543
  27:        0x102ae20f1 - test::run_test::run_test_inner::{{closure}}::hadc7a51fce6724fe
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/test/src/lib.rs:449
  28:        0x102abcb4b - std::sys_common::backtrace::__rust_begin_short_backtrace::h6e10ee62b301fe5a
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:137
  29:        0x102ac1da5 - std::thread::Builder::spawn_unchecked::{{closure}}::{{closure}}::hada0c711499bf9bc
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/thread/mod.rs:464
  30:        0x102ac1da5 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h6e54792f2e5b9eeb
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panic.rs:308
  31:        0x102ac1da5 - std::panicking::try::do_call::h78edcf08bb257583
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:381
  32:        0x102ac1da5 - std::panicking::try::h76bc625add9266eb
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:345
  33:        0x102ac1da5 - std::panic::catch_unwind::h0b51b751ac0aff59
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panic.rs:382
  34:        0x102ac1da5 - std::thread::Builder::spawn_unchecked::{{closure}}::h9f08b0d941a32467
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/thread/mod.rs:463
  35:        0x102ac1da5 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h48bb72bd4d1e4e41
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/ops/function.rs:227
  36:        0x102be581d - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h761c0c24cc66dea8
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/alloc/src/boxed.rs:1042
  37:        0x102be581d - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h15cdc23ec4ed7bf4
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/alloc/src/boxed.rs:1042
  38:        0x102be581d - std::sys::unix::thread::Thread::new::thread_start::he3e6719579180a65
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys/unix/thread.rs:87
  39:     0x7fff727bd33d - __pthread_body
  40:     0x7fff727c02a7 - __pthread_start

failures:
    scanner::scie_scanner::tests::should_handle_unicode1

test result: FAILED. 18 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out

error: test failed, to rerun pass '-p scie_scanner --lib'
error: Recipe `tests` failed on line 2 with exit code 101
phodal commented 3 years ago

嗯,这个就是 README 里的 issue,随机 crash。应该是 FFI 的时候出了问题

cyw3 commented 3 years ago

嗯,这个就是 README 里的 issue,随机 crash。应该是 FFI 的时候出了问题

确实,重新执行之后,又可以了。感谢解答!

cyw3 commented 3 years ago

执行scie-cli失败,看起来是找不到对应的import


> cd scie-cli/
> cargo run  -- -h
   Compiling scie_scanner v0.1.0 (/Users/xxx/Applications/gitSpace/scie/scie-scanner)
error[E0432]: unresolved imports `scie_onig::createOnigScanner`, `scie_onig::findNextOnigScannerMatch`, `scie_onig::freeOnigScanner`, `scie_onig::OnigScanner`, `scie_onig::MAX_REGIONS`
 --> scie-scanner/src/scanner/scie_scanner.rs:4:5
  |
4 |     createOnigScanner, findNextOnigScannerMatch, freeOnigScanner, OnigScanner, MAX_REGIONS,
  |     ^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^  ^^^^^^^^^^^  ^^^^^^^^^^^ no `MAX_REGIONS` in the root
  |     |                  |                         |                |
  |     |                  |                         |                no `OnigScanner` in the root
  |     |                  |                         no `freeOnigScanner` in the root
  |     |                  no `findNextOnigScannerMatch` in the root
  |     no `createOnigScanner` in the root

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.
error: could not compile `scie_scanner`

To learn more, run the command again with --verbose.
phodal commented 3 years ago

看上去应该是 FFI 有问题。Scie_onig 是个 FFI,你去 scie_onig build 一下试试

cyw3 commented 3 years ago
> cargo build
   Compiling libc v0.2.81
   Compiling proc-macro2 v1.0.24
   Compiling quote v1.0.7
   Compiling atty v0.2.14
   Compiling which v3.1.1
   Compiling clang-sys v1.0.3
   Compiling env_logger v0.7.1
   Compiling clap v2.33.3
   Compiling bindgen v0.55.1
   Compiling scie-onig v0.1.0 (/Users/xxx/Applications/gitSpace/scie/scie-onig)
warning: `extern` block uses type `u128`, which is not FFI-safe
    --> /Users/xxx/Applications/gitSpace/scie/target/debug/build/scie-onig-ebf2a40fb3f450e6/out/bindings.rs:2435:10
     |
2435 |     ) -> u128;
     |          ^^^^ not FFI-safe
     |
     = note: `#[warn(improper_ctypes)]` on by default
     = note: 128-bit integers don't currently have a known stable ABI

warning: 1 warning emitted

    Finished dev [unoptimized + debuginfo] target(s) in 24.95s

看起来成功,但是执行就会出现上面error

phodal commented 3 years ago

那应该是成功了。这个 error 是 FFI 自动生成 的,暂时解决不了

cyw3 commented 3 years ago

您那边可以release一个版本吗?这边想先看下功能

phodal commented 3 years ago

不稳定的版本,等稳定了再 release,你先试试这个 scie-cli.zip

cyw3 commented 3 years ago

好的,感谢

cyw3 commented 3 years ago

执行scie-cli失败,看起来是找不到对应的import


> cd scie-cli/
> cargo run  -- -h
   Compiling scie_scanner v0.1.0 (/Users/xxx/Applications/gitSpace/scie/scie-scanner)
error[E0432]: unresolved imports `scie_onig::createOnigScanner`, `scie_onig::findNextOnigScannerMatch`, `scie_onig::freeOnigScanner`, `scie_onig::OnigScanner`, `scie_onig::MAX_REGIONS`
 --> scie-scanner/src/scanner/scie_scanner.rs:4:5
  |
4 |     createOnigScanner, findNextOnigScannerMatch, freeOnigScanner, OnigScanner, MAX_REGIONS,
  |     ^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^  ^^^^^^^^^^^  ^^^^^^^^^^^ no `MAX_REGIONS` in the root
  |     |                  |                         |                |
  |     |                  |                         |                no `OnigScanner` in the root
  |     |                  |                         no `freeOnigScanner` in the root
  |     |                  no `findNextOnigScannerMatch` in the root
  |     no `createOnigScanner` in the root

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.
error: could not compile `scie_scanner`

To learn more, run the command again with --verbose.

scie-onig的README里面有这一句 bindgen libonigvs/src/oniguruma.h --with-derive-eq --no-layout-tests --distrust-clang-mangling > src/ffi.rs

但是没有对应位置的文件,只有libonigvs/oniguruma/src/oniguruma.h,而 scie_scanner中import不到的函数createOnigScanner, findNextOnigScannerMatch, freeOnigScanner, OnigScanner, MAX_REGIONS也不在libonigvs/oniguruma/src/oniguruma.h中,只在libonigvs/onigvs.c中找到对应的定义。

然后我修改这行命令为 bindgen libonigvs/onigvs.c --with-derive-eq --no-layout-tests --distrust-clang-mangling > src/ffi.rs 并执行后,scie-cli编译成功了,并运行成功了。

另外,您刚才提供的版本,执行时候有报错:

> ./scie-cli -p examples/java/
Using input file: examples/java/
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { depth: 0, inner: Io { path: Some("/Users/fdhuang/charj/scie/extensions"), err: Os { code: 2, kind: NotFound, message: "No such file or directory" } } }', scie-bingen/src/ext_file.rs:13:31
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
phodal commented 3 years ago

来个 PR ?

cyw3 commented 3 years ago

好的