diff --git a/.github/workflows/build-samples.yml b/.github/workflows/build-samples.yml new file mode 100644 index 00000000..b00ca9c9 --- /dev/null +++ b/.github/workflows/build-samples.yml @@ -0,0 +1,86 @@ +# 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: + - uses: actions/checkout@v6.0.2 + + - name: Setup Haxe + uses: FunkinCrew/ci-haxe@v3 + with: + haxe-version: 4.3.7 + + - 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: | + haxe run.hxml + 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 16e21ce5..c244a948 100644 --- a/include.xml +++ b/include.xml @@ -1,6 +1,9 @@ + + + diff --git a/polymod/Polymod.hx b/polymod/Polymod.hx index a7891a3d..fd79b238 100644 --- a/polymod/Polymod.hx +++ b/polymod/Polymod.hx @@ -851,6 +851,7 @@ class Polymod } } + #if lime /** * Get a list of all the available scripted classes (`.hxc` files), interpret them asynchronously, and register any classes. * Called on platforms that don't support synchronous file access. @@ -889,6 +890,12 @@ class Polymod return futures; } + #else + public static function registerAllScriptClassesAsync() + { + throw 'Function not supported on current target'; + } + #end /** * Dispatch an error message with the severity `PolymodErrorType.ERROR`. diff --git a/polymod/backends/HEAPSBackend.hx b/polymod/backends/HEAPSBackend.hx index 8094207b..413aa127 100644 --- a/polymod/backends/HEAPSBackend.hx +++ b/polymod/backends/HEAPSBackend.hx @@ -102,6 +102,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'; @@ -293,16 +298,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 748d8f2c..e0b9624d 100644 --- a/polymod/backends/LimeBackend.hx +++ b/polymod/backends/LimeBackend.hx @@ -1,6 +1,5 @@ package polymod.backends; -import lime.system.ThreadPool; import polymod.backends.PolymodAssetLibrary; import polymod.backends.PolymodAssets.PolymodAssetType; import polymod.fs.PolymodFileSystem; @@ -18,6 +17,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 bc6e8202..0006d292 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 2b198e9e..fecd1ec9 100644 --- a/polymod/backends/PolymodAssetLibrary.hx +++ b/polymod/backends/PolymodAssetLibrary.hx @@ -652,7 +652,7 @@ class PolymodAssetLibrary typeLibraries.get('default').push(f); } - #if openfl + #if (openfl && !nme) if (assetType == FONT) { var fontBytes = fileSystem.getFileBytes(file(f, d)); @@ -713,7 +713,7 @@ class PolymodAssetLibrary type.set(f, assetType); if (!typeLibraries.exists(libraryId)) typeLibraries.set(libraryId, []); typeLibraries.get(libraryId).push(f); - #if openfl + #if (openfl && !nme) if (assetType == FONT) { var fontBytes = fileSystem.getFileBytes(file(f, redirectPath)); diff --git a/polymod/fs/MemoryZipFileSystem.hx b/polymod/fs/MemoryZipFileSystem.hx index 6ea0cde2..92bd51e0 100644 --- a/polymod/fs/MemoryZipFileSystem.hx +++ b/polymod/fs/MemoryZipFileSystem.hx @@ -16,12 +16,12 @@ class MemoryZipFileSystem extends StubFileSystem public function new(params:ZipFileSystemParams) { super(params); - Polymod.error(FUNCTIONALITY_NOT_IMPLEMENTED, "This file system not supported for this platform, and is only intended for use in html5"); + Polymod.error(POLYMOD_FUNCTIONALITY_NOT_IMPLEMENTED, "This file system not supported for this platform, and is only intended for use in html5"); } public function addZipFile(zipName:String, zipBytes:Bytes) { - Polymod.error(FUNCTIONALITY_NOT_IMPLEMENTED, "This file system not supported for this platform, and is only intended for use in html5"); + Polymod.error(POLYMOD_FUNCTIONALITY_NOT_IMPLEMENTED, "This file system not supported for this platform, and is only intended for use in html5"); } } #else diff --git a/polymod/hscript/_internal/HScriptableMacro.hx b/polymod/hscript/_internal/HScriptableMacro.hx index b44c5567..687d4ce1 100644 --- a/polymod/hscript/_internal/HScriptableMacro.hx +++ b/polymod/hscript/_internal/HScriptableMacro.hx @@ -177,7 +177,7 @@ class HScriptableMacro } else { - polymod.Polymod.debug('The scripted function ' + $v{pathName} + ' could not be found, but that is fine because it is optional.', SCRIPT_RUNTIME); + polymod.Polymod.debug('The scripted function ' + $v{pathName} + ' could not be found, but that is fine because it is optional.'); // Prevent the script from running but do not prevent the function body from executing. // wasCancelled = true; diff --git a/polymod/hscript/_internal/PolymodScriptClass.hx b/polymod/hscript/_internal/PolymodScriptClass.hx index 53e9dc5a..ef11bc13 100644 --- a/polymod/hscript/_internal/PolymodScriptClass.hx +++ b/polymod/hscript/_internal/PolymodScriptClass.hx @@ -183,6 +183,7 @@ class PolymodScriptClass } } + #if lime static function registerScriptClassByPathAsync(path:String):lime.app.Future { var promise = new lime.app.Promise(); @@ -231,6 +232,7 @@ class PolymodScriptClass // Await the promise return promise.future; } + #end /** * Returns a list of all registered classes. diff --git a/samples/.gitignore b/samples/.gitignore new file mode 100644 index 00000000..438073da --- /dev/null +++ b/samples/.gitignore @@ -0,0 +1,2 @@ +.haxelib +hmm.json diff --git a/samples/flixel/hmm.json b/samples/flixel/hmm.json index f7fdfc87..3bbc308f 100644 --- a/samples/flixel/hmm.json +++ b/samples/flixel/hmm.json @@ -45,7 +45,9 @@ }, { "name": "thx.semver", - "type": "haxelib" + "type": "git", + "ref": "master", + "url": "https://github.com/fponticelli/thx.semver" } ] } diff --git a/samples/flixel_zip/hmm.json b/samples/flixel_zip/hmm.json index 3cff2bd9..0a7cfb9d 100644 --- a/samples/flixel_zip/hmm.json +++ b/samples/flixel_zip/hmm.json @@ -25,6 +25,16 @@ "type": "haxelib", "version": null }, + { + "name": "jsonpatch", + "type": "haxelib", + "version": null + }, + { + "name": "jsonpath", + "type": "haxelib", + "version": null + }, { "name": "lime", "type": "haxelib", @@ -40,10 +50,17 @@ "path": "../..", "type": "dev" }, + { + "name": "thx.core", + "type": "git", + "ref": "master", + "url": "https://github.com/fponticelli/thx.core" + }, { "name": "thx.semver", - "type": "haxelib", - "version": null + "type": "git", + "ref": "master", + "url": "https://github.com/fponticelli/thx.semver" } ] } diff --git a/samples/heaps/hmm.json b/samples/heaps/hmm.json index 6d360aaa..ffab65d5 100644 --- a/samples/heaps/hmm.json +++ b/samples/heaps/hmm.json @@ -1,5 +1,10 @@ { "dependencies": [ + { + "name": "format", + "type": "haxelib", + "version": null + }, { "name": "heaps", "type": "haxelib", @@ -15,15 +20,32 @@ "type": "haxelib", "version": null }, + { + "name": "jsonpatch", + "type": "haxelib", + "version": null + }, + { + "name": "jsonpath", + "type": "haxelib", + "version": null + }, { "name": "polymod", "path": "../..", "type": "dev" }, + { + "name": "thx.core", + "type": "git", + "ref": "master", + "url": "https://github.com/fponticelli/thx.core" + }, { "name": "thx.semver", - "type": "haxelib", - "version": null + "type": "git", + "ref": "master", + "url": "https://github.com/fponticelli/thx.semver" } ] } diff --git a/samples/heaps/res/data/greeting.txt b/samples/heaps/res/data/greeting.txt new file mode 100644 index 00000000..af5626b4 --- /dev/null +++ b/samples/heaps/res/data/greeting.txt @@ -0,0 +1 @@ +Hello, world! diff --git a/samples/heaps/res/data/objects.json b/samples/heaps/res/data/objects.json new file mode 100644 index 00000000..c20b7397 --- /dev/null +++ b/samples/heaps/res/data/objects.json @@ -0,0 +1,6 @@ +{ + "object_0": { "value": "moon" }, + "object_1": { "value": "star" }, + "object_2": { "value": "sun" }, + "nested": { "object": { "array": ["a", "b", "c"] } } +} diff --git a/samples/heaps/res/data/objects.xml b/samples/heaps/res/data/objects.xml new file mode 100644 index 00000000..280a9584 --- /dev/null +++ b/samples/heaps/res/data/objects.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/samples/heaps/res/img/a.png b/samples/heaps/res/img/a.png new file mode 100644 index 00000000..97284217 Binary files /dev/null and b/samples/heaps/res/img/a.png differ diff --git a/samples/heaps/res/img/b.png b/samples/heaps/res/img/b.png new file mode 100644 index 00000000..d00c34d2 Binary files /dev/null and b/samples/heaps/res/img/b.png differ diff --git a/samples/heaps/res/img/c.png b/samples/heaps/res/img/c.png new file mode 100644 index 00000000..38400d98 Binary files /dev/null and b/samples/heaps/res/img/c.png differ diff --git a/samples/nme/hmm.json b/samples/nme/hmm.json index e9dc5449..30dc5000 100644 --- a/samples/nme/hmm.json +++ b/samples/nme/hmm.json @@ -10,15 +10,34 @@ "type": "haxelib", "version": null }, + { + "name": "nme-dev", + "type": "haxelib", + "version": null + }, + { + "name": "nme-toolkit", + "type": "haxelib", + "version": null + }, { "name": "polymod", "path": "../..", "type": "dev" }, + { + "name": "thx.core", + "type": "git", + "dir": null, + "ref": "master", + "url": "https://github.com/fponticelli/thx.core" + }, { "name": "thx.semver", - "type": "haxelib", - "version": null + "type": "git", + "dir": null, + "ref": "master", + "url": "https://github.com/fponticelli/thx.semver" } ] -} +} \ No newline at end of file diff --git a/samples/openfl/hmm.json b/samples/openfl/hmm.json index c8efc8b4..cdc316e6 100644 --- a/samples/openfl/hmm.json +++ b/samples/openfl/hmm.json @@ -10,6 +10,16 @@ "type": "haxelib", "version": null }, + { + "name": "jsonpatch", + "type": "haxelib", + "version": null + }, + { + "name": "jsonpath", + "type": "haxelib", + "version": null + }, { "name": "lime", "type": "haxelib", @@ -25,10 +35,19 @@ "path": "../..", "type": "dev" }, + { + "name": "thx.core", + "type": "git", + "dir": null, + "ref": "master", + "url": "https://github.com/fponticelli/thx.core" + }, { "name": "thx.semver", - "type": "haxelib", - "version": null + "type": "git", + "dir": null, + "ref": "master", + "url": "https://github.com/fponticelli/thx.semver" } ] -} +} \ No newline at end of file diff --git a/samples/openfl_firetongue/hmm.json b/samples/openfl_firetongue/hmm.json index 2c9b37b9..ce7daf6c 100644 --- a/samples/openfl_firetongue/hmm.json +++ b/samples/openfl_firetongue/hmm.json @@ -15,6 +15,16 @@ "type": "haxelib", "version": null }, + { + "name": "jsonpatch", + "type": "haxelib", + "version": null + }, + { + "name": "jsonpath", + "type": "haxelib", + "version": null + }, { "name": "lime", "type": "haxelib", @@ -30,10 +40,19 @@ "path": "../..", "type": "dev" }, + { + "name": "thx.core", + "type": "git", + "dir": null, + "ref": "master", + "url": "https://github.com/fponticelli/thx.core" + }, { "name": "thx.semver", - "type": "haxelib", - "version": null + "type": "git", + "dir": null, + "ref": "master", + "url": "https://github.com/fponticelli/thx.semver" } ] } diff --git a/samples/openfl_hscript/hmm.json b/samples/openfl_hscript/hmm.json index 0bfaa61d..3a78979b 100644 --- a/samples/openfl_hscript/hmm.json +++ b/samples/openfl_hscript/hmm.json @@ -15,6 +15,16 @@ "type": "haxelib", "version": null }, + { + "name": "jsonpatch", + "type": "haxelib", + "version": null + }, + { + "name": "jsonpath", + "type": "haxelib", + "version": null + }, { "name": "lime", "type": "haxelib", @@ -30,10 +40,19 @@ "path": "../..", "type": "dev" }, + { + "name": "thx.core", + "type": "git", + "dir": null, + "ref": "master", + "url": "https://github.com/fponticelli/thx.core" + }, { "name": "thx.semver", - "type": "haxelib", - "version": null + "type": "git", + "dir": null, + "ref": "master", + "url": "https://github.com/fponticelli/thx.semver" } ] } diff --git a/samples/openfl_hscript_class/hmm.json b/samples/openfl_hscript_class/hmm.json index 0bfaa61d..3a78979b 100644 --- a/samples/openfl_hscript_class/hmm.json +++ b/samples/openfl_hscript_class/hmm.json @@ -15,6 +15,16 @@ "type": "haxelib", "version": null }, + { + "name": "jsonpatch", + "type": "haxelib", + "version": null + }, + { + "name": "jsonpath", + "type": "haxelib", + "version": null + }, { "name": "lime", "type": "haxelib", @@ -30,10 +40,19 @@ "path": "../..", "type": "dev" }, + { + "name": "thx.core", + "type": "git", + "dir": null, + "ref": "master", + "url": "https://github.com/fponticelli/thx.core" + }, { "name": "thx.semver", - "type": "haxelib", - "version": null + "type": "git", + "dir": null, + "ref": "master", + "url": "https://github.com/fponticelli/thx.semver" } ] } diff --git a/samples/run.hxml b/samples/run.hxml new file mode 100644 index 00000000..e8046c17 --- /dev/null +++ b/samples/run.hxml @@ -0,0 +1,3 @@ +--class-path scripts +--main SamplesBuild +--interp diff --git a/samples/scripts/SamplesBuild.hx b/samples/scripts/SamplesBuild.hx new file mode 100644 index 00000000..2b0327a2 --- /dev/null +++ b/samples/scripts/SamplesBuild.hx @@ -0,0 +1,74 @@ +package ; + +import haxe.format.JsonPrinter; +import haxe.format.JsonParser; +import haxe.Json; +import sys.io.File; +import haxe.io.Path; +import sys.FileSystem; + +typedef HMMDependency = +{ + name:String, + type:String, + ?version: String, + ?path:String, + ?dir:String, + ?url:String, + ?ref:String, +} + +class SamplesBuild +{ + static final IGNORE_LIST:Array = ['nme']; + + public static function main() + { + final scriptsPath:String = Path.directory(Sys.programPath()); + final workPath:String = Path.normalize('$scriptsPath/..'); + + var searchPaths:Array = FileSystem.readDirectory(workPath); + var dependencies:Map = []; + + for (path in searchPaths) + { + if (IGNORE_LIST.contains(path)) continue; + if (!FileSystem.isDirectory(path)) continue; + + final hmmPath:String = Path.join([path, 'hmm.json']); + if (!FileSystem.exists(hmmPath)) continue; + + var hmmContent:String = File.getContent(hmmPath); + try + { + var json:{ dependencies:Array } = Json.parse(hmmContent); + if (json.dependencies == null) continue; + + for (dependency in json.dependencies) + { + if (dependencies.exists(dependency.name)) + { + continue; + } + + dependencies.set(dependency.name, dependency); + } + } + catch (_) {} + } + + var result = { dependencies: [] }; + for (dependency in dependencies) + { + if (dependency.name == 'polymod' && dependency.type == 'dev') + { + // Force correct relative path + dependency.path = '..'; + } + + result.dependencies.push(dependency); + } + + File.saveContent(Path.join([workPath, 'hmm.json']), Json.stringify(result, ' ')); + } +}