From efd749d4f1c431e30cc792a603fd070d41b24fb1 Mon Sep 17 00:00:00 2001 From: Patrick Ferris Date: Mon, 7 Apr 2025 09:38:19 +0100 Subject: [PATCH] More static --- dune | 2 ++ opentrace.ml | 6 +++++- opentrace.opam | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dune b/dune index d7572d4..f6fff69 100644 --- a/dune +++ b/dune @@ -1,6 +1,8 @@ (executable (name opentrace) (public_name opentrace) + (preprocess (pps ppx_blob)) + (preprocessor_deps (file opentrace.bpf.o)) (libraries unix libbpf libbpf_maps)) (rule diff --git a/opentrace.ml b/opentrace.ml index 3f6038a..fe00954 100644 --- a/opentrace.ml +++ b/opentrace.ml @@ -2,6 +2,7 @@ open Libbpf open Libbpf_maps let obj_path = "opentrace.bpf.o" +let obj_file = [%blob "opentrace.bpf.o"] let program_names = [ @@ -55,6 +56,9 @@ module Open_event = struct end let () = + let dir = Filename.temp_dir "opentrace-" "" in + let full_obj_path = Filename.concat dir obj_path in + Out_channel.with_open_bin full_obj_path (fun oc -> Out_channel.output_string oc obj_file); let bpf_callback obj _links = (* Set signal handlers *) let exitting = ref true in @@ -83,4 +87,4 @@ let () = () done in - with_bpf_object_open_load_link ~obj_path ~program_names bpf_callback + with_bpf_object_open_load_link ~obj_path:full_obj_path ~program_names bpf_callback diff --git a/opentrace.opam b/opentrace.opam index fd500ef..3e53aae 100644 --- a/opentrace.opam +++ b/opentrace.opam @@ -10,6 +10,7 @@ depends: [ "ocaml" "libbpf" "libbpf_maps" + "ppx_blob" "odoc" {with-doc} ] build: [ -- 2.51.2