Skip to content

Commit

Permalink
ahlap
Browse files Browse the repository at this point in the history
  • Loading branch information
NilsIrl committed Aug 10, 2024
1 parent dbd1613 commit e1198df
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 21 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,20 @@ jobs:
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.13.0
- run: zig fmt --check .
- run: zig fmt --check .
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- uses: actions/setup-go@v5
with:
go-version: '1.22.6'
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.13.0
- run: sudo apt install autoconf libtool pkg-config make libzstd-dev libfuse3-dev
- run: zig build -Doptimize=ReleaseSafe -Dtarget=x86_64-linux-musl
- run: zig-out/bin/dockerc --image docker://hello-world --output enlo
- run: ./enlo
3 changes: 2 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
url = https://github.com/containers/skopeo.git
[submodule "crun"]
path = crun
url = https://github.com/containers/crun.git
url = https://github.com/NilsIrl/crun.git
branch = dockerc
[submodule "squashfs-tools"]
path = squashfs-tools
url = https://github.com/plougher/squashfs-tools.git
Expand Down
31 changes: 13 additions & 18 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn build(b: *std.Build) void {
fuse_fss.addIncludePath(b.path("zstd/lib"));

fuse_fss.addIncludePath(b.path("libfuse/include"));
fuse_fss.addIncludePath(b.path("libfuse/build"));
fuse_fss.addIncludePath(b.path("libfuse_include"));

fuse_fss.addCSourceFiles(.{
.files = &[_][]const u8{
Expand Down Expand Up @@ -137,6 +137,13 @@ pub fn build(b: *std.Build) void {
.target = target,
});

const cc = std.fmt.allocPrint(
b.allocator,
// TODO: find exact zig location
"zig cc --target={s}",
.{target.result.zigTriple(b.allocator) catch @panic("OOM")},
) catch @panic("OOM");

const squashfuse_autogen = b.addSystemCommand(&[_][]const u8{
"./autogen.sh",
});
Expand Down Expand Up @@ -172,21 +179,6 @@ pub fn build(b: *std.Build) void {
overlayfs_configure.setCwd(b.path("fuse-overlayfs"));
overlayfs_configure.step.dependOn(&overlayfs_autogen.step);

const libfuse_mkdir_build = b.addSystemCommand(&[_][]const u8{
"mkdir",
"-p",
"build",
});
libfuse_mkdir_build.setCwd(b.path("libfuse"));

const configure_libfuse = b.addSystemCommand(&[_][]const u8{
"meson",
"setup",
"..",
});
configure_libfuse.setCwd(b.path("libfuse/build"));
configure_libfuse.step.dependOn(&libfuse_mkdir_build.step);

const runtime = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.link_libc = true,
Expand All @@ -195,6 +187,7 @@ pub fn build(b: *std.Build) void {
runtime.addImport("zstd", zstd);
runtime.addImport("fuse-overlayfs", fuse_fss);

runtime.addIncludePath(b.path("crun_include"));
runtime.addIncludePath(b.path("crun"));
runtime.addIncludePath(b.path("crun/src"));
runtime.addIncludePath(b.path("crun/libocispec/src"));
Expand Down Expand Up @@ -297,6 +290,10 @@ pub fn build(b: *std.Build) void {
"--disable-caps",
"--disable-seccomp",
});
crun_configure.setEnvironmentVariable(
"CC",
cc,
);
crun_configure.setCwd(b.path("crun"));
crun_configure.step.dependOn(&crun_autogen.step);

Expand All @@ -320,12 +317,10 @@ pub fn build(b: *std.Build) void {
runtime_x86_64.step.dependOn(&squashfuse_make_generate_swap.step);
runtime_x86_64.step.dependOn(&overlayfs_configure.step);
runtime_x86_64.step.dependOn(&libocspec_generate_files.step);
runtime_x86_64.step.dependOn(&configure_libfuse.step);

runtime_aarch64.step.dependOn(&squashfuse_make_generate_swap.step);
runtime_aarch64.step.dependOn(&overlayfs_configure.step);
runtime_aarch64.step.dependOn(&libocspec_generate_files.step);
runtime_aarch64.step.dependOn(&configure_libfuse.step);
}

const go_cpu_arch = switch (target.query.cpu_arch orelse target.result.cpu.arch) {
Expand Down
3 changes: 3 additions & 0 deletions crun_include/git-version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#ifndef GIT_VERSION
# define GIT_VERSION "dockerc-hash"
#endif
44 changes: 44 additions & 0 deletions libfuse_include/fuse_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Autogenerated by the Meson build system.
* Do not edit, your changes will be lost.
*/

#pragma once

// not available in musl
// #define HAVE_BACKTRACE

#define HAVE_COPY_FILE_RANGE

#define HAVE_FALLOCATE

#define HAVE_FDATASYNC

#define HAVE_FORK

#define HAVE_FSTATAT

#define HAVE_ICONV

#define HAVE_OPENAT

#define HAVE_PIPE2

#define HAVE_POSIX_FALLOCATE

#define HAVE_READLINKAT

#define HAVE_SETXATTR

#define HAVE_SPLICE

#define HAVE_STRUCT_STAT_ST_ATIM

#undef HAVE_STRUCT_STAT_ST_ATIMESPEC

#define HAVE_UTIMENSAT

#define HAVE_VMSPLICE

#define PACKAGE_VERSION "3.17.0"

15 changes: 15 additions & 0 deletions libfuse_include/libfuse_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Autogenerated by the Meson build system.
* Do not edit, your changes will be lost.
*/

#pragma once

#define FUSE_HOTFIX_VERSION 0

#define FUSE_MAJOR_VERSION 3

#define FUSE_MINOR_VERSION 17

#define LIBFUSE_BUILT_WITH_VERSIONED_SYMBOLS 1

0 comments on commit e1198df

Please sign in to comment.