Papierkorb / qt5.cr

Qt5 bindings for Crystal, based on Bindgen
Mozilla Public License 2.0
211 stars 20 forks source link

crystal deps has been removed #13

Closed f-fr closed 4 years ago

f-fr commented 6 years ago

When trying to install the shard using shards install I get

Fetching https://github.com/Papierkorb/qt5.cr.git
Fetching https://github.com/Papierkorb/bindgen.git
Fetching https://github.com/Papierkorb/toka.git
Installing qt5 (0.1.0)
Installing bindgen (0.6.1)
Postinstall crystal deps
Failed crystal deps:
Please use 'shards': 'crystal deps' has been removed
Papierkorb commented 6 years ago

Oh hi, this is caused by bindgens shard.yml, its postinstall hook needs to be updated to reflect that change. Can you PR that over there?

f-fr commented 6 years ago

It seems as if shard.yml of qt5.cr also contains the lines

scripts:
 postinstall: crystal deps build

so should it be updated, too? Whats the “correct” fix, replace that line by “shards build”? (I'm pretty new to crystal/shards so I have no idea how this should work, sorry)

Papierkorb commented 6 years ago

Yeah that should work. You can verify by running shards build in the bindgen/ directory.

f-fr commented 6 years ago

It took me some time to even find the "bindgen/" directory, because shards seems to remove the directory immediately if the installation fails.

Anyway, I just cloned bindgen and ran shards build in that directory. It seems to do something but then stops with the following error message:

Fetching https://github.com/Papierkorb/toka.git
Installing toka (0.1.2)
Building: bindgen
Error target bindgen failed to compile:
Error in src/bindgen.cr:57: instantiating 'Bindgen::Tool:Class#new(String, Bindgen::Configuration, Bool)'

tool = Bindgen::Tool.new(File.dirname(config_path), config, opts.stats)
                     ^~~

in src/bindgen/tool.cr:34: instantiating 'Bindgen::Processor::Runner:Class#new(Bindgen::Configuration, Bindgen::TypeDatabase)'

      @processors = Processor::Runner.new(@config, @database)
                                      ^~~

in src/bindgen/processor/runner.cr:10: instance variable '@processors' of Bindgen::Processor::Runner must be Array(Bindgen::Processor::Base), not Array(Bindgen::Processor::AutoContainerInstantiation | Bindgen::Processor::CopyStructs | Bindgen::Processor::CppWrapper | Bindgen::Processor::CrystalBinding | Bindgen::Processor::CrystalWrapper | Bindgen::Processor::DefaultConstructor | Bindgen::Processor::DumpGraph | Bindgen::Processor::Enums | Bindgen::Processor::ExternC | Bindgen::Processor::FilterMethods | Bindgen::Processor::FunctionClass | Bindgen::Processor::Functions | Bindgen::Processor::Inheritance | Bindgen::Processor::InstantiateContainers | Bindgen::Processor::Macros | Bindgen::Processor::Qt | Bindgen::Processor::SanityCheck | Bindgen::Processor::VirtualOverride)

        @processors = config.processors.map do |name|
        ^~~~~~~~~~~

So now a little bit lost how to proceed. This is probably a different issue and I should file it in bindgens repo (right?), but should the "crystal deps" thing be fixed first?

Papierkorb commented 6 years ago

Both issues are bindgen issues in any case. That issue there is new, looks like the type inference algorithm of Crystal got stupider. The #map block starting in src/bindgen/processor/runner.cr:10 needs an .as(Processor::Base) appended to the last line of its body, so the expression that comes before its end (<- Edit). That should fix it.

I myself am not using Crystal currently, so recent changes in the language are beyond me.

RX14 commented 6 years ago

It's not related to type inference, see https://github.com/crystal-lang/crystal/pull/6024.

f-fr commented 6 years ago

@RX14 thanks, but should the following example work:

class Base
  def self.create : Base
    A.new
  end

end

class A < Base
end

class AnyOf < Base
  @children : Array(Base)

  def initialize
    @children = [Base.create]
  end
end

AnyOf.new

The declaration of Base.create states that the return type is Base not A, so why crystal assumes that the call to Base.create returns an A?

RX14 commented 6 years ago

Return type restrictions are not casts, they're constraints. self.create returns type A, but the return type restriction of Base doesn't error because A is a Base. You need to use A.new.as(Base).

https://carc.in/#/r/4e3d

f-fr commented 6 years ago

I see, interesting. That makes sense but might lead to surprising errors (in particular if using external shards or so). Anyway, thanks for the explanation.

PerrinHH commented 6 years ago

I just tried installing it myself (8-year Rubyist new to Crystal) using the steps described here, and it seems to me that this project needs URGENT re-compiliing and testing with the newest Crystal compiler, particularly the Bindgen stuff! I got an avalanche of cascading Type-related errors when I compiled it using crystal 0.25.1.

Thank you!

Papierkorb commented 6 years ago

@PerrinHH You're welcome to do so, I'm not interested in Crystal much anymore.

RX14 commented 6 years ago

@Papierkorb that's sad to hear, just lack of time?

PerrinHH commented 6 years ago

As for me, I tried.And I came to a point where the backtrace responded this:

in src/bindgen/crystal/format.cr:120: undefined method 'key?' for Hash(String, Int64)

Which means that this Hash does not respond to the key? method (which it should, according to documentation). Any ideas what I am supposed to do now? Thank you.

oprypin commented 6 years ago

No it doesn't

https://crystal-lang.org/api/0.25.1/Hash.html

It's has_key? now

PerrinHH commented 6 years ago

You're correct. The documentation I read referred do Crystal 0.24.2.

(Classical case for "Polish your glasses and read the small print.")

PerrinHH commented 6 years ago

UPDATE:

Took me a little to fix the bindgen compilation errors caused by the Crystal update to 0.25.1. But finally I got it. Bindgen compiles. Yeeeah!

Now: How can I link my private Bindgen update to qt5? Building qt5 still results in downloading the "old" bindgen sources that still produce this error:

Please use 'shards': 'crystal deps' has been removed

What can I do now? Since shards deletes all downloaded files on error, I'm really stuck. Please help. Thank you.

mamantoha commented 6 years ago

@PerrinHH, should be fixed in https://github.com/Papierkorb/qt5.cr/pull/14. Please check.

docelic commented 4 years ago

Closing this issue as both bindgen's and qt5.cr's commits for the reported problem have been merged. Bindgen now works with Crystal 0.34.0 and is at release v0.7.0. Qt5.cr is being updated/worked on - see https://github.com/Papierkorb/qt5.cr/issues/29.