It builds at last!

This commit is contained in:
dlannan 2024-12-10 01:00:21 +10:30
parent 93c68cf140
commit f88780a626
28 changed files with 15726 additions and 426 deletions

Binary file not shown.

View File

@ -1 +1 @@
{"graphics":{"antialias":{"index":5,"slen":16,"value":"fxaa"},"display_res":{"index":1,"plist":["1920x1080","1680x1050","1600x900","1440x900","1376x768"],"value":1,"ffi":null,"ptype":"combo"},"display_width":{"ptype":"int","ffi":null,"vmin":640,"vmax":8192,"vstep":32,"vinc":0.1,"index":2,"value":1024},"display_height":{"ptype":"int","ffi":null,"vmin":480,"vmax":8192,"vstep":32,"vinc":0.1,"index":3,"value":768},"display_fps":{"ptype":"int","ffi":null,"vmin":25,"vmax":200,"vstep":5,"vinc":0.1,"index":4,"value":60}},"project":{"build_path":{"ptype":"path","ffi":null,"slen":256,"value":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\builds\\cube_sapp","key":"build_path","len_ffi":null,"index":2},"project_name":{"ptype":"string","ffi":null,"slen":64,"value":"default","key":"project_name","len_ffi":null,"index":1},"project_start":{"index":3,"pfilter":"*.lua","slen":128,"value":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\examples\\samples\\cube_sapp.lua","key":"project_start","len_ffi":null,"ffi":null,"ptype":"file"}},"sokol":{"sokol_examples":{"ptype":"path","ffi":null,"slen":256,"value":"F:\\dev\\luajit\\Thunc\\examples","key":"sokol_examples","len_ffi":null,"index":5},"sokol_path":{"ptype":"path","ffi":null,"slen":256,"value":"F:\\dev\\luajit\\Thunc","key":"sokol_path","len_ffi":null,"index":1},"sokol_bin":{"ptype":"path","ffi":null,"slen":256,"value":"F:\\dev\\luajit\\Thunc\\bin","key":"sokol_bin","len_ffi":null,"index":2},"sokol_ffi":{"ptype":"path","ffi":null,"slen":256,"value":"F:\\dev\\luajit\\Thunc\\ffi","key":"sokol_ffi","len_ffi":null,"index":3},"sokol_lua":{"ptype":"path","ffi":null,"slen":256,"value":"F:\\dev\\luajit\\Thunc\\lua","key":"sokol_lua","len_ffi":null,"index":4}},"platform":{"target":{"ptype":"combo","plist":["Win64","MacOS","Linux","IOS64"],"value":1,"key":"target","ffi":null,"index":1},"srlua_path":{"ptype":"path","ffi":null,"slen":256,"value":"../srlua/","key":"srlua_path","len_ffi":null,"index":2},"arch":{"ptype":"combo","plist":["x86","x64","arm","arm64","arm64be","ppc","mips","mipsel","mips64","mips64el","mips64r6","mips64r6el"],"value":2,"key":"arch","ffi":null,"index":3},"os":{"ptype":"combo","plist":["Windows","Linux","OSX","BSD","POSIX","Other"],"value":1,"key":"os","ffi":null,"index":4}},"remote":{"remote_data":{"index":2,"slen":256,"value":"https://myremotedata.com/data"},"remote_build":{"index":1,"slen":256,"value":"https://mybuildserver.com/sokol_build"}},"assets":{"data":[],"lua":[{"name":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\lua"}],"images":[]},"rbuilder":{"title":{"slen":32,"value":"rbuild (00.01.snow)"},"appname":{"index":1,"slen":7,"value":"rbuild"},"version":{"index":2,"slen":32,"value":"00.01.snow"}},"audio":{"effects_volume":{"ptype":"float","ffi":null,"vmin":0,"vmax":1,"vstep":0.02,"vinc":0.1,"index":2,"value":1},"music_volume":{"ptype":"float","ffi":null,"vmin":0,"vmax":1,"vstep":0.02,"vinc":0.1,"index":3,"value":1},"master_volume":{"ptype":"float","ffi":null,"vmin":0,"vmax":1,"vstep":0.02,"vinc":0.1,"index":1,"value":1}}} {"platform":{"os":{"ptype":"combo","plist":["Windows","Linux","OSX","BSD","POSIX","Other"],"value":1,"key":"os","index":4,"ffi":null},"arch":{"ptype":"combo","plist":["x86","x64","arm","arm64","arm64be","ppc","mips","mipsel","mips64","mips64el","mips64r6","mips64r6el"],"value":2,"key":"arch","index":3,"ffi":null},"srlua_path":{"ptype":"path","slen":256,"key":"srlua_path","len_ffi":null,"value":"../srlua/","index":2,"ffi":null},"target":{"ptype":"combo","plist":["Win64","MacOS","Linux","IOS64"],"value":1,"key":"target","index":1,"ffi":null}},"graphics":{"display_height":{"ptype":"int","index":3,"value":768,"ffi":null,"vmin":480,"vmax":8192,"vstep":32,"vinc":0.1},"display_fps":{"ptype":"int","index":4,"value":60,"ffi":null,"vmin":25,"vmax":200,"vstep":5,"vinc":0.1},"antialias":{"value":"fxaa","slen":16,"index":5},"display_width":{"ptype":"int","index":2,"value":1024,"ffi":null,"vmin":640,"vmax":8192,"vstep":32,"vinc":0.1},"display_res":{"ptype":"combo","plist":["1920x1080","1680x1050","1600x900","1440x900","1376x768"],"value":1,"index":1,"ffi":null}},"options":{"build_type":{"ptype":"combo","plist":["Release","Debug","Release Remotery","Debug Remotery"],"value":3,"key":"build_type","index":1,"ffi":null},"build_relative":{"ptype":"check","value":0,"key":"build_relative","index":2,"ffi":null},"build_bytecode":{"ptype":"check","value":1,"key":"build_bytecode","index":3,"ffi":null}},"project":{"project_name":{"ptype":"string","slen":64,"key":"project_name","len_ffi":null,"value":"default","index":1,"ffi":null},"project_start":{"ptype":"file","len_ffi":null,"slen":128,"key":"project_start","ffi":null,"value":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\examples\\samples\\cube_sapp.lua","index":3,"pfilter":"*.lua"},"build_path":{"ptype":"path","slen":256,"key":"build_path","len_ffi":null,"value":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\builds\\cube_sapp","index":2,"ffi":null}},"remote":{"remote_build":{"value":"https://mybuildserver.com/sokol_build","slen":256,"index":1},"remote_data":{"value":"https://myremotedata.com/data","slen":256,"index":2}},"assets":{"data":[{"name":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\examples\\samples\\cube-sapp.glsl"}],"images":[],"lua":[{"name":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\tools\\dirtools.lua"},{"name":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\ffi\\sokol\\sokol_app.lua"},{"name":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\ffi\\sokol\\sokol_gfx.lua"},{"name":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\ffi\\sokol\\sokol_libs.lua"},{"name":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\ffi\\sokol\\hmm.lua"},{"name":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\ffi\\sokol\\hmm_utils.lua"},{"name":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\lua\\utils.lua"}]},"audio":{"master_volume":{"ptype":"float","index":1,"value":1,"ffi":null,"vmin":0,"vmax":1,"vstep":0.02,"vinc":0.1},"effects_volume":{"ptype":"float","index":2,"value":1,"ffi":null,"vmin":0,"vmax":1,"vstep":0.02,"vinc":0.1},"music_volume":{"ptype":"float","index":3,"value":1,"ffi":null,"vmin":0,"vmax":1,"vstep":0.02,"vinc":0.1}},"rbuilder":{"version":{"value":"00.01.snow","slen":32,"index":2},"title":{"value":"rbuild (00.01.snow)","slen":32},"appname":{"value":"rbuild","slen":7,"index":1}},"sokol":{"sokol_examples":{"ptype":"path","slen":256,"key":"sokol_examples","len_ffi":null,"value":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\examples","index":5,"ffi":null},"sokol_path":{"ptype":"path","slen":256,"key":"sokol_path","len_ffi":null,"value":"F:\\dev\\luajit\\Thunc\\sokol-luajit","index":1,"ffi":null},"sokol_bin":{"ptype":"path","slen":256,"key":"sokol_bin","len_ffi":null,"value":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\bin","index":2,"ffi":null},"sokol_ffi":{"ptype":"path","slen":256,"key":"sokol_ffi","len_ffi":null,"value":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\ffi","index":3,"ffi":null},"sokol_lua":{"ptype":"path","slen":256,"key":"sokol_lua","len_ffi":null,"value":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\lua","index":4,"ffi":null}}}

Binary file not shown.

View File

@ -1,64 +0,0 @@
local ffi = require("ffi")
local dirtools = {}
---------------------------------------------------------------------------------------
dirtools.add_default_paths = function(path)
local folders = {
["Linux"] = "linux",
["Windows"] = "win64",
["MacOSX"] = "macos",
}
local extensions = {
["Linux"] = "so",
["Windows"] = "dll",
["MacOSX"] = "so",
}
package.cpath = package.cpath..";"..path.."bin/"..folders[ffi.os].."/?."..extensions[ffi.os]
package.path = package.path..";"..path.."/ffi/sokol/?.lua"
package.path = package.path..";"..path.."/?.lua"
end
---------------------------------------------------------------------------------------
dirtools.get_app_path = function( expected_root_folder )
local base_dir = "."
if(ffi.os == "Windows") then
local cmdh = io.popen("cd", "r")
if(cmdh) then base_dir = cmdh:read("*a"); cmdh:close() end
else
local cmdh = io.popen("pwd", "r")
if(cmdh) then base_dir = cmdh:read("*a"); cmdh:close() end
end
local folder_name = expected_root_folder
local last_folder, remain = string.match(base_dir, "(.-"..folder_name..")(.-)")
last_folder = last_folder or ""
remain = remain or ""
remain = remain:gsub("%s+", "")
if(ffi.os == "Windows") then
base_dir = last_folder.."\\"
else
base_dir = last_folder.."/"
end
-- print("Base Directory: "..base_dir)
return base_dir
end
---------------------------------------------------------------------------------------
-- By default the paths are added
dirtools.init = function( base_path )
local path = dirtools.get_app_path(base_path)
dirtools.add_default_paths(path)
end
---------------------------------------------------------------------------------------
return dirtools
---------------------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -59,19 +59,19 @@ local colors = {
oxford_blue = make_nk_color(0xff0b132b), oxford_blue = make_nk_color(0xff0b132b),
space_cadet = make_nk_color(0xff1c2541), space_cadet = make_nk_color(0xff1c2541),
yinmin_blue = make_nk_color(0xff3a506b), yinmin_blue = make_nk_color(0xff3a506b),
vedigris = make_nk_color(0xff5bc0be), vedigris = nk.nk_rgba_hex("5bc0be"),
white = make_nk_color(0xffffffff), white = make_nk_color(0xffffffff),
gunmetal = make_nk_color(0xff253237), gunmetal = make_nk_color(0xff253237),
paynes_dark = make_nk_color(0xff2c3b43), paynes_dark = make_nk_color(0xff2c3b43),
paynes_gray = make_nk_color(0xff5c6b73), paynes_gray = make_nk_color(0xff5c6b73),
cadet_gray = make_nk_color(0xff6d94a0), cadet_gray = make_nk_color(0xff6d94a0),
light_blue = make_nk_color(0xff627f93), light_blue = nk.nk_rgba_hex("ADD8E6"),
light_cyan = make_nk_color(0xffc0dbdc), light_cyan = make_nk_color(0xffc0dbdc),
techalpha = make_nk_color(0x00177772), techalpha = make_nk_color(0x00177772),
techbg1 = make_nk_color(0xff177772), techbg1 = make_nk_color(0xff177772),
techbg2 = make_nk_color(0xff29f9e5), techbg2 = nk.nk_rgba_hex("29f9e5"),
techfg1 = make_nk_color(0x800c3d46), techfg1 = make_nk_color(0x800c3d46),
tech_black = make_nk_color(0xff000000), tech_black = make_nk_color(0xff000000),
@ -180,9 +180,9 @@ local themes = {
color_tbl[indexes.NK_COLOR_BUTTON_HOVER] = colors.tech_primary[3] -- button hover color color_tbl[indexes.NK_COLOR_BUTTON_HOVER] = colors.tech_primary[3] -- button hover color
color_tbl[indexes.NK_COLOR_BUTTON_ACTIVE] = colors.tech_primary[4] -- button active color color_tbl[indexes.NK_COLOR_BUTTON_ACTIVE] = colors.tech_primary[4] -- button active color
color_tbl[indexes.NK_COLOR_TOGGLE] = colors.tech_primary[6] -- toggle color color_tbl[indexes.NK_COLOR_TOGGLE] = colors.white --tech_primary[6] -- toggle color
color_tbl[indexes.NK_COLOR_TOGGLE_HOVER] = colors.tech_primary[5] -- toggle hover color color_tbl[indexes.NK_COLOR_TOGGLE_HOVER] = colors.vedigris -- toggle hover color
color_tbl[indexes.NK_COLOR_TOGGLE_CURSOR] = colors.tech_primary[4] -- toggle active color --color_tbl[indexes.NK_COLOR_TOGGLE_CURSOR] = colors.tech_primary[4] -- toggle active color
color_tbl[indexes.NK_COLOR_SELECT] = colors.tech_primary[2] -- select color color_tbl[indexes.NK_COLOR_SELECT] = colors.tech_primary[2] -- select color
color_tbl[indexes.NK_COLOR_SELECT_ACTIVE] = colors.tech_mixed[1] -- select active color color_tbl[indexes.NK_COLOR_SELECT_ACTIVE] = colors.tech_mixed[1] -- select active color

View File

@ -1,2 +1,4 @@
[Info] settings.load projectpath nil, using default settings. [Info] settings.load projectpath nil, using default settings.
[Info] Success
[Info] Success
[Info] settings.save_recents. [Info] settings.save_recents.

View File

@ -16,11 +16,12 @@ local settings = {
-- Default settings if none are loaded or found -- Default settings if none are loaded or found
local platforms = { "Win64", "MacOS", "Linux", "IOS64" } local platforms = { "Win64", "MacOS", "Linux", "IOS64" }
local buildtypes = { "Release", "Debug", "Release Remotery", "Debug Remotery" }
local resolutions = { "1920x1080", "1680x1050", "1600x900", "1440x900", "1376x768" } local resolutions = { "1920x1080", "1680x1050", "1600x900", "1440x900", "1376x768" }
local arch = { "x86", "x64", "arm", "arm64", "arm64be", "ppc", "mips", "mipsel", "mips64", "mips64el", "mips64r6", "mips64r6el" } local arch = { "x86", "x64", "arm", "arm64", "arm64be", "ppc", "mips", "mipsel", "mips64", "mips64el", "mips64r6", "mips64r6el" }
local oss = { "Windows", "Linux", "OSX", "BSD", "POSIX", "Other" } local oss = { "Windows", "Linux", "OSX", "BSD", "POSIX", "Other" }
local default_settings = { settings.default_settings = {
rbuilder = { rbuilder = {
appname = { index = 1, value = "rbuild", slen = 7 }, appname = { index = 1, value = "rbuild", slen = 7 },
@ -34,6 +35,12 @@ local default_settings = {
os = { index = 4, value = 1, ptype = "combo", plist = oss }, os = { index = 4, value = 1, ptype = "combo", plist = oss },
}, },
options = {
build_type = { index = 1, value = 1, ptype = "combo", plist = buildtypes },
build_relative = { index = 2, value = false, ptype = "check" },
build_bytecode = { index = 3, value = true, ptype = "check" },
},
project = { project = {
project_name = { index = 1, value = "default", ptype = "string", slen = 64 }, project_name = { index = 1, value = "default", ptype = "string", slen = 64 },
build_path = { index = 2, value = "<change me>", ptype = "path", slen = 256 }, -- Always starts empty. Will support a project file. build_path = { index = 2, value = "<change me>", ptype = "path", slen = 256 }, -- Always starts empty. Will support a project file.
@ -157,13 +164,13 @@ settings.load = function( projectpath )
if( projectpath == nil ) then if( projectpath == nil ) then
logging.info("settings.load projectpath nil, using default settings.") logging.info("settings.load projectpath nil, using default settings.")
settings.config = default_settings settings.config = settings.default_settings
else else
-- Load the project settings into the local config -- Load the project settings into the local config
settings.config = loadconfig(projectpath) settings.config = loadconfig(projectpath)
if(settings.config == nil) then if(settings.config == nil) then
logging.error("settings.load invalid projectpath nil, using default settings.") logging.error("settings.load invalid projectpath nil, using default settings.")
settings.config = default_settings settings.config = settings.default_settings
end end
end end

File diff suppressed because it is too large Load Diff

View File

@ -20,6 +20,7 @@ local stb = require("stb")
local ffi = require("ffi") local ffi = require("ffi")
local panel = require("ui.panels") local panel = require("ui.panels")
local builder = require("utils.build")
-- -------------------------------------------------------------------------------------- -- --------------------------------------------------------------------------------------
-- For win - sleep so as to not consume all proc cycles for ui -- For win - sleep so as to not consume all proc cycles for ui
@ -31,17 +32,21 @@ ffi.cdef[[
local ticker = nil local ticker = nil
function default_handler(ctx, build) function default_handler(ctx, build)
ticker = (ticker or 0) + 0.016
if(ticker > 0.01) then builder.configure(panel.config)
build.progress[0] = build.progress[0] + 1 builder.run(panel.config)
ticker = ticker - 0.01
end -- ticker = (ticker or 0) + 0.016
if(panel.build.progress[0] >= 999) then -- if(ticker > 0.01) then
ticker = nil -- build.progress[0] = build.progress[0] + 1
-- ticker = ticker - 0.01
-- end
-- if(panel.build.progress[0] >= 999) then
-- ticker = nil
build.progress[0] = 0.0 build.progress[0] = 0.0
build.active = 0 build.active = 0
build.mode = nil build.mode = nil
end -- end
end end
-- -------------------------------------------------------------------------------------- -- --------------------------------------------------------------------------------------

View File

@ -20,38 +20,17 @@ local icons = ffi.new("struct nk_image [?]", 10)
local themes = require("lua.themes") local themes = require("lua.themes")
local logging = require("utils.logging") local logging = require("utils.logging")
local build = require("ui.panels_build")
local assets = require("ui.panels_assets")
-- --------------------------------------------------------------------------------------
local panel = { local panel = {
config = nil, config = nil,
current_path = ".", current_path = ".",
build = { build = build,
mode = nil, assets = assets,
active = 0,
progress = ffi.new("size_t[1]", { 0 } ),
status = "",
handler = nil,
ui_func = function(ctx, dim, build)
nk.nk_layout_row_dynamic(ctx, dim.h-20, 1)
local flags = bit.bor(nk.NK_WINDOW_BORDER, nk.NK_WINDOW_TITLE)
flags = bit.bor(flags, nk.NK_WINDOW_NO_SCROLLBAR)
if (nk.nk_group_begin(ctx, "Building...", flags) == true) then
nk.nk_layout_row_dynamic(ctx, dim.h-dim.h/2 - 50, 1)
nk.nk_layout_row_dynamic(ctx, 25, 1)
nk.nk_label(ctx, "Please wait. Build mode: "..build.mode, nk.NK_TEXT_CENTERED)
nk.nk_layout_row_dynamic(ctx, 25, 1)
nk.nk_progress(ctx, build.progress, 1000, nk.NK_FIXED)
nk.nk_group_end(ctx)
end
if(build.handler) then build.handler(ctx, build) end
if(build.active == 0) then nk.nk_popup_close(ctx) end
return build.active
end,
}
} }
-- -------------------------------------------------------------------------------------- -- --------------------------------------------------------------------------------------
@ -76,45 +55,6 @@ local folder_select = nil
local file_select = nil local file_select = nil
local recent_files = nil local recent_files = nil
-- --------------------------------------------------------------------------------------
local curr_tab = 1
local tabs = {
{
name = "Lua Source",
func = function(ctx)
local bounds = nk.nk_window_get_content_region(ctx)
nk.nk_layout_row_dynamic(ctx, bounds.h, 1)
local files = panel.config.assets.lua
wdgts.widget_list_removeable(ctx, "source_files", nk.NK_WINDOW_BORDER, files, bounds.w -40 )
end,
asset_name = "lua",
},
{
name = "Images",
func = function(ctx)
local bounds = nk.nk_window_get_content_region(ctx)
nk.nk_layout_row_dynamic(ctx, bounds.h, 1)
local files = panel.config.assets.images
wdgts.widget_list_removeable(ctx, "source_files", nk.NK_WINDOW_BORDER, files, bounds.w -40 )
end,
asset_name = "images",
},
{
name = "Data",
func = function(ctx)
local bounds = nk.nk_window_get_content_region(ctx)
nk.nk_layout_row_dynamic(ctx, bounds.h, 1)
local files = panel.config.assets.data
wdgts.widget_list_removeable(ctx, "source_files", nk.NK_WINDOW_BORDER, files, bounds.w -40 )
end,
asset_name = "data",
}
}
-- -------------------------------------------------------------------------------------- -- --------------------------------------------------------------------------------------
-- Extract config and build ffi objects for them -- Extract config and build ffi objects for them
-- Each config property shall have a shadow ffi property labeled with _ffi -- Each config property shall have a shadow ffi property labeled with _ffi
@ -132,6 +72,8 @@ local function setup_config()
prop.len_ffi = ffi.new("int[1]", {string.len(prop.value)}) prop.len_ffi = ffi.new("int[1]", {string.len(prop.value)})
elseif(prop.ptype == "combo") then elseif(prop.ptype == "combo") then
prop.ffi = ffi.new("int[1]", prop.value) prop.ffi = ffi.new("int[1]", prop.value)
elseif(prop.ptype == "check") then
prop.ffi = ffi.new("bool[1]", prop.value)
elseif(prop.ptype == "int") then elseif(prop.ptype == "int") then
prop.ffi = ffi.new("int[1]", prop.value) prop.ffi = ffi.new("int[1]", prop.value)
elseif(prop.ptype == "float") then elseif(prop.ptype == "float") then
@ -149,6 +91,13 @@ local function setup_config()
end end
end end
end end
assets.config = panel.config
assets.folder_select = folder_select
assets.file_select = file_select
build.config = panel.config
build.folder_select = folder_select
build.file_select = file_select
end end
-- -------------------------------------------------------------------------------------- -- --------------------------------------------------------------------------------------
@ -196,189 +145,6 @@ panel.init = function()
recent_files = fsel.create_file_list("Choose Recent", dim3, {}) recent_files = fsel.create_file_list("Choose Recent", dim3, {})
end end
-- --------------------------------------------------------------------------------------
-- Attempts to find sokol in nearby folders (up max 4 directories from builder)
-- Sets all the sokol properties if it does find it
local function search_sokol(ctx)
local r = nk.nk_window_get_content_region(ctx)
nk.nk_layout_space_begin(ctx, nk.NK_STATIC, 27, 1)
nk.nk_layout_space_push(ctx, nk.nk_rect(r.w-40, -195, 27, 27))
nk.nk_style_set_font(ctx, myfonts[1].handle)
if(nk.nk_button_label(ctx, "") == true) then
-- do search stuff
local found = dirtools.find_folder(".", 5, "sokol-luajit")
if(found) then
logging.info(string.format("Found Sokol-luajit: %s",found))
logging.info("Auto filling sokol paths...")
panel.config["sokol"].sokol_path.value = found
panel.config["sokol"].sokol_bin.value = dirtools.combine_path(found, "bin")
panel.config["sokol"].sokol_ffi.value = dirtools.combine_path(found, "ffi")
panel.config["sokol"].sokol_lua.value = dirtools.combine_path(found, "lua")
panel.config["sokol"].sokol_examples.value = dirtools.combine_path(found, "examples")
setup_config()
end
end
nk.nk_style_set_font(ctx, myfonts[3].handle)
nk.nk_layout_space_end(ctx)
end
-- --------------------------------------------------------------------------------------
local function display_section(ctx, sectionname)
local section = panel.config[sectionname]
-- Collect the number of properties in the section
local count = 0
local sorted = {}
for k,v in pairs(section) do
count = count + 1
v.key = k
sorted[v.index] = v
end
nk.nk_layout_row_dynamic(ctx, 28 * count + 60, 1)
local bounds = nk.nk_window_get_content_region(ctx)
local prop_col = bounds.w * 0.23
local value_col = bounds.w * 0.73
local flags = bit.bor(nk.NK_WINDOW_BORDER, nk.NK_WINDOW_TITLE)
flags = bit.bor(flags, nk.NK_WINDOW_NO_SCROLLBAR)
if (nk.nk_group_begin(ctx, sectionname, flags) == true) then
for k,v in ipairs(sorted) do
nk.nk_layout_row_begin(ctx, nk.NK_STATIC, 28, 3)
nk.nk_layout_row_push(ctx, prop_col)
nk.nk_label(ctx, v.key..":", nk.NK_TEXT_LEFT)
if(v.ptype == "string" or v.ptype == nil) then
nk.nk_layout_row_push(ctx, value_col)
nk.nk_edit_string(ctx, nk.NK_EDIT_SIMPLE, v.ffi, v.len_ffi, v.slen, nk.nk_filter_default)
elseif(v.ptype == "path") then
nk.nk_layout_row_push(ctx, value_col - 34)
nk.nk_edit_string(ctx, nk.NK_EDIT_SIMPLE, v.ffi, v.len_ffi, v.slen, nk.nk_filter_default)
nk.nk_style_set_font(ctx, myfonts[1].handle)
nk.nk_layout_row_push(ctx, 30)
if(nk.nk_button_label(ctx, "") == true) then
fsel.open(folder_select, v.value, v)
end
nk.nk_style_set_font(ctx, myfonts[3].handle)
elseif(v.ptype == "file") then
nk.nk_layout_row_push(ctx, value_col - 34)
nk.nk_edit_string(ctx, nk.NK_EDIT_SIMPLE, v.ffi, v.len_ffi, v.slen, nk.nk_filter_default)
nk.nk_style_set_font(ctx, myfonts[1].handle)
nk.nk_layout_row_push(ctx, 30)
if(nk.nk_button_label(ctx, "") == true) then
fsel.open(file_select, v.value, v)
end
nk.nk_style_set_font(ctx, myfonts[3].handle)
elseif(v.ptype == "combo") then
nk.nk_layout_row_push(ctx, value_col)
v.value = wdgts.widget_combo_box(ctx, v.plist, v.value, 200)
elseif(v.ptype == "int") then
nk.nk_layout_row_push(ctx, value_col)
nk.nk_property_int(ctx, "", v.vmin, v.ffi, v.vmax, v.vstep, v.vinc)
elseif(v.ptype == "float") then
nk.nk_layout_row_push(ctx, value_col)
nk.nk_property_float(ctx, "", v.vmin, v.ffi, v.vmax, v.vstep, v.vinc)
end
nk.nk_layout_row_end(ctx)
end
nk.nk_group_end(ctx)
end
end
-- --------------------------------------------------------------------------------------
local project_curr_tab = 1
local project_tabs = {
{
name = "Settings",
func = function(ctx)
display_section(ctx, "project")
display_section(ctx, "sokol")
search_sokol(ctx)
end,
},
{
name = "Build",
func = function(ctx)
display_section(ctx, "platform")
end,
},
{
name = "Logs",
func = function(ctx)
local bounds = nk.nk_window_get_content_region(ctx)
nk.nk_layout_row_dynamic(ctx, bounds.h, 1)
wdgts.widget_list(ctx, "Logs", nk.NK_WINDOW_BORDER, logging.loglines)
end,
}
}
-- --------------------------------------------------------------------------------------
local function project_panel(ctx)
nk.nk_style_set_font(ctx, myfonts[3].handle)
project_curr_tab = wdgts.widget_notebook(ctx, "assets", project_tabs, project_curr_tab, 500, 120)
-- display_section(ctx, "graphics")
-- display_section(ctx, "audio")
nk.nk_layout_row_dynamic(ctx, 25, 2)
if (nk.nk_button_label(ctx, "Build Release") == true) then
panel.build.mode = "release"
panel.build.active = 1
end
if (nk.nk_button_label(ctx, "Clean All") == true) then
panel.build.mode = "clean"
panel.build.active = 1
end
-- Awesome little radial popup.
local res = wdgts.make_pie_popup(ctx, icons, 100, 6)
end
-- --------------------------------------------------------------------------------------
local function assets_panel(ctx)
nk.nk_style_set_font(ctx, myfonts[3].handle)
curr_tab, named_tab = wdgts.widget_notebook(ctx, "assets", tabs, curr_tab, 500, 120)
nk.nk_layout_row_dynamic(ctx, 25, 2)
if (nk.nk_button_label(ctx, "Add Folder") == true) then
fsel.open(folder_select, ".", nil, function(udata, res)
print(udata.folder_path, named_tab, res)
if(res == true) then
local tabinfo = tabs[curr_tab]
local newfolder = {
name=ffi.string(udata.folder_path),
select = ffi.new("bool[1]", {0})
}
table.insert(panel.config.assets[tabinfo.asset_name], newfolder)
end
end)
end
if (nk.nk_button_label(ctx, "Add File") == true) then
fsel.open(file_select, ".", nil, function(udata, res)
if(res == true) then
local tabinfo = tabs[curr_tab]
local newfile = {
name=ffi.string(udata.file_selected),
select = ffi.new("bool[1]", {0})
}
table.insert(panel.config.assets[tabinfo.asset_name], newfile)
end
end)
end
end
-- -------------------------------------------------------------------------------------- -- --------------------------------------------------------------------------------------
panel.show_recents = function(ctx) panel.show_recents = function(ctx)
@ -409,6 +175,9 @@ panel.main_ui = function(ctx)
myfonts = fonts.setup_font(ctx, font_list) myfonts = fonts.setup_font(ctx, font_list)
wdgts.myfonts = myfonts wdgts.myfonts = myfonts
themes.tech(ctx) themes.tech(ctx)
assets.font = myfonts
build.font = myfonts
end end
wdgts.widget_panel_fixed(ctx, "WinMain", 0, 0, sapp.sapp_width(), sapp.sapp_height(), 0, function(data) wdgts.widget_panel_fixed(ctx, "WinMain", 0, 0, sapp.sapp_width(), sapp.sapp_height(), 0, function(data)
@ -504,7 +273,8 @@ panel.main_ui = function(ctx)
local padding = ctx[0].style.window.padding local padding = ctx[0].style.window.padding
ctx[0].style.window.padding = nk.nk_vec2(10,10) ctx[0].style.window.padding = nk.nk_vec2(10,10)
project_panel(data.ctx) build.panel(data.ctx)
if(build.run_config) then setup_config() end
nk.nk_group_end(ctx) nk.nk_group_end(ctx)
end end
@ -512,7 +282,7 @@ panel.main_ui = function(ctx)
if (nk.nk_group_begin(ctx, "Assets", flags) == true) then if (nk.nk_group_begin(ctx, "Assets", flags) == true) then
assets_panel(data.ctx) assets.panel(data.ctx)
nk.nk_group_end(ctx) nk.nk_group_end(ctx)
end end

View File

@ -0,0 +1,110 @@
-- --------------------------------------------------------------------------------------
local ffi = require("ffi")
local dirtools = require("tools.dirtools")
local sapp = require("sokol_app")
sg = require("sokol_nuklear")
local nk = sg
local slib = require("sokol_libs") -- Warn - always after gfx!!
-- --------------------------------------------------------------------------------------
local settings = require("config.settings")
local wdgts = require("utils.widgets")
local fonts = require("utils.fonts")
local fsel = require("ui.file_selector")
local icons = ffi.new("struct nk_image [?]", 10)
local themes = require("lua.themes")
local logging = require("utils.logging")
-- --------------------------------------------------------------------------------------
local assets = {
curr_tab = 1,
font = nil,
}
local tabs = {
{
name = "Lua Source",
func = function(ctx)
local bounds = nk.nk_window_get_content_region(ctx)
nk.nk_layout_row_dynamic(ctx, bounds.h, 1)
local files = assets.config.assets.lua
wdgts.widget_list_removeable(ctx, "source_files", nk.NK_WINDOW_BORDER, files, bounds.w -40 )
end,
asset_name = "lua",
},
{
name = "Images",
func = function(ctx)
local bounds = nk.nk_window_get_content_region(ctx)
nk.nk_layout_row_dynamic(ctx, bounds.h, 1)
local files = assets.config.assets.images
wdgts.widget_list_removeable(ctx, "source_files", nk.NK_WINDOW_BORDER, files, bounds.w -40 )
end,
asset_name = "images",
},
{
name = "Data",
func = function(ctx)
local bounds = nk.nk_window_get_content_region(ctx)
nk.nk_layout_row_dynamic(ctx, bounds.h, 1)
local files = assets.config.assets.data
wdgts.widget_list_removeable(ctx, "source_files", nk.NK_WINDOW_BORDER, files, bounds.w -40 )
end,
asset_name = "data",
}
}
-- --------------------------------------------------------------------------------------
assets.panel = function(ctx)
nk.nk_style_set_font(ctx, assets.font[3].handle)
assets.curr_tab, named_tab = wdgts.widget_notebook(ctx, "assets", tabs, assets.curr_tab, 500, 120)
nk.nk_layout_row_dynamic(ctx, 25, 2)
if (nk.nk_button_label(ctx, "Add Folder") == true) then
fsel.open(assets.folder_select, ".", nil, function(udata, res)
print(udata.folder_path, named_tab, res)
if(res == true) then
local tabinfo = tabs[assets.curr_tab]
local newfolder = {
name=ffi.string(udata.folder_path),
select = ffi.new("bool[1]", {0})
}
table.insert(assets.config.assets[tabinfo.asset_name], newfolder)
end
end)
end
if (nk.nk_button_label(ctx, "Add File") == true) then
fsel.open(assets.file_select, ".", nil, function(udata, res)
if(res == true) then
local tabinfo = tabs[assets.curr_tab]
local newfile = {
name=ffi.string(udata.file_selected),
select = ffi.new("bool[1]", {0})
}
table.insert(assets.config.assets[tabinfo.asset_name], newfile)
end
end)
end
end
-- --------------------------------------------------------------------------------------
return assets
-- --------------------------------------------------------------------------------------

View File

@ -0,0 +1,217 @@
-- --------------------------------------------------------------------------------------
local ffi = require("ffi")
local dirtools = require("tools.dirtools")
local sapp = require("sokol_app")
sg = require("sokol_nuklear")
local nk = sg
local slib = require("sokol_libs") -- Warn - always after gfx!!
-- --------------------------------------------------------------------------------------
local settings = require("config.settings")
local wdgts = require("utils.widgets")
local fonts = require("utils.fonts")
local fsel = require("ui.file_selector")
local icons = ffi.new("struct nk_image [?]", 10)
local themes = require("lua.themes")
local logging = require("utils.logging")
-- --------------------------------------------------------------------------------------
local build = {
curr_tab = 1,
font = nil,
run_config = nil,
mode = nil,
active = 0,
progress = ffi.new("size_t[1]", { 0 } ),
status = "",
handler = nil,
ui_func = function(ctx, dim, build)
nk.nk_layout_row_dynamic(ctx, dim.h-20, 1)
local flags = bit.bor(nk.NK_WINDOW_BORDER, nk.NK_WINDOW_TITLE)
flags = bit.bor(flags, nk.NK_WINDOW_NO_SCROLLBAR)
if (nk.nk_group_begin(ctx, "Building...", flags) == true) then
nk.nk_layout_row_dynamic(ctx, dim.h-dim.h/2 - 50, 1)
nk.nk_layout_row_dynamic(ctx, 25, 1)
nk.nk_label(ctx, "Please wait. Build mode: "..build.mode, nk.NK_TEXT_CENTERED)
nk.nk_layout_row_dynamic(ctx, 25, 1)
nk.nk_progress(ctx, build.progress, 1000, nk.NK_FIXED)
nk.nk_group_end(ctx)
end
if(build.handler) then build.handler(ctx, build) end
if(build.active == 0) then nk.nk_popup_close(ctx) end
return build.active
end,
}
-- --------------------------------------------------------------------------------------
-- Attempts to find sokol in nearby folders (up max 4 directories from builder)
-- Sets all the sokol properties if it does find it
local function search_sokol(ctx)
local r = nk.nk_window_get_content_region(ctx)
build.run_config = nil
nk.nk_layout_space_begin(ctx, nk.NK_STATIC, 27, 1)
nk.nk_layout_space_push(ctx, nk.nk_rect(r.w-40, -195, 27, 27))
nk.nk_style_set_font(ctx, build.font[1].handle)
if(nk.nk_button_label(ctx, "") == true) then
-- do search stuff
local found = dirtools.find_folder(".", 5, "sokol-luajit")
if(found) then
found = dirtools.combine_path(found, "sokol-luajit")
logging.info(string.format("Found Sokol-luajit: %s",found))
logging.info("Auto filling sokol paths...")
build.config["sokol"].sokol_path.value = found
build.config["sokol"].sokol_bin.value = dirtools.combine_path(found, "bin")
build.config["sokol"].sokol_ffi.value = dirtools.combine_path(found, "ffi")
build.config["sokol"].sokol_lua.value = dirtools.combine_path(found, "lua")
build.config["sokol"].sokol_examples.value = dirtools.combine_path(found, "examples")
build.run_config = true
end
end
nk.nk_style_set_font(ctx, build.font[3].handle)
nk.nk_layout_space_end(ctx)
end
-- --------------------------------------------------------------------------------------
local function display_section(ctx, sectionname)
local section = build.config[sectionname]
if(section == nil) then
build.config[sectionname] = settings.default_settings[sectionname]
section = settings.default_settings[sectionname]
end
-- Collect the number of properties in the section
local count = 0
local sorted = {}
for k,v in pairs(section) do
count = count + 1
v.key = k
sorted[v.index] = v
end
nk.nk_layout_row_dynamic(ctx, 28 * count + 60, 1)
local bounds = nk.nk_window_get_content_region(ctx)
local prop_col = bounds.w * 0.23
local value_col = bounds.w * 0.73
local flags = bit.bor(nk.NK_WINDOW_BORDER, nk.NK_WINDOW_TITLE)
flags = bit.bor(flags, nk.NK_WINDOW_NO_SCROLLBAR)
if (nk.nk_group_begin(ctx, sectionname, flags) == true) then
for k,v in ipairs(sorted) do
nk.nk_layout_row_begin(ctx, nk.NK_STATIC, 28, 3)
nk.nk_layout_row_push(ctx, prop_col)
nk.nk_label(ctx, v.key..":", nk.NK_TEXT_LEFT)
if(v.ptype == "string" or v.ptype == nil) then
nk.nk_layout_row_push(ctx, value_col)
nk.nk_edit_string(ctx, nk.NK_EDIT_SIMPLE, v.ffi, v.len_ffi, v.slen, nk.nk_filter_default)
elseif(v.ptype == "path") then
nk.nk_layout_row_push(ctx, value_col - 34)
nk.nk_edit_string(ctx, nk.NK_EDIT_SIMPLE, v.ffi, v.len_ffi, v.slen, nk.nk_filter_default)
nk.nk_style_set_font(ctx, build.font[1].handle)
nk.nk_layout_row_push(ctx, 30)
if(nk.nk_button_label(ctx, "") == true) then
fsel.open(build.folder_select, v.value, v)
end
nk.nk_style_set_font(ctx, build.font[3].handle)
elseif(v.ptype == "file") then
nk.nk_layout_row_push(ctx, value_col - 34)
nk.nk_edit_string(ctx, nk.NK_EDIT_SIMPLE, v.ffi, v.len_ffi, v.slen, nk.nk_filter_default)
nk.nk_style_set_font(ctx, build.font[1].handle)
nk.nk_layout_row_push(ctx, 30)
if(nk.nk_button_label(ctx, "") == true) then
fsel.open(build.file_select, v.value, v)
end
nk.nk_style_set_font(ctx, build.font[3].handle)
elseif(v.ptype == "combo") then
nk.nk_layout_row_push(ctx, value_col)
v.value = wdgts.widget_combo_box(ctx, v.plist, v.value, 200)
elseif(v.ptype == "check") then
nk.nk_layout_row_push(ctx, value_col)
nk.nk_checkbox_label(ctx, "", v.ffi)
elseif(v.ptype == "int") then
nk.nk_layout_row_push(ctx, value_col)
nk.nk_property_int(ctx, "", v.vmin, v.ffi, v.vmax, v.vstep, v.vinc)
elseif(v.ptype == "float") then
nk.nk_layout_row_push(ctx, value_col)
nk.nk_property_float(ctx, "", v.vmin, v.ffi, v.vmax, v.vstep, v.vinc)
end
nk.nk_layout_row_end(ctx)
end
nk.nk_group_end(ctx)
end
end
-- --------------------------------------------------------------------------------------
local project_tabs = {
{
name = "Settings",
func = function(ctx)
display_section(ctx, "project")
display_section(ctx, "sokol")
search_sokol(ctx)
end,
},
{
name = "Build",
func = function(ctx)
display_section(ctx, "platform")
display_section(ctx, "options")
end,
},
{
name = "Logs",
func = function(ctx)
local bounds = nk.nk_window_get_content_region(ctx)
nk.nk_layout_row_dynamic(ctx, bounds.h, 1)
wdgts.widget_list(ctx, "Logs", nk.NK_WINDOW_BORDER, logging.loglines)
end,
}
}
-- --------------------------------------------------------------------------------------
build.panel = function(ctx)
nk.nk_style_set_font(ctx, build.font[3].handle)
build.curr_tab = wdgts.widget_notebook(ctx, "assets", project_tabs, build.curr_tab, 500, 120)
-- display_section(ctx, "graphics")
-- display_section(ctx, "audio")
nk.nk_layout_row_dynamic(ctx, 25, 2)
if (nk.nk_button_label(ctx, "Build Release") == true) then
build.mode = "release"
build.active = 1
end
if (nk.nk_button_label(ctx, "Clean All") == true) then
build.mode = "clean"
build.active = 1
end
-- Awesome little radial popup.
local res = wdgts.make_pie_popup(ctx, icons, 100, 6)
end
-- --------------------------------------------------------------------------------------
return build
-- --------------------------------------------------------------------------------------

View File

@ -2,6 +2,19 @@
-- Use ffi for arch and os detection -- Use ffi for arch and os detection
local ffi = require("ffi") local ffi = require("ffi")
local logging = require("utils.logging")
local combine = require("utils.combine")
local dirtools = require("tools.dirtools")
local base_path = dirtools.get_app_path("sokol%-luajit")
local tinsert = table.insert
-- ----------------------------------------------------------------------------------
local luajit_builder = {
}
-- ---------------------------------------------------------------------------------- -- ----------------------------------------------------------------------------------
local function run_cmd(command) local function run_cmd(command)
@ -11,67 +24,105 @@ local function run_cmd(command)
local output = fh:read("*a") local output = fh:read("*a")
fh:close() fh:close()
io.write(output) io.write(output)
print("[Success]") logging.info("Success")
else else
print("[Error] Cannot execute command: "..command) logging.error("Cannot execute command: "..command)
end end
end end
-- ---------------------------------------------------------------------------------- -- ----------------------------------------------------------------------------------
-- srlua and glue for each os -- srlua and glue for each os
local plaform_cmds = {
["Windows"] = { local plaform_cmds = {}
srlua = ".\\tools\\srlua\\win64\\srlua.exe",
glue = ".\\tools\\srlua\\win64\\glue.exe", luajit_builder.configure = function(config)
plaform_cmds["Windows"] = {
build_path = config["sokol"].sokol_path.value.."\\tools\\build\\",
srlua = config["sokol"].sokol_path.value.."\\tools\\build\\srlua\\bin\\win64\\srlua.exe",
glue = config["sokol"].sokol_path.value.."\\tools\\build\\srlua\\bin\\win64\\glue.exe",
ext = ".exe", ext = ".exe",
sep = "\\", sep = "\\",
luajit = ".\\bin\\win64\\luajit.exe", luajit = config["sokol"].sokol_bin.value.."\\win64\\luajit.exe",
src_dll = ".\\bin\\win64\\*.dll", src_dll = config["sokol"].sokol_bin.value.."\\win64\\*.dll",
src_cfg = ".\\config", src_cfg = ".\\config",
}, }
["OSX"] = { plaform_cmds["OSX"] = {
srlua = "./tools/srlua/macos/srlua", build_path = config["sokol"].sokol_path.value.."/tools/build/",
glue = "./tools/srlua/macos/glue", srlua = config["sokol"].sokol_path.value.."/tools/build/srlua/bin/macos/srlua",
glue = config["sokol"].sokol_path.value.."/tools/build/srlua/bin/macos/glue",
ext = "", ext = "",
sep = "/", sep = "/",
luajit = "./bin/macos/luajit", luajit = config["sokol"].sokol_bin.value.."/macos/luajit",
src_dll = "./bin/macos/*.dylib", src_dll = config["sokol"].sokol_bin.value.."/macos/*.dylib",
src_cfg = "./config", src_cfg = "./config",
}, }
["Linux"] = { plaform_cmds["Linux"] = {
srlua = "./tools/srlua/linux/srlua", build_path = config["sokol"].sokol_path.value.."/tools/build/",
glue = "./tools/srlua/linux/glue", srlua = config["sokol"].sokol_path.value.."/tools/build/srlua/bin/linux/srlua",
glue = config["sokol"].sokol_path.value.."/tools/build/srlua/bin/linux/glue",
ext = "", ext = "",
sep = "/", sep = "/",
luajit = "./bin/linux/luajit", luajit = config["sokol"].sokol_bin.value.."/linux/luajit",
src_dll = "./bin/linux/*.so", src_dll = config["sokol"].sokol_bin.value.."/linux/*.so",
src_cfg = "./config", src_cfg = "./config",
}, }
} end
local cmds = plaform_cmds[ffi.os] -- --------------------------------------------------------------------------------------
local outputfolder = "."..cmds.sep.."tools"..cmds.sep.."bin"..cmds.sep..string.lower(ffi.os)..cmds.sep
local outputexe = "minikeybd_"..ffi.os..cmds.ext
-- Have to build a bytecode "chunk" first. luajit_builder.run = function( config )
local buildchunk = cmds.luajit.." ."..cmds.sep.."tools"..cmds.sep.."combine.lua "
buildchunk = buildchunk.."."..cmds.sep.."lua"..cmds.sep.."minikeybd.lua -L "
buildchunk = buildchunk.."."..cmds.sep.."ffi"..cmds.sep.."hidwin.lua "
buildchunk = buildchunk.."."..cmds.sep.."ffi"..cmds.sep.."lusb.lua "
buildchunk = buildchunk.."."..cmds.sep.."lua"..cmds.sep.."mapcodes.lua "
buildchunk = buildchunk.."."..cmds.sep.."lua"..cmds.sep.."wchar_win.lua "
run_cmd(buildchunk)
-- Build the exe local cmds = plaform_cmds[ffi.os]
local command = cmds.glue.." "..cmds.srlua.." luac.out "..outputfolder..outputexe local outputfolder = config["project"].build_path.value..cmds.sep..string.lower(ffi.os)..cmds.sep
run_cmd(command) local outputexe = config["project"].project_name.value..cmds.ext
local copycmd = "cp -rf "..cmds.src_dll.." "..outputfolder -- Add the startup file
if(ffi.os == "Windows") then copycmd = "xcopy /C /I /Y "..cmds.src_dll.." "..outputfolder end local startfiles = { config["project"].project_start.value }
-- Copy in the dlls/dylib/sos
run_cmd(copycmd)
-- Copy in config folder -- Iterate Lua source to add
local copyconfig = "cp -rf "..cmds.src_cfg.." "..outputfolder..cmds.sep.."config" local libfiles = {}
if(ffi.os == "Windows") then copyconfig = "xcopy /S /E /C /I /Y "..cmds.src_cfg.." "..outputfolder.."config" end for i,v in ipairs(config["assets"].lua) do
run_cmd(copyconfig) if(v.folder) then
else
local rpath = dirtools.get_relative_path(v.name, config["sokol"].sokol_path.value)
if(rpath == nil) then rpath = v.name end
tinsert(libfiles, { name = rpath, fullpath = v.name })
end
end
local combine_out = outputfolder.."combine.out"
combine.run( combine_out, startfiles, libfiles)
-- Build the exe
local command = cmds.glue.." "..cmds.srlua.." "..combine_out.." "..outputfolder..outputexe
run_cmd(command)
local copycmd = "cp -rf "..cmds.src_dll.." "..outputfolder
if(ffi.os == "Windows") then copycmd = "xcopy /C /I /Y "..cmds.src_dll.." "..outputfolder end
-- Copy in the dlls/dylib/sos
run_cmd(copycmd)
-- -- Copy in image files
-- local copyimages = "cp -rf "..cmds.src_cfg.." "..outputfolder..cmds.sep.."config"
-- if(ffi.os == "Windows") then copyimages = "xcopy /S /E /C /I /Y "..cmds.src_cfg.." "..outputfolder.."config" end
-- -- Iterate Lua source to add
-- for i,v in ipairs(config["assets"].lua) do
-- if(v.folder) then
-- else
-- buildchunk = buildchunk..v.name.." "
-- run_cmd(copyimages)
-- end
-- end
-- Copy in data files
end
-- --------------------------------------------------------------------------------------
return luajit_builder
-- --------------------------------------------------------------------------------------

View File

@ -19,11 +19,7 @@
-- --------------------------------------------------------------------------------------------------- -- ---------------------------------------------------------------------------------------------------
local NAME="luac" local combine = {}
local OUTPUT=NAME..".out"
local n=#arg
local m=n
-- --------------------------------------------------------------------------------------------------- -- ---------------------------------------------------------------------------------------------------
-- Load a chunk manually so we can name it -- Load a chunk manually so we can name it
@ -38,37 +34,39 @@ local function loader(filepath)
end end
-- --------------------------------------------------------------------------------------------------- -- ---------------------------------------------------------------------------------------------------
-- Process args
for i=1,n do combine.run = function(tempfile, startup_files, lib_files)
if arg[i]=="-L" then m=i-1 break end
local outfile=tempfile
-- Iterate libs to prepend them to the chunk list
local ts = {}
table.insert(ts, 1, "local t=package.preload;")
for k,v in ipairs(lib_files) do
local modulename = string.gsub(v.name, "^%.[/\\]", "")
modulename = string.gsub(modulename, "[/\\]", "%.")
modulename = string.gsub(modulename, "%.lua", "")
local loaded_chunk = assert(load( loader(v.fullpath),modulename ))
table.insert(ts, ("t['%s']=load(%q);"):format(modulename, string.dump(loaded_chunk)) )
end
-- Add core scripts that will be executed
for k,v in ipairs(startup_files) do
table.insert(ts, ("load(%q)(...);"):format(string.dump(assert(loadfile(v)))) )
end
-- Assemble chunks into one file to dump.
local chunks = assert(load(table.concat(ts)))
local f=assert(io.open(outfile,"wb"))
local data = string.dump(chunks)
f:write(data)
assert(f:close())
end end
-- --------------------------------------------------------------------------------------------------- -- ---------------------------------------------------------------------------------------------------
-- Iterate libs to prepend them to the chunk list
local ts = {}
table.insert(ts, 1, "local t=package.preload;")
for i=m+2,n do return combine
local modulename = string.gsub(arg[i], "^%.[/\\]", "")
modulename = string.gsub(modulename, "[/\\]", "%.")
modulename = string.gsub(modulename, "%.lua", "")
local loaded_chunk = assert(load( loader(arg[i]),modulename ))
table.insert(ts, ("t['%s']=load(%q);"):format(modulename, string.dump(loaded_chunk)) )
end
-- ---------------------------------------------------------------------------------------------------
-- Add core scripts that will be executed
for i=1,m do
table.insert(ts, ("load(%q)(...);"):format(string.dump(assert(loadfile(arg[i])))) )
end
-- ---------------------------------------------------------------------------------------------------
-- Assemble chunks into one file to dump.
local chunks = assert(load(table.concat(ts)))
local f=assert(io.open(OUTPUT,"wb"))
local data = string.dump(chunks)
f:write(data)
assert(f:close())
-- --------------------------------------------------------------------------------------------------- -- ---------------------------------------------------------------------------------------------------

View File

@ -46,27 +46,43 @@ end
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
dirtools.get_drives = function() dirtools.get_drives = function()
local cmd = "wmic logicaldisk get name"
-- Note: Add more -t <filetype> to support different file system mounts
if(ffi.os ~= "Windows") then cmd = "df -h -t ext4 --output=target" end
local drives = {} local drives = {}
local fh = io.popen(cmd, "r") if(ffi.os == "Windows") then
if(fh) then
local data = fh:read("*a") local cmd = "fsutil fsinfo drives"
local count = 0 local fh = io.popen(cmd, "r")
for f in string.gmatch(data, "(.-)\n") do if(fh) then
f = string.gsub(f, "%s+", "") local data = fh:read("*a")
if(count > 0) then fh:close()
if(#f > 0) then if(string.match(data, "Drives: ")) then
data = string.sub(data, 10, -1)
for f in string.gmatch(data, "([^%s]+)") do
f = string.sub(f, 1, -2)
tinsert(drives, f) tinsert(drives, f)
end end
end end
count = count + 1
end end
fh:close() else
-- Note: Add more -t <filetype> to support different file system mounts
local cmd = "df -h -t ext4 --output=target"
local fh = io.popen(cmd, "r")
if(fh) then
local data = fh:read("*a")
local count = 0
for f in string.gmatch(data, "(.-)\n") do
f = string.gsub(f, "%s+", "")
if(count > 0) then
if(#f > 0) then
tinsert(drives, f)
end
end
count = count + 1
end
fh:close()
end
end end
return drives return drives
end end
@ -115,6 +131,18 @@ end
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
dirtools.get_relative_path = function( fullpath, parent_path )
local rpath = nil
local str_st, str_end = string.find( fullpath, parent_path, 1, true )
if(str_st and str_end) then
rpath = string.sub(fullpath, str_end+2, -1)
end
return rpath
end
---------------------------------------------------------------------------------------
dirtools.get_app_path = function( expected_root_folder ) dirtools.get_app_path = function( expected_root_folder )
local base_dir = "." local base_dir = "."