Skip to content
This repository was archived by the owner on Apr 13, 2026. It is now read-only.

Commit b6aaa69

Browse files
committed
Finish exelua
1 parent d13b564 commit b6aaa69

File tree

6 files changed

+50
-20
lines changed

6 files changed

+50
-20
lines changed

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"Lua.diagnostics.disable": [
3+
"need-check-nil"
4+
]
5+
}

exelua/release/exelua-0.1.zip

76.4 KB
Binary file not shown.

exelua/release/srlua/srglue.exe

-89.1 KB
Binary file not shown.

exelua/src/exelua.lua

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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
5760
end
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
@@ -72,38 +75,42 @@ end
7275
--- @param outputExe string: The output exe file path
7376
local 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
108115
end
109116

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
11
r"""
2-
2+
lua_to_exe项目源码
3+
:author: WaterRun
4+
:time: 2025-03-20
5+
:file: lua_to_exe.py
36
"""
7+
import subprocess
8+
import tkinter
9+
10+
def self_check():
11+
r"""
12+
进行自检
13+
:raise RuntimeError: 如果自检过程出现错误
14+
"""
415

516
def gui():
617
r"""
18+
由tkinter实现的GUI界面,提供了交互式的操作转换功能
719
"""
820

921
def lua_to_exe(lua: str, exe: str):
1022
r"""
23+
将指定的.lua文件转换为.exe
24+
:param lua: 待转换的lua文件路径
25+
:param exe: 转换后的exe文件路径
26+
:raise FileExistsError: 如果输入或输出的文件不存在
27+
:raise RuntimeError: 如果转换过程中出现其它问题
1128
"""
29+
self_check()
1230

0 commit comments

Comments
 (0)