logos-storage-proofs/codex_storage_proofs.nim

39 lines
971 B
Nim
Raw Normal View History

Feature/msgpack argument passing (#9) * adding rmpv crate * plumb in msgpack * setting up mpack basics * setting up mpack basics * setting up mpack basics * setting up mpack basics * updates * chunks * chunks * chunks * add mpack proof func * add mpack proof func - tests infra * add mpack proof func - tests infra remove * add mpack proof func - split mpack * rework funcs * rework funcs * rework funcs * rework funcs * rework funcs * rework funcs * refactor * refactor * refactor * refactor * refactor * refactor * refactor * refactor * refactor - read orig for testing * refactor - read orig for testing * setting up tests * setting up tests * setting up tests * setting up tests * setting rest of data * setting rest of data * setting rest of data * setting rest of data * re-add original prove for comparison * re-add original prove for comparison * re-add original prove for comparison * cleanup * refactor * refactor * pass tests * initial setup to build as a nim package * initial setup * update build setup * update build setup * update build setup * add nim ffi and genffi build task * add nim ffi and genffi build task * add nim ffi and genffi build task * update init to remove redundant pointers * update init to remove redundant pointers * update init to remove redundant pointers * update init to remove redundant pointers * save mpack * save mpack * update ffi * update ffi * add example ffi test * add example ffi test * updates * fix tests * adding git ignore * rename * run testament * fix stuffs * fix stuffs * fix stuffs * update build * update build
2024-01-17 22:04:47 +02:00
import std/os
import std/strutils
import std/macros
const
currentDir = currentSourcePath().parentDir()
libDir* = currentDir/"target"/"release"
libPath* = libDir/"libcodex_storage_proofs.a"
static:
let cmd = "cargo build --release"
warning "\nBuilding codex-storage-proofs: " & cmd
let (output, exitCode) = gorgeEx cmd
for ln in output.splitLines():
warning("cargo> " & ln)
if exitCode != 0:
raise (ref Defect)(msg: "Failed to build codex-storage-proofs")
{.passl: "-lcodex_storage_proofs" & " -L" & libDir.}
include codex_proofs_ffi
proc len*(buff: Buffer): int =
buff.len.int
template unsafeBufferPath*(path: var string): Buffer =
assert path.len() > 0
Buffer(data: cast[ptr uint8](path.cstring),
len: path.len().uint)
template unsafeBufferFromFile*(path: string): Buffer =
assert path.len() > 0
let entireFile = readFile(path)
Buffer(data: cast[ptr uint8](entireFile.cstring),
len: entireFile.len().uint)