Still trying to just link some stuff bro

main
Jef Roosens 2022-01-12 20:54:54 +01:00
parent cfcca90dfc
commit 05e725eb4e
Signed by: Jef Roosens
GPG Key ID: 955C0660072F691F
11 changed files with 43 additions and 28 deletions

4
.gitignore vendored
View File

@ -1,7 +1,7 @@
*.c *.c
data/ data/
vieter.exe vieter
vieter-prod.exe vieter-prod
# Ignore testing files # Ignore testing files
*.pkg* *.pkg*

View File

@ -1,31 +1,37 @@
# =====CONFIG===== # =====CONFIG=====
SRC_DIR := src
SOURCES != find '$(SRC_DIR)' -iname '*.v'
LARCHIVE_VER := 3.5.2 LARCHIVE_VER := 3.5.2
LARCHIVE_DIR := libarchive-$(LARCHIVE_VER) 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 # 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===== # =====COMPILATION=====
.PHONY: vieter .PHONY: debug
vieter: debug: vieter
$(V) -cg -o vieter.exe vieter vieter: $(SOURCES)
$(V) -cg -o vieter $(SRC_DIR)
.PHONY: prod .PHONY: prod
prod: prod: vieter-prod
$(V) -o vieter-prod.exe -prod vieter vieter-prod: $(SOURCES)
$(V) -o vieter-prod -prod $(SRC_DIR)
# =====EXECUTION===== # =====EXECUTION=====
# Run the server in the default 'data' directory # Run the server in the default 'data' directory
.PHONY: run .PHONY: run
run: libarchive run: vieter
API_KEY=test REPO_DIR=data LOG_LEVEL=DEBUG $(V) run vieter API_KEY=test REPO_DIR=data LOG_LEVEL=DEBUG ./vieter
# Same as run, but restart when the source code changes # Same as run, but restart when the source code changes
.PHONY: watch .PHONY: watch
watch: libarchive watch:
API_KEY=test REPO_DIR=data LOG_LEVEL=DEBUG $(V) watch run vieter API_KEY=test REPO_DIR=data LOG_LEVEL=DEBUG $(V) watch run vieter
@ -33,7 +39,7 @@ watch: libarchive
# Format the V codebase # Format the V codebase
.PHONY: fmt .PHONY: fmt
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 # Pulls & builds my personal build of the v compiler, required for this project to function
.PHONY: customv .PHONY: customv
@ -51,8 +57,8 @@ customv:
libarchive: $(LARCHIVE_LIB) libarchive: $(LARCHIVE_LIB)
$(LARCHIVE_LIB): $(LARCHIVE_LIB):
curl -o - "https://libarchive.org/downloads/libarchive-${LARCHIVE_VER}.tar.gz" | tar xzf - 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}" '$(MAKE)' -C "libarchive-${LARCHIVE_VER}"
clean: clean:
rm -rf '$(LARCHIVE_DIR)' 'data' rm -rf '$(LARCHIVE_DIR)' 'data' 'vieter' 'vieter-prod'

20
src/archive.v 100644
View File

@ -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)
}

View File

@ -5,6 +5,7 @@ import os
import log import log
import io import io
import repo import repo
import archive
const port = 8000 const port = 8000
@ -94,6 +95,7 @@ fn main() {
logger.info("Created package directory '$repo.pkg_dir()'.") logger.info("Created package directory '$repo.pkg_dir()'.")
} }
archive.list_filenames()
web.run(&App{ web.run(&App{
logger: logger logger: logger
api_key: key api_key: key

View File

@ -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()
}