From 49e7b9de5ddf66d2d28e5af2884973c3be050095 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Wed, 12 Jan 2022 18:18:23 +0100 Subject: [PATCH] Added linking of libarchive to Makefile --- .gitignore | 3 +++ Makefile | 33 +++++++++++++++++++++++++-------- vieter/repo.v | 4 ++++ 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 8d15c59e..b96b80c2 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ vieter/vieter *.pkg* vieter.log + +# External lib; gets added by Makefile +libarchive-* diff --git a/Makefile b/Makefile index a48a802f..0f1db9dd 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,22 @@ +# =====CONFIG===== +LARCHIVE_VER := 3.5.2 +LARCHIVE_DIR := libarchive-$(LARCHIVE_VER) +LARCHIVE_LIB := $(LARCHIVE_DIR)/.libs/libarchive.a + +# Custom V command for linking libarchive +V := LD_FLAGS=$(PWD)/$(LARCHIVE_LIB) v -cflags -I$(PWD)/$(LARCHIVE_DIR) + +# Run the server in the default 'data' directory .PHONY: run -run: - API_KEY=test REPO_DIR=data LOG_LEVEL=DEBUG v -cg run vieter - -.PHONY: run-prod -run-prod: - API_KEY=test REPO_DIR=data LOG_LEVEL=DEBUG v -prod run vieter +run: libarchive + API_KEY=test REPO_DIR=data LOG_LEVEL=DEBUG $(V) run vieter +# Same as run, but restart when the source code changes .PHONY: watch -watch: - API_KEY=test REPO_DIR=data LOG_LEVEL=DEBUG v watch run vieter +watch: libarchive + API_KEY=test REPO_DIR=data LOG_LEVEL=DEBUG $(V) watch run vieter +# Format the V codebase .PHONY: fmt fmt: v fmt -w vieter @@ -23,3 +30,13 @@ customv: --single-branch \ https://github.com/ChewingBever/v jjr-v '$(MAKE)' -C jjr-v + +.PHONY: libarchive +libarchive: $(LARCHIVE_LIB) +$(LARCHIVE_LIB): + curl -o - "https://libarchive.org/downloads/libarchive-${LARCHIVE_VER}.tar.gz" | tar xzf - + cd "libarchive-${LARCHIVE_VER}" && ./configure --disable-bsdtar --disable-bsdcpio + '$(MAKE)' -C "libarchive-${LARCHIVE_VER}" + +clean: + rm -rf '$(LARCHIVE_DIR)' 'data' diff --git a/vieter/repo.v b/vieter/repo.v index 6b307e89..c7e52bfd 100644 --- a/vieter/repo.v +++ b/vieter/repo.v @@ -2,6 +2,10 @@ module repo import os +#include "libarchive/archive.h" + +struct C.archive {} + const pkgs_subpath = 'pkgs' // Dummy struct to work around the fact that you can only share structs, maps &