crossplatform optimisation
This commit is contained in:
parent
b52b157eff
commit
7f5d84ee5e
11 changed files with 109 additions and 22 deletions
|
|
@ -61,6 +61,8 @@ Archive: result/bin/xrforge.com
|
||||||
|
|
||||||
> Profit! you have aqcuired the sourcecode from the binary: run and distribute modified versions if needed ♥
|
> Profit! you have aqcuired the sourcecode from the binary: run and distribute modified versions if needed ♥
|
||||||
|
|
||||||
|
**NOTE**: if the binary does not work on your server, use [xrforge-x86_64]() from the releases section instead.
|
||||||
|
|
||||||
## Adding content
|
## Adding content
|
||||||
|
|
||||||
First you need a directory with glTF or JanusXR experiences.<br>
|
First you need a directory with glTF or JanusXR experiences.<br>
|
||||||
|
|
@ -167,6 +169,10 @@ Then run with debug flag to see output of `trace()` calls
|
||||||
$ DEBUG=1 result/bin/xrforge.com
|
$ DEBUG=1 result/bin/xrforge.com
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> Testing: run the builtin testrunner: `cd src && ../result/bin/xrforge.com test`
|
||||||
|
|
||||||
|
Use `ARCH=x86_64 build` to enforce x86_64 output (instead of a cosmopolitan binary)
|
||||||
|
|
||||||
## Permacomputing Spirit
|
## Permacomputing Spirit
|
||||||
|
|
||||||
* developed on [Dillo](https://dillo-browser.github.io/) as lowest common denominator / compatibility
|
* developed on [Dillo](https://dillo-browser.github.io/) as lowest common denominator / compatibility
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
package.path = package.path .. ";.lua/?.lua"
|
package.path = package.path .. ";/zip/?.lua"
|
||||||
package.path = package.path .. ";src/.lua/?.lua"
|
package.path = package.path .. ";src/.lua/?.lua"
|
||||||
package.path = package.path .. ";middleware/?.lua"
|
package.path = package.path .. ";.lua/?.lua;/zip/.lua/?.lua"
|
||||||
package.path = package.path .. ";cmd/?.lua"
|
package.path = package.path .. ";middleware/?.lua;/zip/middleware/?.lua"
|
||||||
package.path = package.path .. ";plugin/?.lua"
|
package.path = package.path .. ";cmd/?.lua;/zip/cmd/?.lua"
|
||||||
|
package.path = package.path .. ";plugin/?.lua;/zip/plugin/?.lua"
|
||||||
|
|
||||||
util = require "util"
|
util = require "util"
|
||||||
json = require "json"
|
json = require "json"
|
||||||
|
|
@ -14,7 +15,7 @@ HidePath('/usr/share/ssl/')
|
||||||
-- create
|
-- create
|
||||||
app = require("soakbean") {
|
app = require("soakbean") {
|
||||||
bin = "./xrforge.com",
|
bin = "./xrforge.com",
|
||||||
bindir = arg[-1]:gsub("xrforge.com",""),
|
bindir = arg[-1]:gsub("/[a-zA-Z0-9-_ ]+.com$","/"),
|
||||||
cache = { items = {}, url = {} },
|
cache = { items = {}, url = {} },
|
||||||
plugin = {},
|
plugin = {},
|
||||||
opts = {},
|
opts = {},
|
||||||
|
|
@ -116,7 +117,3 @@ end
|
||||||
OnServerStart = function()
|
OnServerStart = function()
|
||||||
app.init() -- this triggers init event
|
app.init() -- this triggers init event
|
||||||
end
|
end
|
||||||
|
|
||||||
OnServerStop = function()
|
|
||||||
print("todo: kill threads")
|
|
||||||
end
|
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,14 @@ function pluginInput(opt)
|
||||||
return html
|
return html
|
||||||
end
|
end
|
||||||
|
|
||||||
|
app.on('set', function(k,v) -- clear url cache
|
||||||
|
if k:match("app.opts") then -- after (admin) updates to app.opts.*
|
||||||
|
foreach( app.cache.url, function(k,v)
|
||||||
|
app.cache.url = nil
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
function pluginUI(seen,data)
|
function pluginUI(seen,data)
|
||||||
return function(name,plugin)
|
return function(name,plugin)
|
||||||
if seen[ plugin.name ] then return end -- already processed
|
if seen[ plugin.name ] then return end -- already processed
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
|
{if true then
|
||||||
|
showfediportals = app.opts.plugin_federation_strategy == 'always' or
|
||||||
|
(app.opts.plugin_federation_strategy == 'homepage' and urlpath == '/')
|
||||||
|
end}
|
||||||
|
|
||||||
|
|
||||||
<fireboxroom>
|
<fireboxroom>
|
||||||
<assets>
|
<assets>
|
||||||
<assetshader id="xrforgeportal" src="${opts.baseurl}shader/xrforgeportal.shadertoy.frag" shadertype="shadertoy"></assetshader>
|
<assetshader id="xrforgeportal" src="${opts.baseurl}shader/xrforgeportal.shadertoy.frag" shadertype="shadertoy"></assetshader>
|
||||||
|
|
@ -6,13 +12,15 @@
|
||||||
print('\t<assetimage src="' .. v.thumbnail .. '" id="img' .. i .. '"/>')
|
print('\t<assetimage src="' .. v.thumbnail .. '" id="img' .. i .. '"/>')
|
||||||
end
|
end
|
||||||
end}
|
end}
|
||||||
{for i=1,5 do
|
{if showfediportals then
|
||||||
|
for i=1,5 do
|
||||||
local urls = app.opts[ 'plugin_federation_url_' .. i]
|
local urls = app.opts[ 'plugin_federation_url_' .. i]
|
||||||
if #urls > 0 then
|
if #urls > 0 then
|
||||||
local fediurl = urls:gsub(' .*','')
|
local fediurl = urls:gsub(' .*','')
|
||||||
local thumburl = urls:gsub('.* ','')
|
local thumburl = urls:gsub('.* ','')
|
||||||
print('\t<assetimage src="' .. thumburl .. '" id="federated' .. i .. '"/>')
|
print('\t<assetimage src="' .. thumburl .. '" id="federated' .. i .. '"/>')
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end}
|
end}
|
||||||
</assets>
|
</assets>
|
||||||
{if item then
|
{if item then
|
||||||
|
|
@ -49,7 +57,7 @@
|
||||||
addPortal('dir',center, v, url,i, -4, 'img', '0 0 0', '0.2 0.2 0.2')
|
addPortal('dir',center, v, url,i, -4, 'img', '0 0 0', '0.2 0.2 0.2')
|
||||||
end
|
end
|
||||||
end}
|
end}
|
||||||
{if not item then
|
{if showfediportals and not item then
|
||||||
local portals = {}
|
local portals = {}
|
||||||
for i=1,5 do
|
for i=1,5 do
|
||||||
local urls = app.opts[ 'plugin_federation_url_' .. i]
|
local urls = app.opts[ 'plugin_federation_url_' .. i]
|
||||||
|
|
|
||||||
|
|
@ -113,15 +113,14 @@ local plugin = {
|
||||||
getRandomRoom = function()
|
getRandomRoom = function()
|
||||||
local me = app.plugin.janusxr
|
local me = app.plugin.janusxr
|
||||||
local room= ''
|
local room= ''
|
||||||
|
math.randomseed(os.time())
|
||||||
foreach( me.opts, function(k,v)
|
foreach( me.opts, function(k,v)
|
||||||
print(v.key)
|
|
||||||
if v.key == 'app.opts.plugin_janusxr_portalroom' then
|
if v.key == 'app.opts.plugin_janusxr_portalroom' then
|
||||||
local ordered = {}
|
local ordered = {}
|
||||||
foreach( v.values, function(k,v) table.insert(ordered,v) end)
|
foreach( v.values, function(k,v) table.insert(ordered,v) end)
|
||||||
room = ordered[ math.random( #ordered ) ]
|
room = ordered[ math.random( #ordered ) ]
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
print("ROOM = " .. room)
|
|
||||||
return room
|
return room
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
|
||||||
10
src/test/cheatsheet.txt
Normal file
10
src/test/cheatsheet.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
expect(...).to.exist()
|
||||||
|
expect(...).to.be.truthy()
|
||||||
|
expect(...).to.be.falsy()
|
||||||
|
expect(...).to.be(...)
|
||||||
|
expect(...).to.equal(...)
|
||||||
|
expect(...).to.approximately.equal(...)
|
||||||
|
expect(...).to.approximately(eps).equal(...)
|
||||||
|
expect(t).to.have(val)
|
||||||
|
expect(f).to.fail(pattern?)
|
||||||
|
expect(x).to_not.*
|
||||||
|
|
@ -3,6 +3,7 @@ local describe, it, expect = lust.describe, lust.it, lust.expect
|
||||||
-- usage: https://github.com/bjornbytes/lust
|
-- usage: https://github.com/bjornbytes/lust
|
||||||
|
|
||||||
require('test/plugin_diskscan')(lust)
|
require('test/plugin_diskscan')(lust)
|
||||||
|
require('test/plugin_xrfragment')(lust)
|
||||||
|
|
||||||
if lust.errors == 0 then
|
if lust.errors == 0 then
|
||||||
print("✅ all tests passed")
|
print("✅ all tests passed")
|
||||||
|
|
|
||||||
|
|
@ -21,4 +21,23 @@ return function(lust)
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
describe('src/plugin/diskscan.lua (e2e)', function()
|
||||||
|
|
||||||
|
describe('ℹ️ scan_experience', function() -- Can be nested
|
||||||
|
|
||||||
|
local dirs = 0
|
||||||
|
|
||||||
|
app.on('scan_experience', function(exp)
|
||||||
|
if exp.dir then dirs = dirs +1 end
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('on init', function()
|
||||||
|
app.init()
|
||||||
|
expect(dirs > 0).to.be.truthy()
|
||||||
|
end)
|
||||||
|
|
||||||
|
end)
|
||||||
|
|
||||||
|
end)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
30
src/test/plugin_xrfragment.lua
Normal file
30
src/test/plugin_xrfragment.lua
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
return function(lust)
|
||||||
|
|
||||||
|
|
||||||
|
local describe, it, expect = lust.describe, lust.it, lust.expect
|
||||||
|
|
||||||
|
describe('src/plugin/xrfragments.lua', function()
|
||||||
|
|
||||||
|
describe('ℹ️ detect sidecarfiles', function() -- Can be nested
|
||||||
|
|
||||||
|
local sidecarfile = {}
|
||||||
|
|
||||||
|
it('on init', function()
|
||||||
|
app.init()
|
||||||
|
foreach(app.cache.items, function(k,exp)
|
||||||
|
if exp.sidecarfile then
|
||||||
|
foreach( {"png","vtt","ogg","json"}, function(k,ext)
|
||||||
|
if exp.sidecarfile[k] then sidecarfile[ext] = true end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
print_r(sidecarfile)
|
||||||
|
expect( (sidecarfile.png ~= nil) ).to.be.truthy()
|
||||||
|
expect( (sidecarfile.vtt ~= nil) ).to.be.truthy()
|
||||||
|
end)
|
||||||
|
|
||||||
|
end)
|
||||||
|
|
||||||
|
end)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
@ -12,11 +12,21 @@ download(){
|
||||||
verify(){
|
verify(){
|
||||||
echo "$REDBEAN_CRC" > /tmp/checksum
|
echo "$REDBEAN_CRC" > /tmp/checksum
|
||||||
sha256sum -c /tmp/checksum || { echo "psuedosecurity checksum failed"; exit 1; }
|
sha256sum -c /tmp/checksum || { echo "psuedosecurity checksum failed"; exit 1; }
|
||||||
chmod +x $OUTDIR/xrforge.com
|
|
||||||
}
|
}
|
||||||
test -f /tmp/xrforge.com || wget --no-check-certificate "$REDBEAN_URL" -O /tmp/xrforge.com
|
test -f /tmp/xrforge.com || {
|
||||||
|
wget --no-check-certificate "$REDBEAN_URL" -O /tmp/xrforge.com
|
||||||
|
}
|
||||||
cp /tmp/xrforge.com $OUTDIR/xrforge.com
|
cp /tmp/xrforge.com $OUTDIR/xrforge.com
|
||||||
verify
|
test -n "$ARCH" && {
|
||||||
|
test -f /tmp/assimilate || {
|
||||||
|
wget https://cosmo.zip/pub/cosmos/bin/assimilate-x86_64.elf -O /tmp/assimilate
|
||||||
|
chmod +x /tmp/assimilate
|
||||||
|
}
|
||||||
|
rm $OUTDIR/*.bak || true
|
||||||
|
/tmp/assimilate $OUTDIR/xrforge.com
|
||||||
|
}
|
||||||
|
chmod +x $OUTDIR/*.com
|
||||||
|
#verify
|
||||||
}
|
}
|
||||||
|
|
||||||
janusweb(){
|
janusweb(){
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
../result/bin/xrforge.lua
|
|
||||||
Loading…
Add table
Reference in a new issue