Use Lune for parallel corescript compilation and formatting improvements

This commit is contained in:
Lewin Kelly 2024-03-16 23:36:41 +00:00
parent ef74699fe8
commit 9900e991fa
6 changed files with 318 additions and 22 deletions

View File

@ -1,3 +1,3 @@
# Corescripts
After installing Aftman and running `aftman install`, run `./corescripts/compile.sh` to compile the corescripts and libraries from this directory to ./corescripts/processed.
After installing Aftman and running `aftman install`, run `lune run ./corescripts/compile.luau` to compile the corescripts and libraries from this directory to ./corescripts/processed.

81
compile.luau Normal file
View File

@ -0,0 +1,81 @@
--!strict
-- There's issues with running this file from windows so idk
local fs = require "@lune/fs"
local process = require "@lune/process"
local stdio = require "@lune/stdio"
local task = require "@lune/task"
local colour = stdio.color
local green = colour "green"
local red = colour "red"
local reset = colour "reset"
local normalCores = {}
local libraryCores = {
"Fusion/init.luau",
"Red/init.luau",
}
local otherCores = {}
-- Allow for running from the base or corescripts directories
local cwd = process.cwd
local fromCoresDir = not not string.match(cwd, "corescripts/$")
local normalCoresDir = if fromCoresDir then "./luau" else "./corescripts/luau"
for _, core in ipairs(fs.readDir(normalCoresDir)) do
table.insert(
-- normalCores should be ones with numbers
if string.match(core, "%d+%.lua") then normalCores else otherCores,
core
)
end
local function processCores(
scripts: { string },
startDir: string,
endDir: string,
config: "lines" | "dense",
libraries: boolean?
)
local configFile = if fromCoresDir
then `../{config}.json5`
else `{config}.json5`
local coresDir = if fromCoresDir then "." else "./corescripts"
for i, core in ipairs(scripts) do
local newCore = if libraries
then `{10000000 + i}.lua`
else string.gsub(core, "%.luau$", ".lua")
task.spawn(function()
local cmd = process.spawn("darklua", {
"process",
"-c",
configFile,
`{coresDir}/{startDir}/{core}`,
`{coresDir}/{endDir}/{newCore}`,
})
print(
if cmd.ok
then `{green}Processed {core}{reset}`
else `{red}Error processing {core}: {cmd.stderr}{reset}`
)
end)
end
end
task.spawn(function()
processCores(libraryCores, "Libraries", "processed", "dense", true)
end)
task.spawn(function()
processCores(normalCores, "luau", "processed", "dense")
end)
task.spawn(function()
processCores(otherCores, "luau", "processed", "lines")
end)

View File

@ -1,13 +0,0 @@
echo "Processing corescripts..."
for file in ./corescripts/luau/[0-9]*.luau; do
darklua process -c dense.json5 $file ./corescripts/processed/$(basename "${file::-1}")
done
echo "Processing libraries..."
darklua process -c dense.json5 ./corescripts/Libraries/Fusion/init.luau ./corescripts/processed/10000001.lua
darklua process -c dense.json5 ./corescripts/Libraries/Red/init.luau ./corescripts/processed/10000002.lua
echo "Processing other corescripts..."
for file in ./corescripts/luau/[a-z]*.luau; do
darklua process -c lines.json5 $file ./corescripts/processed/$(basename "${file::-1}")
done

View File

@ -7042,7 +7042,8 @@ declare class ScriptContext extends Instance
function StartScriptProfiling(self, frequency: number?): nil
function StopScriptProfiling(self): string
function AddCoreScript(self, id: number, player: Player, name: string): nil
-- player or instance
function AddCoreScript(self, id: number, instance: Instance, name: string): nil
function RegisterLibrary(self, name: string, id: string): nil
function LibraryRegistrationComplete(self): nil
end
@ -8897,6 +8898,236 @@ export type Red = {
Load: (self: Red, Script: LuaSourceContainer) -> RedCore,
}
-- just plain useful
export type InstanceName =
"Accoutrement"
| "Hat"
| "AdvancedDragger"
| "Animation"
| "CurveAnimation"
| "KeyframeSequence"
| "AnimationController"
| "AnimationRigData"
| "Animator"
| "AudioDeviceInput"
| "AudioDeviceOutput"
| "AudioDistortion"
| "AudioEcho"
| "AudioEmitter"
| "AudioEqualizer"
| "AudioFader"
| "AudioFlanger"
| "AudioListener"
| "AudioPitchShifter"
| "AudioPlayer"
| "AudioReverb"
| "AudioSearchParams"
| "Backpack"
| "BindableEvent"
| "BindableFunction"
| "BodyAngularVelocity"
| "BodyForce"
| "BodyGyro"
| "BodyPosition"
| "BodyThrust"
| "BodyVelocity"
| "RocketPropulsion"
| "BubbleChatMessageProperties"
| "Camera"
| "BodyColors"
| "CharacterMesh"
| "Pants"
| "Shirt"
| "ShirtGraphic"
| "Skin"
| "ClickDetector"
| "DragDetector"
| "Configuration"
| "AngularVelocity"
| "AnimationConstraint"
| "BallSocketConstraint"
| "HingeConstraint"
| "LineForce"
| "LinearVelocity"
| "PlaneConstraint"
| "Plane"
| "RigidConstraint"
| "RodConstraint"
| "RopeConstraint"
| "CylindricalConstraint"
| "PrismaticConstraint"
| "SpringConstraint"
| "Torque"
| "TorsionSpringConstraint"
| "UniversalConstraint"
| "HumanoidController"
| "SkateboardController"
| "VehicleController"
| "AirController"
| "ClimbController"
| "GroundController"
| "SwimController"
| "ControllerManager"
| "CustomEvent"
| "CustomEventReceiver"
| "CylinderMesh"
| "DynamicMesh"
| "FileMesh"
| "SpecialMesh"
| "DataStoreIncrementOptions"
| "DataStoreOptions"
| "DataStoreSetOptions"
| "DebuggerWatch"
| "Dialog"
| "DialogChoice"
| "Dragger"
| "ExperienceInviteOptions"
| "Explosion"
| "Decal"
| "Texture"
| "Hole"
| "MotorFeature"
| "Fire"
| "CSGDictionaryService"
| "NonReplicatedCSGDictionaryService"
| "ForceField"
| "FunctionalTest"
| "GetTextBoundsParams"
| "Frame"
| "ImageButton"
| "TextButton"
| "ImageLabel"
| "TextLabel"
| "TextBox"
| "VideoFrame"
| "ViewportFrame"
| "BillboardGui"
| "ScreenGui"
| "GuiMain"
| "AdGui"
| "SurfaceGui"
| "FloorWire"
| "SelectionBox"
| "BoxHandleAdornment"
| "ConeHandleAdornment"
| "CylinderHandleAdornment"
| "ImageHandleAdornment"
| "LineHandleAdornment"
| "SphereHandleAdornment"
| "WireframeHandleAdornment"
| "ParabolaAdornment"
| "SelectionSphere"
| "ArcHandles"
| "Handles"
| "SurfaceSelection"
| "SelectionPartLasso"
| "SelectionPointLasso"
| "HeightmapImporterService"
| "HiddenSurfaceRemovalAsset"
| "Humanoid"
| "RotateP"
| "RotateV"
| "Glue"
| "ManualGlue"
| "ManualWeld"
| "Motor"
| "Motor6D"
| "Rotate"
| "Snap"
| "VelocityMotor"
| "Weld"
| "Keyframe"
| "KeyframeMarker"
| "PointLight"
| "SpotLight"
| "SurfaceLight"
| "Script"
| "LocalScript"
| "ModuleScript"
| "MarkerCurve"
| "MemoryStoreService"
| "Message"
| "Hint"
| "CornerWedgePart"
| "Part"
| "FlagStand"
| "Seat"
| "SkateboardPlatform"
| "SpawnLocation"
| "WedgePart"
| "PartOperation"
| "IntersectOperation"
| "NegateOperation"
| "UnionOperation"
| "TrussPart"
| "VehicleSeat"
| "Model"
| "HopperBin"
| "Tool"
| "Flag"
| "WorldModel"
| "PartOperationAsset"
| "PathfindingLink"
| "PathfindingModifier"
| "Player"
| "PluginAction"
| "PluginCapabilities"
| "NumberPose"
| "Pose"
| "ReflectionMetadata"
| "ReflectionMetadataCallbacks"
| "ReflectionMetadataClasses"
| "ReflectionMetadataEnums"
| "ReflectionMetadataEvents"
| "ReflectionMetadataFunctions"
| "ReflectionMetadataClass"
| "ReflectionMetadataEnum"
| "ReflectionMetadataEnumItem"
| "ReflectionMetadataMember"
| "ReflectionMetadataProperties"
| "ReflectionMetadataYieldFunctions"
| "RemoteEvent"
| "RemoteFunction"
| "RenderingTest"
| "BuoyancySensor"
| "ControllerPartSensor"
| "Sky"
| "Smoke"
| "Sound"
| "Sparkles"
| "StandalonePluginScripts"
| "StarterGear"
| "StudioCallout"
| "StudioObjectBase"
| "StudioWidget"
| "StyleDerive"
| "StyleLink"
| "SurfaceAppearance"
| "Team"
| "TeleportOptions"
| "TerrainDetail"
| "TerrainRegion"
| "TestService"
| "TextChannel"
| "TextChatCommand"
| "TextChatMessageProperties"
| "TrackerStreamAnimation"
| "BinaryStringValue"
| "BoolValue"
| "BrickColorValue"
| "CFrameValue"
| "Color3Value"
| "DoubleConstrainedValue"
| "IntConstrainedValue"
| "IntValue"
| "NumberValue"
| "ObjectValue"
| "RayValue"
| "StringValue"
| "Vector3Value"
| "Wire"
declare LoadLibrary: ((libraryName: "RbxFusion") -> Fusion) & ((libraryName: "RbxRed") -> Red) & ((libraryName: string) -> any)
declare function settings(): GlobalSettings

View File

@ -2,6 +2,7 @@
print "[Mercury]: Loaded corescript 37801172"
local scriptContext = game:GetService "ScriptContext"
local CoreGui = game:GetService "CoreGui"
-- Creates all neccessary scripts for the gui on initial load, everything except build tools
-- Please note that these are loaded in a specific order to diminish errors/perceived load time by user
@ -19,8 +20,8 @@ local function waitForChild(instance, name)
end
end
waitForChild(game:GetService "CoreGui", "RobloxGui")
local screenGui = game:GetService("CoreGui"):FindFirstChild "RobloxGui"
waitForChild(CoreGui, "RobloxGui")
local screenGui = CoreGui:FindFirstChild "RobloxGui"
-- ToolTipper (creates tool tips for gui)
scriptContext:AddCoreScript(36868950, screenGui, "CoreScripts/ToolTip")

View File

@ -54,10 +54,6 @@ local result, _ = pcall(function()
end)
if not result then
pcall(function()
ScriptContext:AddCoreScript(
37801172,
game:GetService "ScriptContext",
"StarterScript"
)
ScriptContext:AddCoreScript(37801172, ScriptContext, "StarterScript")
end)
end