@@ -9,7 +9,7 @@ File: exelua.lua
99_VERSION = 0.1
1010
1111--- Help information
12- _HELP_INFO = " exelua help: \n " .. " Get version: exelua -v\n " .. " Compile to exe: exelua -c `input Lua file path` `output exe file path`"
12+ _HELP_INFO = " exelua: help\n " .. " Get version>> exelua -v\n " .. " Compile to exe>> exelua -c `input Lua file path` `output exe file path`"
1313
1414--- Check if a file exists
1515--- @param filepath string : The file path to check
@@ -38,10 +38,12 @@ local function selfCheck()
3838 if result :match (" 64" ) then
3939 arch = " x64"
4040 else
41- error (" >>>ERR<<< exelua can only run on 64-bit systems" )
41+ print (" exelua: can only run on 64-bit systems" )
42+ error (" >>>PLATFORM ERR<<<" )
4243 end
4344 else
44- error (" >>>ERR<<< exelua can only run on Windows platforms" )
45+ print (" exelua: can only run on Windows platforms" )
46+ error (" >>>PLATFORM ERR<<<" )
4547 end
4648
4749 -- Check files in the srlua directory
@@ -51,17 +53,18 @@ local function selfCheck()
5153 for _ , filename in ipairs (files ) do
5254 local filepath = base_path .. filename
5355 if not file_exists (filepath ) then
54- error (" >>>ERR<<< Missing srlua file: " .. filename )
56+ print (" exelua: missing srlua file: " .. filename )
57+ error (" >>>RUNTIME ERR<<<" )
5558 end
5659 end
5760end
5861
5962--- Ensure file extension
6063--- @param filepath string : The file path
6164--- @param ext string : The extension to check and add (e.g. , " .lua" or " .exe" )
62- local function ensure_extension (filepath , ext )
65+ local function ensureExtension (filepath , ext )
6366 if not filepath :match (" %." .. ext :sub (2 ) .. " $" ) then
64- print (" >>>WARN<<< File path is missing extension, automatically added: " .. filepath .. ext )
67+ print (" exelua: auto-completion of extension " .. ext .. " for ` " .. filepath .. " ` " )
6568 return filepath .. ext
6669 end
6770 return filepath
7275--- @param outputExe string : The output exe file path
7376local function convert (inputLua , outputExe )
7477 -- Ensure the validity of the input Lua file and output exe file
75- inputLua = ensure_extension (inputLua , " .lua" )
76- outputExe = ensure_extension (outputExe , " .exe" )
78+ inputLua = ensureExtension (inputLua , " .lua" )
79+ outputExe = ensureExtension (outputExe , " .exe" )
7780
7881 -- Check if the input file exists
7982 if not file_exists (inputLua ) then
80- error (" >>>ERR<<< Input Lua file not found: " .. inputLua )
83+ print (" exelua: input .lua not find: " .. inputLua )
84+ error (" >>>FILEEXISTS ERR<<<" )
8185 end
8286
8387 -- Get paths for srlua and srglue
84- local base_path = " ./ srlua/ "
88+ local base_path = " srlua\\ "
8589 local srglue = base_path .. " srglue.exe"
86- local srlua_main = base_path .. " srlua.exe"
90+ local srluaMain = base_path .. " srlua.exe"
8791
8892 -- Ensure necessary files exist
8993 if not file_exists (srglue ) then
90- error (" >>>ERR<<< Missing srglue tool: " .. srglue )
94+ print (" exelua: missing " .. srglue )
95+ error (" >>>RUNTIME ERR<<<" )
9196 end
92- if not file_exists (srlua_main ) then
93- error (" >>>ERR<<< Missing srlua main program: " .. srlua_main )
97+ if not file_exists (srluaMain ) then
98+ print (" exelua: missing " .. srluaMain )
99+ error (" >>>RUNTIME ERR<<<" )
94100 end
95101
96102 -- Build the command
97- local cmd = string.format (' %s %s %s %s' , srglue , srlua_main , inputLua , outputExe )
98- print (" >>>INFO<<< Generating executable file... " )
99- print (" >>>INFO<<< Executing command: " .. cmd )
103+ local cmd = string.format (' %s %s %s %s' , srglue , srluaMain , inputLua , outputExe )
104+ print (" exelua: generating executable file" )
105+ print (" exelua: executing command: " .. cmd )
100106
101107 -- Execute the command
102108 local result = os.execute (cmd )
103109 if result == 0 then
104- print (" >>>INFO<<< Executable file generated successfully: " .. outputExe )
110+ print (" exelua: executable file generated successfully: " .. outputExe )
105111 else
106- error (" >>>ERR<<< Failed to generate executable file" )
112+ print (" exelua: failed to generated" )
113+ error (" >>>RUNTIME ERR<<<" )
107114 end
108115end
109116
0 commit comments