Skip to content

Conversation

@mejedi
Copy link
Contributor

@mejedi mejedi commented Jul 10, 2024

Extract imports from "bpf2go.hfiles.go" in the output dir, scan packages for header files, and expose headers to clang. C code consumes headers by providing a go package path in include directive, e.g.

bpf2go.hfiles.go:
  package awesome
  import (
    _ "example.org/foo"
  )

frob.c:
  #include "example.org/foo/foo.h"

It is handy for sharing code between multiple ebpf blobs within a project. Even better, it enables sharing ebpf code between multiple projects using go modules as delivery vehicle.

By listing build dependencies in a .go file, we ensure that they are properly reflected in go.mod.

@mejedi mejedi requested a review from lmb July 10, 2024 09:32
@mejedi mejedi force-pushed the bpf2go-ebpf-code-reuse-v2 branch 2 times, most recently from 1576cb6 to c27e4b3 Compare October 29, 2024 19:14
@mejedi mejedi changed the title bpf2go: enable ebpf code reuse across go packages (WIP) bpf2go: enable ebpf code reuse across go packages Oct 29, 2024
@mejedi mejedi marked this pull request as ready for review October 29, 2024 19:49
@mejedi mejedi force-pushed the bpf2go-ebpf-code-reuse-v2 branch from c27e4b3 to 3d563d4 Compare October 29, 2024 19:53
Extract imports from "bpf2go.hfiles.go" in the output dir, scan packages
for header files, and expose headers to clang. C code consumes headers
by providing a go package path in include directive, e.g.

bpf2go.hfiles.go:
  package awesome
  import (
    _ "example.org/foo"
  )

frob.c:
  #include "example.org/foo/foo.h"

It is handy for sharing code between multiple ebpf blobs withing a
project. Even better, it enables sharing ebpf code between multiple
projects using go modules as delivery vehicle.

By listing build dependencies in a .go file, we ensure that they are
properly reflected in go.mod.

Signed-off-by: Nick Zavaritsky <[email protected]>
@mejedi mejedi force-pushed the bpf2go-ebpf-code-reuse-v2 branch from 3d563d4 to 2d46635 Compare October 29, 2024 20:10
@mejedi
Copy link
Contributor Author

mejedi commented Dec 12, 2024

Superseded by #1625

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants