From cfd7be34deb7f10782fe7ce805280b425b355373 Mon Sep 17 00:00:00 2001 From: David Cruz Date: Tue, 7 Apr 2026 12:14:17 -0700 Subject: [PATCH 1/4] feat: global make bin resolution and ship it for windows Resolves #124 --- packages/lde-core/src/global/init.lua | 11 +++++++++++ packages/lde-core/src/package/rockspec.lua | 7 ++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/lde-core/src/global/init.lua b/packages/lde-core/src/global/init.lua index 3691a71..84fa91c 100644 --- a/packages/lde-core/src/global/init.lua +++ b/packages/lde-core/src/global/init.lua @@ -78,6 +78,17 @@ function global.getGCCBin() return "gcc" end +function global.getMakeBin() + if jit.os == "Windows" then + local mingwMake = path.join(global.getMingwDir(), "bin", "mingw32-make.exe") + if fs.exists(mingwMake) then + return mingwMake + end + end + + return "make" +end + function global.getRegistryDir() return path.join(global.getDir(), "registry") end diff --git a/packages/lde-core/src/package/rockspec.lua b/packages/lde-core/src/package/rockspec.lua index 8a378d7..fabbc07 100644 --- a/packages/lde-core/src/package/rockspec.lua +++ b/packages/lde-core/src/package/rockspec.lua @@ -150,7 +150,8 @@ local function openRockspec(dir, rockspecPath) local modulesDir = path.dirname(outputDir) if buildType == "make" then - if not process.exec("make", { "--version" }) then + local makeBin = lde.global.getMakeBin() + if not process.exec(makeBin, { "--version" }) then return nil, "Package '" .. (spec.package or "?") .. "' requires 'make' to build, but it was not found." .. " Install make (e.g. build-essential on Debian/Ubuntu, Xcode Command Line Tools on macOS)." end @@ -190,7 +191,7 @@ local function openRockspec(dir, rockspecPath) local buildArgs = buildVarList(spec.build.variables) if buildTarget ~= "" then buildArgs[#buildArgs + 1] = buildTarget end - local code, stdout, stderr = process.exec("make", buildArgs, { cwd = dir }) + local code, stdout, stderr = process.exec(makeBin, buildArgs, { cwd = dir }) if code ~= 0 then local msg = (stderr ~= "" and stderr) or (stdout ~= "" and stdout) or ("exited with code " .. code) return nil, "make failed: " .. msg @@ -199,7 +200,7 @@ local function openRockspec(dir, rockspecPath) local installArgs = buildVarList(spec.build.install_variables) installArgs[#installArgs + 1] = installTarget - code, stdout, stderr = process.exec("make", installArgs, { cwd = dir }) + code, stdout, stderr = process.exec(makeBin, installArgs, { cwd = dir }) if code ~= 0 then local msg = (stderr ~= "" and stderr) or (stdout ~= "" and stdout) or ("exited with code " .. code) return nil, "make install failed: " .. msg From 1eea4e1b172558bb228207bd31c37733cf3727d5 Mon Sep 17 00:00:00 2001 From: David Cruz Date: Tue, 7 Apr 2026 12:42:18 -0700 Subject: [PATCH 2/4] feat: add shell lookup for windows Warns you if it can't find a posix compatible shell and uses Git For Windows' shell if you have it. --- packages/lde-core/src/global/init.lua | 9 +++++++++ packages/lde-core/src/package/rockspec.lua | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/packages/lde-core/src/global/init.lua b/packages/lde-core/src/global/init.lua index 84fa91c..0b23059 100644 --- a/packages/lde-core/src/global/init.lua +++ b/packages/lde-core/src/global/init.lua @@ -89,6 +89,15 @@ function global.getMakeBin() return "make" end +function global.getShellBin() + if jit.os == "Windows" then + local gitSh = "C:\\Program Files\\Git\\usr\\bin\\sh.exe" + if fs.exists(gitSh) then + return gitSh + end + end +end + function global.getRegistryDir() return path.join(global.getDir(), "registry") end diff --git a/packages/lde-core/src/package/rockspec.lua b/packages/lde-core/src/package/rockspec.lua index fabbc07..46a2c7c 100644 --- a/packages/lde-core/src/package/rockspec.lua +++ b/packages/lde-core/src/package/rockspec.lua @@ -8,6 +8,7 @@ local http = require("http") local path = require("path") local process = require("process2") local util = require("util") +local ansi = require("ansi") ---@param dir string? ---@param rockspecPath string? # Path to the rockspec file; if nil, scanned from dir @@ -156,6 +157,11 @@ local function openRockspec(dir, rockspecPath) " Install make (e.g. build-essential on Debian/Ubuntu, Xcode Command Line Tools on macOS)." end + local shellBin = lde.global.getShellBin() + if jit.os == "Windows" and not shellBin then + ansi.printf("{yellow}Warning: sh.exe not found. Make builds may fail. Install Git for Windows to fix this.\n") + end + local luajitPath = sea.getLuajitPath() local luajitInclude = path.join(luajitPath, "include") local stdVars = { @@ -189,6 +195,7 @@ local function openRockspec(dir, rockspecPath) local installTarget = spec.build.install_target or "install" local buildArgs = buildVarList(spec.build.variables) + if shellBin then buildArgs[#buildArgs + 1] = "SHELL=" .. shellBin end if buildTarget ~= "" then buildArgs[#buildArgs + 1] = buildTarget end local code, stdout, stderr = process.exec(makeBin, buildArgs, { cwd = dir }) @@ -198,6 +205,7 @@ local function openRockspec(dir, rockspecPath) end local installArgs = buildVarList(spec.build.install_variables) + if shellBin then installArgs[#installArgs + 1] = "SHELL=" .. shellBin end installArgs[#installArgs + 1] = installTarget code, stdout, stderr = process.exec(makeBin, installArgs, { cwd = dir }) From 06945494e4717e6c34aecb9b13520415e4ff6244 Mon Sep 17 00:00:00 2001 From: David Cruz Date: Tue, 7 Apr 2026 12:46:04 -0700 Subject: [PATCH 3/4] fix(windows): convert paths to be posix compliant --- packages/lde-core/src/package/rockspec.lua | 31 +++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/packages/lde-core/src/package/rockspec.lua b/packages/lde-core/src/package/rockspec.lua index 46a2c7c..5273a3c 100644 --- a/packages/lde-core/src/package/rockspec.lua +++ b/packages/lde-core/src/package/rockspec.lua @@ -153,29 +153,32 @@ local function openRockspec(dir, rockspecPath) if buildType == "make" then local makeBin = lde.global.getMakeBin() if not process.exec(makeBin, { "--version" }) then - return nil, "Package '" .. (spec.package or "?") .. "' requires 'make' to build, but it was not found." .. + return nil, + "Package '" .. (spec.package or "?") .. "' requires 'make' to build, but it was not found." .. " Install make (e.g. build-essential on Debian/Ubuntu, Xcode Command Line Tools on macOS)." end local shellBin = lde.global.getShellBin() if jit.os == "Windows" and not shellBin then - ansi.printf("{yellow}Warning: sh.exe not found. Make builds may fail. Install Git for Windows to fix this.\n") + ansi.printf( + "{yellow}Warning: sh.exe not found. Make builds may fail. Install Git for Windows to fix this.\n") end local luajitPath = sea.getLuajitPath() local luajitInclude = path.join(luajitPath, "include") + local function toShPath(p) return p:gsub("\\", "/") end local stdVars = { - LUA_INCDIR = luajitInclude, - LUA_LIBDIR = path.join(luajitPath, "lib"), + LUA_INCDIR = toShPath(luajitInclude), + LUA_LIBDIR = toShPath(path.join(luajitPath, "lib")), LUALIB = "libluajit.a", CFLAGS = "-fPIC", LIBFLAG = "-shared", - INST_LIBDIR = modulesDir, - INST_LUADIR = modulesDir, - LUADIR = modulesDir, - LIBDIR = modulesDir, - PREFIX = modulesDir, - LUA = env.execPath() + INST_LIBDIR = toShPath(modulesDir), + INST_LUADIR = toShPath(modulesDir), + LUADIR = toShPath(modulesDir), + LIBDIR = toShPath(modulesDir), + PREFIX = toShPath(modulesDir), + LUA = toShPath(env.execPath()) } local function subst(s) @@ -453,8 +456,12 @@ local function openRockspec(dir, rockspecPath) end end - return lde.Package.Config.new({ name = spec.package, version = spec.version, bin = resolvedBin, dependencies = - deps }) + return lde.Package.Config.new({ + name = spec.package, + version = spec.version, + bin = resolvedBin, + dependencies = deps + }) end return pkg, nil From 96f96cbd7098c539535d6df2ec677034c30faa07 Mon Sep 17 00:00:00 2001 From: David Cruz Date: Tue, 7 Apr 2026 12:51:15 -0700 Subject: [PATCH 4/4] fix(windows): add shelldir to PATH while building to make use of msys2 binaries --- packages/lde-core/src/package/rockspec.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/lde-core/src/package/rockspec.lua b/packages/lde-core/src/package/rockspec.lua index 5273a3c..ddfb942 100644 --- a/packages/lde-core/src/package/rockspec.lua +++ b/packages/lde-core/src/package/rockspec.lua @@ -196,12 +196,17 @@ local function openRockspec(dir, rockspecPath) local buildTarget = spec.build.build_target or "" local installTarget = spec.build.install_target or "install" + local makeEnv = nil + if shellBin then + local shellDir = path.dirname(shellBin) + makeEnv = { PATH = shellDir .. ";" .. (os.getenv("PATH") or "") } + end local buildArgs = buildVarList(spec.build.variables) if shellBin then buildArgs[#buildArgs + 1] = "SHELL=" .. shellBin end if buildTarget ~= "" then buildArgs[#buildArgs + 1] = buildTarget end - local code, stdout, stderr = process.exec(makeBin, buildArgs, { cwd = dir }) + local code, stdout, stderr = process.exec(makeBin, buildArgs, { cwd = dir, env = makeEnv }) if code ~= 0 then local msg = (stderr ~= "" and stderr) or (stdout ~= "" and stdout) or ("exited with code " .. code) return nil, "make failed: " .. msg @@ -211,7 +216,7 @@ local function openRockspec(dir, rockspecPath) if shellBin then installArgs[#installArgs + 1] = "SHELL=" .. shellBin end installArgs[#installArgs + 1] = installTarget - code, stdout, stderr = process.exec(makeBin, installArgs, { cwd = dir }) + code, stdout, stderr = process.exec(makeBin, installArgs, { cwd = dir, env = makeEnv }) if code ~= 0 then local msg = (stderr ~= "" and stderr) or (stdout ~= "" and stdout) or ("exited with code " .. code) return nil, "make install failed: " .. msg