aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-08-19 14:13:06 +0200
committerdec05eba <dec05eba@protonmail.com>2023-08-19 14:13:06 +0200
commit908d2ba2bc4a2c7f18e22df26cda8b619725e853 (patch)
tree431f840a0df524b33b5c721c69b69e6759cb0190
Initial commit
-rw-r--r--.gitignore2
-rw-r--r--.gitmodules3
-rw-r--r--LICENSE19
-rw-r--r--README.md1
-rw-r--r--build.zig50
m---------depends/html-search0
-rw-r--r--src/c.zig3
-rw-r--r--src/main.zig5
8 files changed, 83 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e73c965
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+zig-cache/
+zig-out/
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..71d4348
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "depends/html-search"]
+ path = depends/html-search
+ url = https://repo.dec05eba.com/html-search
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..bc8b574
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) dec05eba
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..6d58581
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
+Example of using [html-search](https://git.dec05eba.com/html-search/about/) in zig
diff --git a/build.zig b/build.zig
new file mode 100644
index 0000000..301212c
--- /dev/null
+++ b/build.zig
@@ -0,0 +1,50 @@
+const std = @import("std");
+
+pub fn build(b: *std.Build) void {
+ const target = b.standardTargetOptions(.{});
+ const optimize = b.standardOptimizeOption(.{});
+
+ const exe = b.addExecutable(.{
+ .name = "html-search-zig-example",
+ .root_source_file = .{ .path = "src/main.zig" },
+ .target = target,
+ .optimize = optimize,
+ });
+
+ const libHtmlTree = buildHtmlSearch(b, &target, optimize);
+ exe.linkLibrary(libHtmlTree);
+ exe.linkLibC();
+ exe.addIncludePath(.{ .path = "depends/html-search/depends/html-parser/include" });
+ exe.addIncludePath(.{ .path = "depends/html-search/include" });
+
+ b.installArtifact(exe);
+
+ const run_cmd = b.addRunArtifact(exe);
+ run_cmd.step.dependOn(b.getInstallStep());
+ if (b.args) |args| {
+ run_cmd.addArgs(args);
+ }
+
+ const run_step = b.step("run", "Run the app");
+ run_step.dependOn(&run_cmd.step);
+}
+
+fn buildHtmlSearch(b: *std.Build, target: *const std.zig.CrossTarget, optimize: std.builtin.OptimizeMode) *std.Build.Step.Compile {
+ const lib = b.addStaticLibrary(.{
+ .name = "html-search",
+ .target = target.*,
+ .optimize = optimize,
+ });
+
+ lib.addCSourceFiles(&.{
+ "depends/html-search/depends/html-parser/src/HtmlParser.c",
+ "depends/html-search/src/HtmlSearch.c",
+ "depends/html-search/src/XpathTokenizer.c",
+ "depends/html-search/src/XpathParser.c",
+ "depends/html-search/src/NodeSearch.c",
+ }, &.{});
+
+ lib.addIncludePath(.{ .path = "depends/html-search/depends/html-parser/include" });
+ lib.linkLibC();
+ return lib;
+} \ No newline at end of file
diff --git a/depends/html-search b/depends/html-search
new file mode 160000
+Subproject 68989816f43ceda8655c2dbdc0d581971e645fc
diff --git a/src/c.zig b/src/c.zig
new file mode 100644
index 0000000..d4d1414
--- /dev/null
+++ b/src/c.zig
@@ -0,0 +1,3 @@
+pub usingnamespace @cImport({
+ @cInclude("HtmlSearch.h");
+}); \ No newline at end of file
diff --git a/src/main.zig b/src/main.zig
new file mode 100644
index 0000000..050e335
--- /dev/null
+++ b/src/main.zig
@@ -0,0 +1,5 @@
+const std = @import("std");
+
+pub fn main() !void {
+
+} \ No newline at end of file