diff --git a/.github/workflows/build-samples.yml b/.github/workflows/build-samples.yml new file mode 100644 index 00000000..da97ec29 --- /dev/null +++ b/.github/workflows/build-samples.yml @@ -0,0 +1,99 @@ +# Builds the sample projects on multiple targets to check for compiler errors. + +name: Build Samples + +on: + #push: + pull_request: + workflow_dispatch: + +jobs: + build: + strategy: + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + target: [cpp, html5, hl] + fail-fast: false + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@v6.0.2 + + - name: Setup Haxe + uses: FunkinCrew/ci-haxe@v3 + with: + haxe-version: 4.3.7 + + - name: Setup hmm.json for Samples + working-directory: ./samples + run: haxe run.hxml + + - name: Cache Haxelibs + uses: actions/cache@v6 + with: + path: ./samples/.haxelib + key: haxelib-${{ hashFiles('samples/hmm.json') }} + enableCrossOsArchive: true + restore-keys: | + haxelib- + + - name: Setup HMM + run: | + haxelib --global --quiet --never update haxelib + haxelib --global fixrepo + haxelib --global --quiet install hmm + haxelib --global run hmm setup + + - name: Install sample dependencies + working-directory: ./samples + run: | + hmm install --quiet + haxelib fixrepo + + - name: Build Flixel Sample + working-directory: ./samples/flixel + run: | + haxelib run lime build ${{ matrix.target }} --no-output + + - name: Build ZIP Flixel Sample + working-directory: ./samples/flixel_zip + run: | + haxelib run lime build ${{ matrix.target }} --no-output + + - name: Build Heaps Sample + if: matrix.target == 'hl' + working-directory: ./samples/heaps + run: | + haxe hl.hxml + + # - name: Build NME Sample + # if: matrix.target != 'hl' + # working-directory: ./samples/nme + # run: | + # hmm install --quiet + # haxelib update + # echo y | haxelib run nme build ${{ matrix.target }} + + - name: Build OpenFL Sample + working-directory: ./samples/openfl + run: | + haxelib run openfl build ${{ matrix.target }} --no-output + + - name: Build OpenFL (Firetongue) Sample + working-directory: ./samples/openfl_firetongue + run: | + haxelib run openfl build ${{ matrix.target }} --no-output + + - name: Build OpenFL (HScript) Sample + working-directory: ./samples/openfl_hscript + run: | + haxelib run openfl build ${{ matrix.target }} --no-output + + - name: Build OpenFL (HScript with Classes) Sample + working-directory: ./samples/openfl_hscript_class + run: | + haxelib run openfl build ${{ matrix.target }} --no-output + + diff --git a/include.xml b/include.xml index 3833d7dd..537b54b6 100644 --- a/include.xml +++ b/include.xml @@ -1,6 +1,9 @@ + + + diff --git a/polymod/Polymod.hx b/polymod/Polymod.hx index cdb0c15e..7663c229 100644 --- a/polymod/Polymod.hx +++ b/polymod/Polymod.hx @@ -276,7 +276,6 @@ class Polymod params.dirs ??= []; params.ignoredFiles ??= []; - var shouldLoadMods:Bool = params.modIds.length == 0 && params.dirs.length == 0; if (params.fileSystemParams == null) params.fileSystemParams = {modRoot: modRoot}; if (params.fileSystemParams.modRoot == null) params.fileSystemParams.modRoot = modRoot; if (params.apiVersionRule == null) params.apiVersionRule = VersionUtil.DEFAULT_VERSION_RULE; @@ -838,7 +837,7 @@ class Polymod #if hscript_typer polymod.hscript._internal.PolymodTyperEx.clearAllModules(); #end - polymod.hscript.HScriptable.ScriptRunner.clearScripts(); + polymod.hscript.ScriptRunner.clearScripts(); } static function prepareRegisterScriptedClasses():Void @@ -914,7 +913,7 @@ class Polymod * Called on platforms that don't support synchronous file access. * * @return A list of futures for each script class being registered, providing `true` for success or an error if failed. - */ + **/ public static function registerAllScriptClassesAsync():lime.app.Future>> { Polymod.info(SCRIPT_PARSE_START, 'Parsing script classes asynchronously...'); @@ -956,6 +955,12 @@ class Polymod return lime.app.Future.withValue(results); }); } + #else + public static function registerAllScriptClassesAsync():Array + { + Polymod.error(SCRIPT_PARSE_FAILED, 'Asynchronous script loading is not supported on this platform!'); + return []; + } #end /** diff --git a/polymod/backends/HEAPSBackend.hx b/polymod/backends/HEAPSBackend.hx index 854f66a0..2b5b235b 100644 --- a/polymod/backends/HEAPSBackend.hx +++ b/polymod/backends/HEAPSBackend.hx @@ -99,6 +99,11 @@ class HEAPSBackend implements IBackend throw 'Function not implemented'; } + public function listLibraries():Array + { + throw 'Function not implemented'; + } + public function getPath(id:String):String { throw 'Function not implemented'; @@ -229,7 +234,7 @@ class ModFileEntry extends BytesFileEntry var dirPath = isDir ? path : Util.uPathPop(fullFilePath); var itemPaths = []; - for (id in p.type.keys()) + for (id in p.assetTypes.keys()) { if (id.indexOf(dirPath) != 0) continue; if (Util.isMergeOrAppend(id)) continue; @@ -290,16 +295,16 @@ class ModFileEntry extends BytesFileEntry return super.getBytes(); } - override function readByte():Int + override function readBytes(out:Bytes, outPos:Int, pos:Int, len:Int):Int { initBytes(); - return super.readByte(); + return super.readBytes(out, outPos, pos, len); } - override function read(out:Bytes, pos:Int, size:Int) + override function readFull(bytes:Bytes, pos:Int, len:Int) { initBytes(); - return super.read(out, pos, size); + return super.readFull(bytes, pos, len); } override function loadBitmap(onLoaded:LoadedBitmap->Void):Void diff --git a/polymod/backends/LimeBackend.hx b/polymod/backends/LimeBackend.hx index aa7bdd9a..81b2f2d3 100644 --- a/polymod/backends/LimeBackend.hx +++ b/polymod/backends/LimeBackend.hx @@ -21,6 +21,7 @@ import unifill.Unifill; import lime.app.Future; import lime.graphics.Image; import lime.net.HTTPRequest; +import lime.system.ThreadPool; import lime.text.Font; import lime.utils.Assets; import lime.utils.Bytes; diff --git a/polymod/backends/NMEBackend.hx b/polymod/backends/NMEBackend.hx index d1cf0c8e..8fbe8a2d 100644 --- a/polymod/backends/NMEBackend.hx +++ b/polymod/backends/NMEBackend.hx @@ -165,6 +165,11 @@ class NMEBackend implements IBackend throw 'Function not implemented'; } + public function listLibraries():Array + { + throw 'Function not implemented'; + } + public function getPath(id:String):String { throw 'Function not implemented'; diff --git a/polymod/backends/PolymodAssetLibrary.hx b/polymod/backends/PolymodAssetLibrary.hx index dc64e66f..5f92790c 100644 --- a/polymod/backends/PolymodAssetLibrary.hx +++ b/polymod/backends/PolymodAssetLibrary.hx @@ -523,6 +523,7 @@ class PolymodAssetLibrary return backend.loadSound(id); } #end + #end /** * @return A list of asset libraries for this framework. @@ -531,7 +532,6 @@ class PolymodAssetLibrary { return backend.listLibraries(); } - #end /** * Get the absolute system file path for a given asset ID. @@ -951,7 +951,7 @@ class PolymodAssetLibrary typeLibraries.get('default').push(file); } - #if openfl + #if (openfl && !nme) if (assetType == FONT) { var font = Font.fromFile(this.file(file, modDir)); @@ -1015,7 +1015,7 @@ class PolymodAssetLibrary assetTypes.set(f, assetType); if (!typeLibraries.exists(libraryId)) typeLibraries.set(libraryId, []); typeLibraries.get(libraryId).push(f); - #if openfl + #if (openfl && !nme) if (assetType == FONT) { var font = Font.fromFile(file(f, redirectPath)); diff --git a/polymod/hscript/HScriptable.hx b/polymod/hscript/HScriptable.hx index 0852669b..36a09ff5 100644 --- a/polymod/hscript/HScriptable.hx +++ b/polymod/hscript/HScriptable.hx @@ -1,9 +1,6 @@ package polymod.hscript; import haxe.Json; -import polymod.hscript._internal.Expr; -import polymod.Polymod; -import polymod.util.Util; /** * This interface triggers the execution of a macro on any elements which use the `@:hscript` annotation. @@ -171,133 +168,3 @@ class HScriptParams return Json.stringify(this); } } - -typedef ScriptOutput = -{ - /** - * The output of the script. Can be any value type. - */ - var script_result:Dynamic; - - /** - * The functions and variables created within the scope of the script. - */ - var script_variables:Map; -} - -class ScriptRunner -{ - /** - * No reason not to make this static! Load a script once instead of 50 times. - */ - private static var scripts:Map = new Map(); - - public function new() {} - - public static function clearScripts():Void - { - scripts.clear(); - } - - public function load(name:String, assetHandler:Dynamic):Null