From 05e725eb4e59e3a78872c188c99e5b416f241c30 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Wed, 12 Jan 2022 20:54:54 +0100 Subject: [PATCH] Still trying to just link some stuff bro --- .gitignore | 4 ++-- Makefile | 32 +++++++++++++++++++------------- src/archive.v | 20 ++++++++++++++++++++ {vieter => src}/auth.v | 0 {vieter => src}/main.v | 2 ++ {vieter => src}/repo.v | 0 {vieter => src}/routes.v | 0 {vieter => src}/web/logging.v | 0 {vieter => src}/web/parse.v | 0 {vieter => src}/web/web.v | 0 vieter/archive.v | 13 ------------- 11 files changed, 43 insertions(+), 28 deletions(-) create mode 100644 src/archive.v rename {vieter => src}/auth.v (100%) rename {vieter => src}/main.v (98%) rename {vieter => src}/repo.v (100%) rename {vieter => src}/routes.v (100%) rename {vieter => src}/web/logging.v (100%) rename {vieter => src}/web/parse.v (100%) rename {vieter => src}/web/web.v (100%) delete mode 100644 vieter/archive.v diff --git a/.gitignore b/.gitignore index cd150cdd..be17f6b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ *.c data/ -vieter.exe -vieter-prod.exe +vieter +vieter-prod # Ignore testing files *.pkg* diff --git a/Makefile b/Makefile index 5c6f8da0..137c52b0 100644 --- a/Makefile +++ b/Makefile @@ -1,31 +1,37 @@ # =====CONFIG===== +SRC_DIR := src +SOURCES != find '$(SRC_DIR)' -iname '*.v' + LARCHIVE_VER := 3.5.2 LARCHIVE_DIR := libarchive-$(LARCHIVE_VER) -LARCHIVE_LIB := $(LARCHIVE_DIR)/.libs/libarchive.a +LARCHIVE_LIB := $(LARCHIVE_DIR)/libarchive/libarchive.so # Custom V command for linking libarchive -V := LDFLAGS=$(PWD)/$(LARCHIVE_LIB) v -cflags -I$(PWD)/$(LARCHIVE_DIR) +# V := LDFLAGS=$(PWD)/$(LARCHIVE_LIB) v -cflags '-I$(PWD)/$(LARCHIVE_DIR) -I $(PWD)/$(LARCHIVE_DIR)' +V := v # =====COMPILATION===== -.PHONY: vieter -vieter: - $(V) -cg -o vieter.exe vieter +.PHONY: debug +debug: vieter +vieter: $(SOURCES) + $(V) -cg -o vieter $(SRC_DIR) .PHONY: prod -prod: - $(V) -o vieter-prod.exe -prod vieter +prod: vieter-prod +vieter-prod: $(SOURCES) + $(V) -o vieter-prod -prod $(SRC_DIR) # =====EXECUTION===== # Run the server in the default 'data' directory .PHONY: run -run: libarchive - API_KEY=test REPO_DIR=data LOG_LEVEL=DEBUG $(V) run vieter +run: vieter + API_KEY=test REPO_DIR=data LOG_LEVEL=DEBUG ./vieter # Same as run, but restart when the source code changes .PHONY: watch -watch: libarchive +watch: API_KEY=test REPO_DIR=data LOG_LEVEL=DEBUG $(V) watch run vieter @@ -33,7 +39,7 @@ watch: libarchive # Format the V codebase .PHONY: fmt fmt: - v fmt -w vieter + v fmt -w $(SRC_DIR) # Pulls & builds my personal build of the v compiler, required for this project to function .PHONY: customv @@ -51,8 +57,8 @@ customv: 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 + cd "libarchive-${LARCHIVE_VER}" && cmake . '$(MAKE)' -C "libarchive-${LARCHIVE_VER}" clean: - rm -rf '$(LARCHIVE_DIR)' 'data' + rm -rf '$(LARCHIVE_DIR)' 'data' 'vieter' 'vieter-prod' diff --git a/src/archive.v b/src/archive.v new file mode 100644 index 00000000..ef36205d --- /dev/null +++ b/src/archive.v @@ -0,0 +1,20 @@ +module archive + +#flag -larchive +#include "archive.h" +#include "archive_entry.h" + +struct C.archive {} + +struct C.archive_entry {} + +fn C.archive_read_new() &C.archive +fn C.archive_read_support_filter_all(&C.archive) +fn C.archive_read_support_format_all(&C.archive) + +pub fn list_filenames() { + a := C.archive_read_new() + C.archive_read_support_filter_all(a) + C.archive_read_support_format_all(a) + println(a) +} diff --git a/vieter/auth.v b/src/auth.v similarity index 100% rename from vieter/auth.v rename to src/auth.v diff --git a/vieter/main.v b/src/main.v similarity index 98% rename from vieter/main.v rename to src/main.v index b974864c..54b3662f 100644 --- a/vieter/main.v +++ b/src/main.v @@ -5,6 +5,7 @@ import os import log import io import repo +import archive const port = 8000 @@ -94,6 +95,7 @@ fn main() { logger.info("Created package directory '$repo.pkg_dir()'.") } + archive.list_filenames() web.run(&App{ logger: logger api_key: key diff --git a/vieter/repo.v b/src/repo.v similarity index 100% rename from vieter/repo.v rename to src/repo.v diff --git a/vieter/routes.v b/src/routes.v similarity index 100% rename from vieter/routes.v rename to src/routes.v diff --git a/vieter/web/logging.v b/src/web/logging.v similarity index 100% rename from vieter/web/logging.v rename to src/web/logging.v diff --git a/vieter/web/parse.v b/src/web/parse.v similarity index 100% rename from vieter/web/parse.v rename to src/web/parse.v diff --git a/vieter/web/web.v b/src/web/web.v similarity index 100% rename from vieter/web/web.v rename to src/web/web.v diff --git a/vieter/archive.v b/vieter/archive.v deleted file mode 100644 index 4830c24e..00000000 --- a/vieter/archive.v +++ /dev/null @@ -1,13 +0,0 @@ -module archive - -#include "libarchive/archive.h" -#include "libarchive/archive_entry.h" - -struct C.archive {} -struct C.archive_entry {} - -fn C.archive_read_new() &C.archive - -pub fn list_filenames() { - a := C.archive_read_new() -}