fix(qr): Crystal use C FFI instead of qr-code shard
Crystal shards pre-cached during build aren't available for
single-file execution. Use @[Link("qrencode")] FFI instead.
This commit is contained in:
parent
edfe6dc865
commit
bd91337584
1 changed files with 18 additions and 4 deletions
22
test/qr.cr
22
test/qr.cr
|
|
@ -1,5 +1,19 @@
|
|||
require "qr-code"
|
||||
@[Link("qrencode")]
|
||||
lib LibQRencode
|
||||
struct QRcode
|
||||
version : LibC::Int
|
||||
width : LibC::Int
|
||||
data : UInt8*
|
||||
end
|
||||
|
||||
qr = QRCode.new("unsandbox-qr-ok")
|
||||
rows = qr.modules.size
|
||||
puts "QR:unsandbox-qr-ok:ROWS:#{rows}"
|
||||
fun QRcode_encodeString(s : LibC::Char*, version : LibC::Int, level : LibC::Int, hint : LibC::Int, casesensitive : LibC::Int) : QRcode*
|
||||
fun QRcode_free(qr : QRcode*)
|
||||
end
|
||||
|
||||
qr = LibQRencode.QRcode_encodeString("unsandbox-qr-ok", 0, 1, 2, 1)
|
||||
if qr.null?
|
||||
puts "QR encode failed"
|
||||
exit 1
|
||||
end
|
||||
puts "QR:unsandbox-qr-ok:ROWS:#{qr.value.width}"
|
||||
LibQRencode.QRcode_free(qr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue