Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions .github/workflows/build-samples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# 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

# The NME target seems to be in a pretty unusable state, so we will ignore errors for now.
- name: Build NME Sample
continue-on-error: true
if: matrix.target != 'hl' && matrix.target != 'html5'
working-directory: ./samples/nme
run: echo y | haxelib run nme build ${{ matrix.target }} --no-output

- 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


3 changes: 3 additions & 0 deletions include.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<!-- These values are added to the project XML when you include this library. -->
<haxelib name="jsonpath" />
<haxelib name="jsonpatch" />
<haxelib name="thx.core" />
<haxelib name="thx.semver" />

<!--
Expand Down
31 changes: 23 additions & 8 deletions polymod/Polymod.hx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,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;
Expand Down Expand Up @@ -411,7 +410,8 @@ class Polymod
return sortedModsToLoad;
}

static function cleanupAssetLibrary():Void {
static function cleanupAssetLibrary():Void
{
if (assetLibrary == null) return;

var fileSystem = assetLibrary.fileSystem;
Expand Down Expand Up @@ -891,7 +891,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
Expand Down Expand Up @@ -970,9 +970,9 @@ class Polymod
#end
}

#if (POLYMOD_CPPIA && lime)
static function registerAllCppiaClassesAsync():Array<lime.app.Future<Bool>>
{
#if POLYMOD_CPPIA
@:privateAccess {
var libraryIds:Array<String> = Polymod.assetLibrary.listLibraries();
var allBytes:Array<String> = Polymod.assetLibrary.list(BYTES);
Expand Down Expand Up @@ -1047,10 +1047,17 @@ class Polymod
}
return futures;
}
#else
return [];
}
#else
static function registerAllCppiaClassesAsync()
{
// Only error if we're not using Lime
#if POLYMOD_CPPIA
Polymod.error(SCRIPT_PARSE_FAILED, 'Asynchronous script loading with CPPIA is not supported on this platform!');
#end
return [];
}
#end

/**
* Loads all script classes (`.hxc` files) and registers any classes they provide.
Expand Down Expand Up @@ -1082,7 +1089,8 @@ class Polymod
break;
}
}
if (!Polymod.assetLibrary.exists(path)) {
if (!Polymod.assetLibrary.exists(path))
{
Polymod.error(SCRIPT_NOT_FOUND, 'Could not find file "$textPath"');
results.set(path, false);
}
Expand Down Expand Up @@ -1150,7 +1158,8 @@ class Polymod
}
}

return lime.app.Promise.allSettled(futures).then((results) -> {
return lime.app.Promise.allSettled(futures).then((results) ->
{
#if POLYMOD_CPPIA
polymod.hscript._internal.PolymodCppiaClassReference.unloadInactiveModules();
#end
Expand All @@ -1163,6 +1172,12 @@ class Polymod
return lime.app.Future.withValue(results);
});
}
#else
public static function registerAllScriptClassesAsync():Array<Bool>
{
Polymod.error(SCRIPT_PARSE_FAILED, 'Asynchronous script loading is not supported on this platform!');
return [];
}
#end

/**
Expand Down
68 changes: 61 additions & 7 deletions polymod/backends/HEAPSBackend.hx
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,66 @@ class HEAPSBackend implements IBackend

public function list(type:PolymodAssetType = null):Array<String>
{
throw 'Function not implemented';
var result:Array<String> = [];

if (fallback != null)
{
addEntries(fallback.fs.getRoot(), result, type);
}

for (id in polymodLibrary.assetTypes.keys())
{
if (Util.isMergeOrAppend(id) || polymodLibrary.isAssetExcluded(id)) continue;
if (type == null || polymodLibrary.getAssetType(Util.uExtension(id)) == type)
{
result.push(id);
}
}

return Util.filterUnique(result);
}

public function listLibraries():Array<String>
{
return[for (libraryId in polymodLibrary.typeLibraries.keys()) libraryId];
}

public function getPath(id:String):String
{
throw 'Function not implemented';
if (polymodLibrary.check(id))
{
return polymodLibrary.file(id);
}

if (fallback == null || !fallback.exists(id)) return null;

var entry = fallback.fs.get(id);
if (Std.isOfType(fallback.fs, LocalFileSystem))
{
return cast(fallback.fs, LocalFileSystem).getAbsolutePath(entry);
}
return entry.path;
}

private function addEntries(entry:FileEntry, result:Array<String>, type:PolymodAssetType):Void
{
if (entry == null) return;

if (entry.isDirectory)
{
for (child in entry)
{
addEntries(child, result, type);
}
return;
}

var id = entry.path;
if (polymodLibrary.isAssetExcluded(id) || Util.isMergeOrAppend(id)) return;
if (type == null || polymodLibrary.getAssetType(Util.uExtension(id)) == type)
{
result.push(id);
}
}

public function clearCache()
Expand Down Expand Up @@ -229,7 +283,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;
Expand Down Expand Up @@ -290,16 +344,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
Expand Down
5 changes: 5 additions & 0 deletions polymod/backends/NMEBackend.hx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ class NMEBackend implements IBackend
throw 'Function not implemented';
}

public function listLibraries():Array<String>
{
throw 'Function not implemented';
}

public function getPath(id:String):String
{
throw 'Function not implemented';
Expand Down
11 changes: 6 additions & 5 deletions polymod/backends/PolymodAssetLibrary.hx
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ class PolymodAssetLibrary
return (bytes == null) ? null : bytes.getString(0, bytes.length);
}

#if openfl
#if (openfl && !nme)
/**
* Fetch text directly from the file system.
* Queries for any modded asset replacements, but ignores merging and appending.
Expand Down Expand Up @@ -590,7 +590,7 @@ class PolymodAssetLibrary
return backend.loadSound(id);
}

/**
/**
* Asynchronously fetch sound data directly from the file system.
* Ignores any modded asset replacements, and ignores merging and appending.
*
Expand All @@ -612,14 +612,15 @@ class PolymodAssetLibrary
}
#end

#end

/**
* @return A list of asset libraries for this framework.
*/
public function listLibraries():Array<String>
{
return backend.listLibraries();
}
#end

/**
* Get the absolute system file path for a given asset ID.
Expand Down Expand Up @@ -1041,7 +1042,7 @@ class PolymodAssetLibrary
typeLibraries.get('default').push(file);
}

#if openfl
#if (openfl && !nme)
if (assetType == FONT)
{
var font = Font.fromFile(this.file(file, modDir));
Expand Down Expand Up @@ -1105,7 +1106,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));
Expand Down
Loading
Loading