support for Windows .love/.zip
This commit is contained in:
parent
8d33b39730
commit
0b30988408
4
.gitignore
vendored
4
.gitignore
vendored
@ -4,6 +4,10 @@
|
|||||||
*.pdb
|
*.pdb
|
||||||
*.idb
|
*.idb
|
||||||
*.def
|
*.def
|
||||||
|
*.exe
|
||||||
|
*.zip
|
||||||
|
*.love
|
||||||
|
dist/
|
||||||
.~*
|
.~*
|
||||||
.\#*
|
.\#*
|
||||||
\#*
|
\#*
|
||||||
|
|||||||
2
Makefile
2
Makefile
@ -96,7 +96,7 @@ pack_main: src/pack_main.o
|
|||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
.INTERMEDIATE:
|
.INTERMEDIATE:
|
||||||
.SECONDARY:
|
.SECONDARY:
|
||||||
.PHONY: all clean phony
|
.PHONY: all clean phony dist
|
||||||
|
|
||||||
%: RCS/%,v
|
%: RCS/%,v
|
||||||
%: RCS/%
|
%: RCS/%
|
||||||
|
|||||||
11
dist.sh
Normal file
11
dist.sh
Normal file
@ -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 . )
|
||||||
34
main.lua
34
main.lua
@ -39,33 +39,33 @@ void update(float time);
|
|||||||
|
|
||||||
local platform = love.system.getOS()
|
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 is_zip or is_love then
|
||||||
if love.filesystem.isFused() then
|
if love.filesystem.isFused() then
|
||||||
local archive = love.filesystem.getSourceBaseDirectory()
|
local archive = love.filesystem.getSourceBaseDirectory()
|
||||||
end
|
end
|
||||||
|
|
||||||
local contents, size = love.filesystem.read("data", "test.so")
|
local contents, size = love.filesystem.read("data", lib_name)
|
||||||
assert(contents ~= nil, size)
|
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()
|
local app_data = love.filesystem.getAppdataDirectory()
|
||||||
|
|
||||||
-- the love2d "filesystem" API is the worst possible design in the
|
-- the love2d "filesystem" API is the worst possible design in the
|
||||||
-- entire history of computing
|
-- entire history of computing
|
||||||
if platform == "Linux" then
|
test = ffi.load(app_data .. "/" .. love_name .. "/love-demo2/" .. lib_name)
|
||||||
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
|
else
|
||||||
assert(false, "unsupported platform: " .. platform)
|
test = ffi.load("./" .. lib_name)
|
||||||
end
|
|
||||||
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
|
|
||||||
end
|
end
|
||||||
test.load(source_path)
|
test.load(source_path)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -21,6 +21,8 @@ namespace file {
|
|||||||
|
|
||||||
void const * read_file(const char * r_filename, int * out_size)
|
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];
|
pack::header const * header = (pack::header const *)&_binary_test_pack_start[0];
|
||||||
assert(header->magic == pack::magic_value);
|
assert(header->magic == pack::magic_value);
|
||||||
ptrdiff_t data = (ptrdiff_t)&_binary_test_pack_start[header->header_size];
|
ptrdiff_t data = (ptrdiff_t)&_binary_test_pack_start[header->header_size];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user