From 9900e991fae704bba7ff335cf0d7ec3b149dcb05 Mon Sep 17 00:00:00 2001 From: Lewin Kelly Date: Sat, 16 Mar 2024 23:36:41 +0000 Subject: [PATCH] Use Lune for parallel corescript compilation and formatting improvements --- README.md | 2 +- compile.luau | 81 ++++++++++++++++ compile.sh | 13 --- defs.d.lua | 233 ++++++++++++++++++++++++++++++++++++++++++++- luau/37801172.luau | 5 +- luau/studio.luau | 6 +- 6 files changed, 318 insertions(+), 22 deletions(-) create mode 100644 compile.luau delete mode 100644 compile.sh diff --git a/README.md b/README.md index 43cdb7d..3e9591a 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/compile.luau b/compile.luau new file mode 100644 index 0000000..902cf4b --- /dev/null +++ b/compile.luau @@ -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) diff --git a/compile.sh b/compile.sh deleted file mode 100644 index b2bc33c..0000000 --- a/compile.sh +++ /dev/null @@ -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 diff --git a/defs.d.lua b/defs.d.lua index 1996a47..9599ea5 100644 --- a/defs.d.lua +++ b/defs.d.lua @@ -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 diff --git a/luau/37801172.luau b/luau/37801172.luau index c88341a..fee015c 100644 --- a/luau/37801172.luau +++ b/luau/37801172.luau @@ -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") diff --git a/luau/studio.luau b/luau/studio.luau index b3290b1..1577b4b 100644 --- a/luau/studio.luau +++ b/luau/studio.luau @@ -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