From 9886663594116c5557c1b12c6556242b1afdac1b Mon Sep 17 00:00:00 2001 From: reggie Date: Sun, 14 Jan 2024 13:26:44 -0600 Subject: [PATCH] Fix all logic for Lune 0.8, bump Wax from 0.3.7 -> 0.4.0 --- README.md | 21 +++++++++++---------- lune/lib/data/Version.luau | 2 +- lune/make.luau | 23 +++++++++++++++++++++-- lune/run-tests.luau | 11 +++++++---- lune/wax-remote.luau | 2 +- lune/wax.luau | 6 +++--- 6 files changed, 44 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index bfb84b7..d858688 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ A Fast Runtime Lua 5.1x+/Luau Project Bundler, Using Roblox Models and Module-Require Semantics -*Powered by [Lune](https://github.com/filiptibell/lune), a standalone Luau script runtime* +*Powered by [Lune](https://github.com/lune-org/lune), a standalone Luau script runtime* ## 🎉 About @@ -37,29 +37,30 @@ This is more of a successor to [Maui](https://github.com/latte-soft/maui), a sim * Built-in support for minifying bundled output directly with [Darklua](https://darklua.com) and either our default configuration (no extra steps), or your project's own `.darklua.json/json5` file for making personal tweaks. * Localized/flattened modified globals in closures, meaning `getfenv`/`setfenv` aren't used to modify the script's environment - This also means that in Luau, `safeenv` runtime optimizations are maintained, and closures run 'natively' with no user modification! * Automated CI/deployment pipeline usage in mind, with the `ci-mode` flag; no user confirmation prompts, and exits with a `1` status code upon any errors -* A 'virtual' Roblox-like DOM for scripts that can run completely outside of Roblox, while also allowing module imports (`require()`) with a simulated relative `script` global, or traditional filesystem path strings like in [Lune](https://github.com/filiptibell/lune) or the Lua/Luau CLI REPLs. +* A 'virtual' Roblox-like DOM for scripts that can run completely outside of Roblox, while also allowing module imports (`require()`) with a simulated relative `script` global, or traditional filesystem path strings like in [Lune](https://github.com/lune-org/lune) or the Lua/Luau CLI REPLs. Additionally, you can check out some example "projects" in our [tests](tests) directory if you don't really know what all of this is about, or how to get started.. ## ⚙️ Installation -For your project, you **must** have at least [Lune](https://github.com/filiptibell/lune) installed, most easily done and managed with [Aftman](https://github.com/LPGhatguy/aftman): +For your project, you **must** have at least [Lune](https://github.com/lune-org/lune) installed, most easily done and managed with [Aftman](https://github.com/LPGhatguy/aftman): 1. Goto Aftman's GitHub repository (linked above), and follow its installation instructions for your platform 2. Open the root directory of your project in your system's terminal, and run the following: ``` aftman init -aftman add filiptibell/lune +aftman add lune-org/lune ``` 3. If you've setup Aftman properly, you can now try running `lune --help`, and if all is well you should see something similar to the following in your terminal: ``` $ lune --help -A Luau script runner +A standalone Luau runtime -Usage: lune [OPTIONS] [SCRIPT_PATH] [SCRIPT_ARGS]... +Usage: lune [COMMAND] +... ``` ### Add Wax to Your Lune Scripts @@ -78,7 +79,7 @@ If you already have a "`lune`", "`.lune`", or similar directory in your project ]] -- You set the following string to "latest" (case insensitive), or any version tag --- on Wax's releases page (e.g. "0.3.7") +-- on Wax's releases page (e.g. "0.4.0") local WaxVersion = "latest" ------------------------------------------------------------------------------- @@ -96,14 +97,14 @@ luau.load(net.request(FileLink).body, { ``` -3. Now, when running `lune wax`, you should see something similar to what's in the next section ([Usage](#🚀-usage)) in your terminal. Voilà! +3. Now, when running `lune run wax`, you should see something similar to what's in the next section ([Usage](#🚀-usage)) in your terminal. Voilà! ## 🚀 Usage -From your terminal in the root directory of your project, run `lune wax`, or just `lune ` +From your terminal in the root directory of your project, run `lune run wax`, or just `lune run ` ``` -Wax 0.3.7 +Wax 0.4.0 A Fast Runtime Lua 5.1x+/Luau Project Bundler, Using Roblox Models and Module-Require Semantics USAGE: diff --git a/lune/lib/data/Version.luau b/lune/lib/data/Version.luau index 39870fa..f37f68d 100644 --- a/lune/lib/data/Version.luau +++ b/lune/lib/data/Version.luau @@ -1 +1 @@ -return "0.3.7" +return "0.4.0" diff --git a/lune/make.luau b/lune/make.luau index e69f8de..58d4945 100644 --- a/lune/make.luau +++ b/lune/make.luau @@ -30,6 +30,16 @@ local CodegenHeader = [[ ]=] +local BuildFlags = { + ["build-standalone-wine"] = false +} + +for _, BuildFlag in process.args do + if BuildFlags[BuildFlag] ~= nil then + BuildFlags[BuildFlag] = true + end +end + local CodegenHeaderExtraLines = StringUtils.LineCount(CodegenHeader) - 1 CommandUtils.CheckCommands({"lune", "rojo", "darklua"}) @@ -66,12 +76,21 @@ local function HandleRun(...) end end -HandleRun("lune", {"wax", "bundle", "output=build/wax.dbg.luau", `extra-offset-lines={CodegenHeaderExtraLines}`, "ci-mode=true"}) -HandleRun("lune", {"wax", "bundle", "output=build/wax.luau", "minify=true", "ci-mode=true"}) +HandleRun("lune", {"run", "wax", "bundle", "output=build/wax.dbg.luau", `extra-offset-lines={CodegenHeaderExtraLines}`, "ci-mode=true"}) +HandleRun("lune", {"run", "wax", "bundle", "output=build/wax.luau", "minify=true", "ci-mode=true"}) Log.Info("(Adding CodegenHeader)") WriteFile("build/wax.dbg.luau", CodegenHeader .. fs.readFile("build/wax.dbg.luau")) WriteFile("build/wax.luau", CodegenHeader .. fs.readFile("build/wax.luau")) +Log.Info("Building standalone Wax binary") +HandleRun("lune", {"build", "build/wax.luau"}) + +-- For cross-compilation to Windows from Unix +if BuildFlags["build-standalone-wine"] then + Log.Info("Cross-building standalone Wax binary for Windows (via Wine on Unix)") + HandleRun("wine", {"lune", "build", "build/wax.luau"}) +end + print() Log.Info(`++++++++ Finished build target ++++++++`) diff --git a/lune/run-tests.luau b/lune/run-tests.luau index a9582b2..5600045 100644 --- a/lune/run-tests.luau +++ b/lune/run-tests.luau @@ -43,8 +43,8 @@ for _, TestName in fs.readDir("tests") do pcall(fs.removeFile, OutputScriptPathMin) end - local BundleResult = Run("lune", {"wax", "bundle", `input={RojoProjectFilePath}`, `output={OutputScriptPath}`, "minify=false", "ci-mode=true", "verbose=false"}) - local BundleResultMin = Run("lune", {"wax", "bundle", `input={RojoProjectFilePath}`, `output={OutputScriptPathMin}`, "minify=true", "ci-mode=true", "verbose=false"}) + local BundleResult = Run("lune", {"run", "wax", "bundle", `input={RojoProjectFilePath}`, `output={OutputScriptPath}`, "minify=false", "ci-mode=true", "verbose=false"}) + local BundleResultMin = Run("lune", {"run", "wax", "bundle", `input={RojoProjectFilePath}`, `output={OutputScriptPathMin}`, "minify=true", "ci-mode=true", "verbose=false"}) local BadResult = if not BundleResult.ok then BundleResult elseif not BundleResultMin.ok then BundleResultMin else nil if BadResult and not DoNotExitForErrors then @@ -65,8 +65,11 @@ for _, ScriptPathObject in ScriptFilesToTest do Log.Info(`Running script file "{StringUtils.FileNameFromPath(ScriptPath)}" for all targets..\n`) - local function RunWithCommand(binary: string) - Run(binary, {ScriptPath}, false, function(message: string?) + local function RunWithCommand(binary: string, args: {string}?) + args = args or {} + table.insert(args :: {any}, ScriptPath) + + Run(binary, args, false, function(message: string?) if not DoNotExitForErrors then if message then Log.Error(message) diff --git a/lune/wax-remote.luau b/lune/wax-remote.luau index 51704be..45bf884 100644 --- a/lune/wax-remote.luau +++ b/lune/wax-remote.luau @@ -4,7 +4,7 @@ ]] -- You set the following string to "latest" (case insensitive), or any version tag --- on Wax's releases page (e.g. "0.3.7") +-- on Wax's releases page (e.g. "0.4.0") local WaxVersion = "latest" ------------------------------------------------------------------------------- diff --git a/lune/wax.luau b/lune/wax.luau index f687a8a..e875f75 100644 --- a/lune/wax.luau +++ b/lune/wax.luau @@ -9,7 +9,7 @@ do -- Minimum "recommended" ver local MajorRec, MinorRec, - PatchRec = 0, 7, 11 + PatchRec = 0, 8, 0 local Major, Minor, @@ -21,8 +21,8 @@ do print(`! Can't parse Lune's version on the assumed format from "{_VERSION}", continuing anyway..\n`) else _G.LuneVersion = `{Major}.{Minor}.{Patch}` - if Major < MajorRec or Minor < MinorRec or Patch < PatchRec then - print(`! Lune version "{_G.LuneVersion}" detected, Wax currently recommends Lune {MajorRec}.{MinorRec}.{PatchRec} or higher, continuing anyway..\n`) + if Major < MajorRec or (Minor < MinorRec and Major <= MajorRec) or (Patch < PatchRec and Minor <= MinorRec and Major <= MajorRec) then + print(`! Lune version "{_G.LuneVersion}" detected, but Wax currently recommends Lune {MajorRec}.{MinorRec}.{PatchRec} or higher, continuing anyway..\n`) end end end