diff --git a/.gitignore b/.gitignore index ad21af0..c7c3865 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,10 @@ *.pdb *.idb *.def +*.exe +*.zip +*.love +dist/ .~* .\#* \#* diff --git a/Makefile b/Makefile index 7f018e1..f3819bb 100644 --- a/Makefile +++ b/Makefile @@ -96,7 +96,7 @@ pack_main: src/pack_main.o .SUFFIXES: .INTERMEDIATE: .SECONDARY: -.PHONY: all clean phony +.PHONY: all clean phony dist %: RCS/%,v %: RCS/% diff --git a/dist.sh b/dist.sh new file mode 100644 index 0000000..aaed387 --- /dev/null +++ b/dist.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +set -eux + +rm -rf dist/ +mkdir dist/ +[ -f "test.so" ] && cp test.so dist/ +[ -f "test.dll" ] && cp test.dll dist/ +cp conf.lua main.lua dist/ + +( cd dist/ ; zip -r ../test.zip . ) diff --git a/main.lua b/main.lua index f8d532a..0bdc5a5 100644 --- a/main.lua +++ b/main.lua @@ -39,33 +39,33 @@ void update(float time); local platform = love.system.getOS() + local lib_name + local love_name + if platform == "Linux" then + lib_name = "test.so" + love_name = "love" + elseif platform == "Windows" then + lib_name = "test.dll" + love_name = "LOVE" + else + assert(false, "unsupported platform " .. platform) + end + if is_zip or is_love then if love.filesystem.isFused() then local archive = love.filesystem.getSourceBaseDirectory() end - local contents, size = love.filesystem.read("data", "test.so") + local contents, size = love.filesystem.read("data", lib_name) assert(contents ~= nil, size) - local write_success, message = love.filesystem.write("test.so", contents, size) + local write_success, message = love.filesystem.write(lib_name, contents, size) + assert(write_success, lib_name, message) local app_data = love.filesystem.getAppdataDirectory() - -- the love2d "filesystem" API is the worst possible design in the -- entire history of computing - if platform == "Linux" then - test = ffi.load(app_data .. "/love/love-demo2/test.so") - elseif platform == "Windows" then - test = ffi.load(app_data .. "/love/love-demo2/test.dll") - else - assert(false, "unsupported platform: " .. platform) - end + test = ffi.load(app_data .. "/" .. love_name .. "/love-demo2/" .. lib_name) else - if platform == "Linux" then - test = ffi.load("./test.so") - elseif platform == "Windows" then - test = ffi.load("./test.dll") - else - assert(false, "unsupported platform: " .. platform) - end + test = ffi.load("./" .. lib_name) end test.load(source_path) end diff --git a/src/file.cpp b/src/file.cpp index ca24025..62fcce7 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -21,6 +21,8 @@ namespace file { void const * read_file(const char * r_filename, int * out_size) { + fprintf(stderr, "(pack) filename: %s\n", r_filename); + pack::header const * header = (pack::header const *)&_binary_test_pack_start[0]; assert(header->magic == pack::magic_value); ptrdiff_t data = (ptrdiff_t)&_binary_test_pack_start[header->header_size];