implement new loader

This commit is contained in:
2025-03-16 02:37:31 +02:00
parent 7c7832ba40
commit 0101ed8a24
17 changed files with 1594 additions and 83 deletions

View File

@@ -1,14 +1,25 @@
# requires lua, curl and zlib (in the future, lua will be statically linked)
libraries := -llua -lcurl -lz
flags := -Wall
# lua is required in the build process, in order to compile the bytecode
lua := lua
cc := gcc
bundle = $(src_entry_dir)/bundle.lua
dump_loader = $(src_entry_dir)/dump_loader.lua
all_flags += -W -Wall -fPIC -std=gnu11
# requires lua, curl and zlib (in the future, lua will be statically linked)
main_libraries += -llua -lcurl -lz
main_cflags += $(all_flags)
loader_libraries += -lfuse -lpthread -lsquashfuse
loader_cflags += $(all_flags)
loader_cflags += -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=29
loader_cflags += -I/usr/include/fuse
dst_dir = dst
src_main_dir = src/main
src_entry_dir = src/entry
src_loader_dir = src/loader
# Uncomment to get debugging symbols
# flags := -g
@@ -18,21 +29,27 @@ main_sources += $(wildcard $(src_main_dir)/cli/*.lua)
main_sources += $(wildcard $(src_main_dir)/formats/*.lua)
main_sources += $(wildcard $(src_main_dir)/util/*.lua)
c_sources = $(wildcard $(src_entry_dir)/*.c)
entry_sources = $(wildcard $(src_entry_dir)/*.c)
build_entry = $(src_entry_dir)/build.lua
loader_sources = $(wildcard $(src_loader_dir)/*.c)
target = $(dst_dir)/slimpack
bytecode_target = $(dst_dir)/bytecode.h
main_target = $(dst_dir)/slimpack
loader_target = $(dst_dir)/loader
bytecode_h_target = $(dst_dir)/bytecode.h
loader_h_target = $(dst_dir)/loader.h
.PHONY: build
build: $(target)
build: $(main_target)
$(dst_dir):
mkdir -p $@
$(bytecode_target): $(main_sources) $(dst_dir) $(build_entry)
$(lua) $(build_entry) $(src_main_dir) $@ $(main_sources)
$(target): $(c_sources) $(bytecode_target) $(dst_dir)
$(cc) $(flags) $(libraries) -include $(bytecode_target) $(c_sources) -o $@
$(bytecode_h_target): $(dst_dir) $(bundle) $(main_sources)
$(lua) $(bundle) $(src_main_dir) $@ $(main_sources)
$(loader_h_target): $(dst_dir) $(dump_loader) $(loader_target)
$(lua) $(dump_loader) $(loader_target) $@
$(loader_target): $(dst_dir) $(loader_sources)
$(cc) $(loader_cflags) $(loader_libraries) $(loader_sources) -o $@
$(main_target): $(dst_dir) $(bytecode_h_target) $(loader_h_target) $(entry_sources) $(main_sources)
$(cc) $(main_cflags) $(main_libraries) -include $(bytecode_h_target) -include $(loader_h_target) $(entry_sources) -o $@