aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-04-04 17:10:32 -0300
committerMarcos Magueta <maguetamarcos@gmail.com>2026-04-04 17:10:32 -0300
commitd3708bb28adcd0220142f1890ab96bfd2df637d3 (patch)
tree29da1e5e79c0481cb364bdc9d1da0147da0200fd
parent63ae3c930de89af6f85229a467caa3f53cb844a2 (diff)
downloadSakura-d3708bb28adcd0220142f1890ab96bfd2df637d3.tar.gz
Sakura-d3708bb28adcd0220142f1890ab96bfd2df637d3.zip
remove interop with c
-rw-r--r--.gitignore2
-rw-r--r--bin/main.ml2
-rw-r--r--flake.nix43
-rw-r--r--lib/conventions.ml6
-rw-r--r--lib/core_functions.ml23
-rw-r--r--lib/core_types.ml3
-rw-r--r--lib/dune30
-rw-r--r--lib/interop.ml11
-rw-r--r--test/test_relational_engine.ml2
9 files changed, 10 insertions, 112 deletions
diff --git a/.gitignore b/.gitignore
index 8f56c28..27f25b5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
_build
-.direnv
+.direnv/
# Nix build/link artifacts
result
diff --git a/bin/main.ml b/bin/main.ml
index c77d756..6b2a068 100644
--- a/bin/main.ml
+++ b/bin/main.ml
@@ -1,6 +1,6 @@
let main () =
let digest =
- Relational_engine.Interop.Sha256.compute_hash (Bytes.of_string "sakura")
+ Sha256.to_hex (Sha256.string "sakura")
in
print_endline digest
diff --git a/flake.nix b/flake.nix
index bee021b..ba5bad6 100644
--- a/flake.nix
+++ b/flake.nix
@@ -29,8 +29,6 @@
# Library functions from nixpkgs
lib = legacyPackages.lib;
ocamlPackages = legacyPackages.ocamlPackages;
- # merklecpp = legacyPackages.callPackage ./deps/merklecpp.nix { };
- libressl = legacyPackages.callPackage ./deps/libressl.nix { };
ppx_protocol_conv =
legacyPackages.callPackage ./deps/ppx_protocol_conv.nix {
lib = legacyPackages.lib;
@@ -42,11 +40,6 @@
ppx_protocol_conv = ppx_protocol_conv;
fetchFromGitHub = legacyPackages.fetchFromGitHub;
ocamlPackages = ocamlPackages; };
- librelational_engine =
- legacyPackages.callPackage ./deps/relational_engine_lib.nix {
- libressl = libressl;
- # merklecpp = merklecpp;
- };
# Filtered sources (prevents unecessary rebuilds)
sources = {
ocaml = nix-filter.lib {
@@ -86,23 +79,10 @@
duneVersion = "3";
src = sources.ocaml;
- env = {
- # MERKLECPP_INCLUDE_PATH = "${merklecpp}/include";
- LIBRESSL_INCLUDE_PATH = "${libressl}/include";
- LIBRESSL_LIB_PATH = "${libressl}/lib";
- OS_LIB_EXTENSION =
- if legacyPackages.stdenv.isDarwin then "dylib" else "so";
- LIBRELATIONAL_ENGINE_LIB_PATH = "${librelational_engine}/lib";
- LIBRELATIONAL_ENGINE_INCLUDE_PATH = "${librelational_engine}/include";
- };
-
- nativeInputs = [ ];
-
buildInputs = [ ppx_protocol_conv_xml_light
ppx_protocol_conv ]
++ (with ocamlPackages; [
- ctypes
- ctypes-foreign
+ sha
data-encoding
ppx_inline_test
ppx_deriving
@@ -236,16 +216,6 @@
devShells = {
default = legacyPackages.mkShell {
- env = {
- # MERKLECPP_INCLUDE_PATH = "${merklecpp}/include";
- LIBRESSL_INCLUDE_PATH = "${libressl}/include";
- LIBRESSL_LIB_PATH = "${libressl}/lib";
- OS_LIB_EXTENSION =
- if legacyPackages.stdenv.isDarwin then "dylib" else "so";
- LIBRELATIONAL_ENGINE_LIB_PATH = "${librelational_engine}/lib";
- LIBRELATIONAL_ENGINE_INCLUDE_PATH = "${librelational_engine}/include";
- };
-
# Development tools
packages = [
# Source file formatting
@@ -263,14 +233,11 @@
ocamlPackages.utop
# Libraries
# ocamlPackages.menhir
- ocamlPackages.ctypes
- ocamlPackages.ctypes-foreign
+ ocamlPackages.sha
ocamlPackages.data-encoding
ocamlPackages.ppx_inline_test
ocamlPackages.ppx_deriving
ocamlPackages.ppx_sexp_conv
- legacyPackages.cmake
- legacyPackages.gcc
# legacyPackages.nixfmt-classic
ocamlPackages.lwt
ocamlPackages.lwt-exit
@@ -288,12 +255,6 @@
shellHook = ''
export CAML_LD_LIBRARY_PATH="''${CAML_LD_LIBRARY_PATH:+$CAML_LD_LIBRARY_PATH:}$(ocamlfind query num)"
- # echo MERKLECPP_INCLUDE_PATH=$MERKLECPP_INCLUDE_PATH
- echo LIBRESSL_INCLUDE_PATH=$LIBRESSL_INCLUDE_PATH
- echo LIBRESSL_LIB_PATH=$LIBRESSL_LIB_PATH
- # echo OS_LIB_EXTENSION=$OS_LIB_EXTENSION
- echo LIBRELATIONAL_ENGINE_LIB_PATH=$LIBRELATIONAL_ENGINE_LIB_PATH
- echo LIBRELATIONAL_ENGINE_INCLUDE_PATH=$LIBRELATIONAL_ENGINE_INCLUDE_PATH
'';
# Tools from packages
diff --git a/lib/conventions.ml b/lib/conventions.ml
index b6f82a5..de04712 100644
--- a/lib/conventions.ml
+++ b/lib/conventions.ml
@@ -1,7 +1,7 @@
module Hash = struct
- type t = Interop.Sha256.t
+ type t = string
- let hash_text text = Interop.Sha256.compute_hash (Bytes.of_string text)
+ let hash_text text = Sha256.to_hex (Sha256.string text)
let compare = String.compare
let sexp_of_t = Sexplib.Std.sexp_of_string
end
@@ -25,7 +25,7 @@ end
module AbstractValue = struct
type t = Obj.t
- let hash (elem : t) = Interop.Sha256.compute_hash @@ Marshal.to_bytes elem []
+ let hash (elem : t) = Sha256.to_hex (Sha256.string (Bytes.to_string (Marshal.to_bytes elem [])))
let sexp_of_t (v : t) =
let open Sexplib.Sexp in
diff --git a/lib/core_functions.ml b/lib/core_functions.ml
deleted file mode 100644
index 9cb6213..0000000
--- a/lib/core_functions.ml
+++ /dev/null
@@ -1,23 +0,0 @@
-module Types = Types_generated
-
-module Functions (F : Ctypes.FOREIGN) = struct
- open Ctypes_static
-
- let os_extension =
- if Sys.os_type = "Unix" then
- let ic = Unix.open_process_in "uname" in
- let uname = input_line ic in
- let () = close_in ic in
- if uname = "Darwin" then "dylib" else "so"
- else "dll"
-
- let libmerklecpp =
- Dl.dlopen ~flags:[ RTLD_GLOBAL; RTLD_NOW ]
- ~filename:
- (Sys.getenv "LIBRELATIONAL_ENGINE_LIB_PATH"
- ^ "/librelational_engine." ^ os_extension)
-
- let compute_hash =
- Foreign.foreign ~from:libmerklecpp "compute_hash"
- (ptr char @-> Ctypes.string @-> returning void)
-end
diff --git a/lib/core_types.ml b/lib/core_types.ml
deleted file mode 100644
index 45f5720..0000000
--- a/lib/core_types.ml
+++ /dev/null
@@ -1,3 +0,0 @@
-module Types (F : Ctypes.TYPE) = struct
- let hash_size = F.constant "HASH_SIZE" F.int
-end
diff --git a/lib/dune b/lib/dune
index a6b503d..7833c8a 100644
--- a/lib/dune
+++ b/lib/dune
@@ -3,8 +3,7 @@
(library
(name relational_engine)
(libraries
- ctypes
- ctypes-foreign
+ sha
data-encoding
lwt
lwt.unix
@@ -13,29 +12,4 @@
ppx_protocol_conv_xml_light
sexplib)
(preprocess
- (pps ppx_deriving.show ppx_sexp_conv ppx_protocol_conv))
- ;; (c_library_flags -lssl -lcrypto -L %{env:LIBRESSL_LIB_PATH=})
- ;; (foreign_stubs
- ;; (language cxx)
- ;; (names merklecpp_stubs)
- ;; (flags
- ;; (:standard -lssl -lcrypto)
- ;; (-L %{env:LIBRESSL_LIB_PATH=})
- ;; (-I %{env:LIBRESSL_INCLUDE_PATH=})
- ;; (-I %{env:MERKLECPP_INCLUDE_PATH=})))
- (ctypes
- (external_library_name relational_engine)
- (headers
- (include %{env:LIBRELATIONAL_ENGINE_INCLUDE_PATH=}/library.h))
- (build_flags_resolver
- (vendored
- (c_flags -L %{env:LIBRELATIONAL_ENGINE_LIB_PATH=})))
- (type_description
- (instance Types)
- (functor core_types))
- (function_description
- (concurrency unlocked)
- (instance Functions)
- (functor core_functions))
- (generated_types Types_generated)
- (generated_entry_point C)))
+ (pps ppx_deriving.show ppx_sexp_conv ppx_protocol_conv)))
diff --git a/lib/interop.ml b/lib/interop.ml
deleted file mode 100644
index 8cbc05c..0000000
--- a/lib/interop.ml
+++ /dev/null
@@ -1,11 +0,0 @@
-open Ctypes
-
-module Sha256 = struct
- type t = string
-
- let compute_hash content : t =
- let size_with_null_terminator = C.Types.hash_size + 1 in
- let buf = Ctypes.allocate_n char ~count:size_with_null_terminator in
- let () = C.Functions.compute_hash buf (Bytes.to_string content) in
- Ctypes.coerce (ptr char) Ctypes.string buf
-end
diff --git a/test/test_relational_engine.ml b/test/test_relational_engine.ml
index 1d8f1ca..453cd9c 100644
--- a/test/test_relational_engine.ml
+++ b/test/test_relational_engine.ml
@@ -3480,7 +3480,7 @@ let%test_unit "merge: no-op when both sides are identical" =
= Management.Database.get_relation_names base_db))
(* Helper: look up polarity for a relation name in the result map *)
-let find_polarity name pols = Constraint.PolarityMap.find_opt name pols
+let find_polarity name pols = Constraint.polarity_find name pols
let%test_unit "polarity: MemberOf target is Positive" =
let c =