-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
155 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const std = @import("std"); | ||
|
||
pub fn build(b: *std.Build) void { | ||
const target = b.standardTargetOptions(.{}); | ||
const optimize = b.standardOptimizeOption(.{}); | ||
|
||
const rose = b.dependency("rose", .{ | ||
.target = target, | ||
.optimize = optimize, | ||
}); | ||
|
||
const librose = b.addSharedLibrary(.{ | ||
.name = "rose", | ||
.root_source_file = .{ .path = "src/root.zig" }, | ||
.target = target, | ||
.optimize = optimize, | ||
}); | ||
// TODO: Doesn't work. How do I depend? | ||
librose.linkLibrary(rose.artifact("rose")); | ||
b.installArtifact(librose); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.{ | ||
.name = "rose-ffi", | ||
.version = "0.5.0", | ||
.dependencies = .{ | ||
.rose = .{ | ||
.path = "../rose-zig", | ||
}, | ||
}, | ||
.paths = .{""}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ stdenv | ||
, zig | ||
, version | ||
, rose-zig | ||
}: | ||
|
||
stdenv.mkDerivation { | ||
pname = "rose-ffi"; | ||
version = version; | ||
src = ./.; | ||
nativeBuildInputs = [ zig.hook rose-zig ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.{ | ||
.name = "rose", | ||
.version = "0.5.0", | ||
.dependencies = .{ | ||
.sqlite = .{ | ||
.url = "https://github.com/vrischmann/zig-sqlite/archive/dc339b7cf3bca82a12c2169231dd247587766781.tar.gz", | ||
.hash = "1220e0961c135c5aa3af77a043dbc5890a18235a157238df0e2882fe84a8c8439c7a", | ||
}, | ||
}, | ||
.paths = .{""}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"1220e0961c135c5aa3af77a043dbc5890a18235a157238df0e2882fe84a8c8439c7a": { | ||
"name": "sqlite", | ||
"url": "https://github.com/vrischmann/zig-sqlite/archive/dc339b7cf3bca82a12c2169231dd247587766781.tar.gz", | ||
"hash": "sha256-PbWUedWBuNxA7diVAEh225b6YQA757aSvomQjUgSgRk=" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# generated by zon2nix (https://github.com/Cloudef/zig2nix) | ||
|
||
{ lib, linkFarm, fetchurl, fetchgit, runCommandLocal, zig, name ? "zig-packages" }: | ||
|
||
with builtins; | ||
with lib; | ||
|
||
let | ||
unpackZigArtifact = { name, artifact }: runCommandLocal name { | ||
nativeBuildInputs = [ zig ]; | ||
} '' | ||
hash="$(zig fetch --global-cache-dir "$TMPDIR" ${artifact})" | ||
mv "$TMPDIR/p/$hash" "$out" | ||
chmod 755 "$out" | ||
''; | ||
|
||
fetchZig = { name, url, hash }: let | ||
artifact = fetchurl { inherit url hash; }; | ||
in unpackZigArtifact { inherit name artifact; }; | ||
|
||
fetchGitZig = { name, url, hash }: let | ||
parts = splitString "#" url; | ||
base = elemAt parts 0; | ||
rev = elemAt parts 1; | ||
in fetchgit { | ||
inherit name rev hash; | ||
url = base; | ||
deepClone = false; | ||
}; | ||
|
||
fetchZigArtifact = { name, url, hash }: let | ||
parts = splitString "://" url; | ||
proto = elemAt parts 0; | ||
path = elemAt parts 1; | ||
fetcher = { | ||
"git+http" = fetchGitZig { inherit name hash; url = "http://${path}"; }; | ||
"git+https" = fetchGitZig { inherit name hash; url = "https://${path}"; }; | ||
http = fetchZig { inherit name hash; url = "http://${path}"; }; | ||
https = fetchZig { inherit name hash; url = "https://${path}"; }; | ||
file = unpackZigArtifact { inherit name; artifact = /. + path; }; | ||
}; | ||
in fetcher.${proto}; | ||
in linkFarm name [ | ||
{ | ||
name = "1220e0961c135c5aa3af77a043dbc5890a18235a157238df0e2882fe84a8c8439c7a"; | ||
path = fetchZigArtifact { | ||
name = "sqlite"; | ||
url = "https://github.com/vrischmann/zig-sqlite/archive/dc339b7cf3bca82a12c2169231dd247587766781.tar.gz"; | ||
hash = "sha256-PbWUedWBuNxA7diVAEh225b6YQA757aSvomQjUgSgRk="; | ||
}; | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const std = @import("std"); | ||
const sqlite = @import("sqlite"); | ||
const testing = std.testing; | ||
|
||
pub fn getRelease(allocator: std.mem.Allocator) ![:0]const u8 { | ||
return try allocator.dupeZ(u8, "hello"); | ||
} | ||
|
||
pub fn getTrack(allocator: std.mem.Allocator) void { | ||
const db = try sqlite.Db.init(.{ | ||
.mode = sqlite.Db.Mode{ .File = "/home/blissful/.cache/rose/cache.sqlite3" }, | ||
.open_flags = .{ | ||
.write = true, | ||
.create = true, | ||
}, | ||
.threading_mode = .MultiThread, | ||
}); | ||
_ = db; | ||
_ = allocator; | ||
} | ||
|
||
test "basic add functionality" { | ||
try testing.expect(std.mem.eql(u8, try getRelease(testing.allocator), "hello")); | ||
} |
This file was deleted.
Oops, something went wrong.