Skip to content

Commit

Permalink
Fix all logic for Lune 0.8, bump Wax from 0.3.7 -> 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
regginator committed Jan 14, 2024
1 parent 4619584 commit 9886663
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 21 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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"

-------------------------------------------------------------------------------
Expand All @@ -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 <path/to/wax.luau>`
From your terminal in the root directory of your project, run `lune run wax`, or just `lune run <path/to/wax.luau>`

```
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:
Expand Down
2 changes: 1 addition & 1 deletion lune/lib/data/Version.luau
Original file line number Diff line number Diff line change
@@ -1 +1 @@
return "0.3.7"
return "0.4.0"
23 changes: 21 additions & 2 deletions lune/make.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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"})
Expand Down Expand Up @@ -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 ++++++++`)
11 changes: 7 additions & 4 deletions lune/run-tests.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lune/wax-remote.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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"

-------------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions lune/wax.luau
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ do
-- Minimum "recommended" ver
local MajorRec,
MinorRec,
PatchRec = 0, 7, 11
PatchRec = 0, 8, 0

local Major,
Minor,
Expand All @@ -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
Expand Down

0 comments on commit 9886663

Please sign in to comment.