jhass / crystal-gobject

gobject-introspection for Crystal
BSD 3-Clause "New" or "Revised" License
127 stars 13 forks source link

LibGranite: unexpected token: NEWLINE #38

Closed aljelly closed 4 years ago

aljelly commented 4 years ago

If you manage to get past #37 and try to build something with require_gobject("Granite") included, it fails:

syntax error in /usr/lib/x86_64-linux-gnu/girepository-1.0/Granite-1.0.typelib/ServicesLogger:12
Error: unexpected token: NEWLINE

I don't know if this is due to my hacking around the array constant however.

aljelly commented 4 years ago

I updated to the latest version and I'm still getting the same error when trying to require Granite...

jhass commented 4 years ago

Just

require "gobject"
require_gobject "Granite"

?

jhass commented 4 years ago

IME sometimes shards gets stuck, so if you included this as a dependency into your project a rm -rf lib && shards might help after verifying the lock has the latest revision.

aljelly commented 4 years ago
$ crystal init app granitetest
    create  granitetest/.gitignore
    create  granitetest/.editorconfig
    create  granitetest/LICENSE
    create  granitetest/README.md
    create  granitetest/.travis.yml
    create  granitetest/shard.yml
    create  granitetest/src/granitetest.cr
    create  granitetest/spec/spec_helper.cr
    create  granitetest/spec/granitetest_spec.cr
Initialised empty Git repository in .../granitetest/.git/

$ cd granitetest

$ nano shard.yml

$ shards update
Fetching https://github.com/jhass/crystal-gobject.git
Installing gobject (0.2.0 at master)

$ nano src/granitetest.cr

$ cat src/granitetest.cr
require "gobject"
require_gobject "Granite"

$ shards build
Dependencies are satisfied
Building: granitetest
Error target granitetest failed to compile:
syntax error in /usr/lib/x86_64-linux-gnu/girepository-1.0/Granite-1.0.typelib/ServicesLogger:12
Error: unexpected token: NEWLINE
jhass commented 4 years ago

Doesn't reproduce for me :/

Can you run crystal lib/gobject/src/generator/build_namespace.cr -- Granite > granite.cr and gist the resulting file?

aljelly commented 4 years ago

Gist (granite.cr)

jhass commented 4 years ago

Super weird... can you show the shard.lock please?

aljelly commented 4 years ago

Never mind, I fixed it. It was a silly little mistake. I forgot to install libgranite-dev. I assumed for some reason I had already installed it previously along with the other *-dev packages necessary.

I discovered it just now while trying to find system information to give you to help narrow it down, and I thought I'd give you the version of libgranite-dev that apt reported was installed... and then I found it wasn't installed.

It's building now. Thank you!

jhass commented 4 years ago

Ok, glad it works for you! Weird that would just generate wrongly with it though, I would expect it to completely fail to generate (lack of gir file).