diff options
| author | Saikari <[email protected]> | 2026-02-05 22:48:58 +0300 |
|---|---|---|
| committer | Saikari <[email protected]> | 2026-02-05 22:48:58 +0300 |
| commit | bb7879934dca1ef7b26584f4dfadc29462d5a059 (patch) | |
| tree | 3cdb88086027d96f6d3e12dea0038ae361709df4 /xmake/core | |
| parent | 728ead07ff58cd9d8330075414cfe21b1034b757 (diff) | |
create policy besides pe parser
Diffstat (limited to 'xmake/core')
| -rw-r--r-- | xmake/core/project/policy.lua | 2 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/os.lua | 19 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/winos.lua | 1 |
3 files changed, 22 insertions, 0 deletions
diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua index 5123f0a5c..3f24d9a0f 100644 --- a/xmake/core/project/policy.lua +++ b/xmake/core/project/policy.lua @@ -34,6 +34,8 @@ function policy.policies() local policies = policy._POLICIES if not policies then policies = { + -- Enable/Disable Windows Error Reporting Dialogs + ["run.gui_error_dialogs"] = {description = "Enable Windows Error Reporting Dialogs during execution.", default = false, type = "boolean"}, -- We will check and ignore all unsupported flags by default, but we can also pass `{force = true}` to force to set flags, e.g. add_ldflags("-static", {force = true}) ["check.auto_ignore_flags"] = {description = "Enable check and ignore unsupported flags automatically.", default = true, type = "boolean"}, -- We will map gcc flags to the current compiler and linker by default. diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua index 197356ffa..5718f8dec 100644 --- a/xmake/core/sandbox/modules/os.lua +++ b/xmake/core/sandbox/modules/os.lua @@ -494,7 +494,24 @@ function sandbox_os.execv(program, argv, opt) -- run it opt = opt or {} + + -- check policy for GUI error dialogs (Windows only) + local old_mode + local winos + if os.is_host("windows") and opt.winos_error_mode_gui then + winos = require("sandbox/modules/winos") + if winos.seterrormode then + old_mode = winos.seterrormode(0) + end + end + local ok, errors = os.execv(program, argv, opt) + + -- restore error mode + if old_mode then + winos.seterrormode(old_mode) + end + if ok ~= 0 and not opt.try then -- get command @@ -509,6 +526,8 @@ function sandbox_os.execv(program, argv, opt) local missing_dlls = _get_missing_dlls(program) if #missing_dlls > 0 then errors = string.format("execv(%s) failed(%d): system error 0xC0000135 (STATUS_DLL_NOT_FOUND).\nThe application failed to start because the following DLLs were not found:\n - %s\nPlease check your PATH environment variable or copy the missing DLLs to the executable directory.", cmd, ok, table.concat(missing_dlls, "\n - ")) + else + errors = string.format("execv(%s) failed(%d): system error 0xC0000135 (STATUS_DLL_NOT_FOUND).\nThe application failed to start because a dependent DLL was not found.\nPlease check your PATH environment variable or copy the missing DLL to the executable directory.", cmd, ok) end else errors = string.format("execv(%s) failed(%d)", cmd, ok) diff --git a/xmake/core/sandbox/modules/winos.lua b/xmake/core/sandbox/modules/winos.lua index eddcf91d4..862ed9a8b 100644 --- a/xmake/core/sandbox/modules/winos.lua +++ b/xmake/core/sandbox/modules/winos.lua @@ -35,6 +35,7 @@ sandbox_winos.logical_drives = winos.logical_drives sandbox_winos.cmdargv = winos.cmdargv sandbox_winos.processes = winos.processes sandbox_winos.inherit_handles_safely = winos.inherit_handles_safely +sandbox_winos.seterrormode = winos.seterrormode -- get windows system version function sandbox_winos.version() |
