Skip to content
Open
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" />

<haxeflag name="--macro" value="polymod.hscript._internal.PolymodFinalMacro.locateAllFinals()" />
Expand Down
9 changes: 7 additions & 2 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 @@ -847,7 +846,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 @@ -965,6 +964,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
15 changes: 10 additions & 5 deletions polymod/backends/HEAPSBackend.hx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ class HEAPSBackend 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 Expand Up @@ -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;
Expand Down Expand Up @@ -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
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
8 changes: 4 additions & 4 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 @@ -611,6 +611,7 @@ class PolymodAssetLibrary
return soundFuture;
}
#end
#end

/**
* @return A list of asset libraries for this framework.
Expand All @@ -619,7 +620,6 @@ class PolymodAssetLibrary
{
return backend.listLibraries();
}
#end

/**
* Get the absolute system file path for a given asset ID.
Expand Down Expand Up @@ -1039,7 +1039,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 @@ -1103,7 +1103,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
31 changes: 14 additions & 17 deletions polymod/fs/BaseFileSystem.hx
Original file line number Diff line number Diff line change
Expand Up @@ -104,40 +104,38 @@ abstract class BaseFileSystem implements IFileSystem

return new Future(performWork, true);
}
#end

/**
* Get the byte data for a file from a specific mod.
* Load the byte data for a file from a specific mod, asynchronously.
*
* @param path The path to retrieve byte data from, relative to the asset root.
* @param modId A specific mod ID to retrieve an asset from.
* @return The file bytes, or `null` if it couldn't be fetched.
* @return A future which returns the file bytes.
*/
public function getFileBytesByModId(path:String, modId:String):Null<Bytes>
public function loadFileBytesByModId(path:String, modId:String):Future<Bytes>
{
var modDir:String = scanModDirectoriesForId(modId) ?? return null;
var relativeDir:String = Util.pathJoin(modRoot, modDir);
var modDir:Null<String> = scanModDirectoriesForId(modId);
if (modDir == null) return null;
var relativeDir = Util.pathJoin(modRoot, modDir);

return getFileBytes(Util.pathJoin(relativeDir, path));
return loadFileBytes(Util.pathJoin(relativeDir, path));
}
#end

#if lime
/**
* Load the byte data for a file from a specific mod, asynchronously.
* Get the byte data for a file from a specific mod.
*
* @param path The path to retrieve byte data from, relative to the asset root.
* @param modId A specific mod ID to retrieve an asset from.
* @return A future which returns the file bytes.
* @return The file bytes, or `null` if it couldn't be fetched.
*/
public function loadFileBytesByModId(path:String, modId:String):Future<Bytes>
public function getFileBytesByModId(path:String, modId:String):Null<Bytes>
{
var modDir:Null<String> = scanModDirectoriesForId(modId);
if (modDir == null) return null;
var relativeDir = Util.pathJoin(modRoot, modDir);
var modDir:String = scanModDirectoriesForId(modId) ?? return null;
var relativeDir:String = Util.pathJoin(modRoot, modDir);

return loadFileBytes(Util.pathJoin(relativeDir, path));
return getFileBytes(Util.pathJoin(relativeDir, path));
}
#end

/**
* Provide a list of valid mods for this file system to load.
Expand Down Expand Up @@ -295,7 +293,6 @@ abstract class BaseFileSystem implements IFileSystem

function getModIconPath(modPath:String, ?origin:PolymodErrorOrigin):Null<String>
{
var foundIcon = false;
for (iconBasePath in PolymodConfig.modIconFile)
{
var iconFile = Util.pathJoin(modPath, iconBasePath);
Expand Down
32 changes: 27 additions & 5 deletions polymod/fs/StubFileSystem.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import polymod.Polymod.PolymodErrorOrigin;
import thx.semver.VersionRule;
import polymod.fs.PolymodFileSystem.IFileSystem;
import polymod.fs.PolymodFileSystem.PolymodFileSystemParams;
#if lime
import lime.app.Future;
#end

/**
* This stub file system returns false for all requests.
Expand All @@ -16,7 +19,7 @@ import polymod.fs.PolymodFileSystem.PolymodFileSystemParams;
@SuppressWarnings('checkstyle:FieldDocComment')
class StubFileSystem implements IFileSystem
{
public final modRoot:String;
public final modRoot:String = '';
public function new(params:PolymodFileSystemParams) {}

public inline function exists(path:String):Bool
Expand Down Expand Up @@ -49,15 +52,34 @@ class StubFileSystem implements IFileSystem
return null;
}

public function onLoadMod(id:String):Void {}

public function onUnloadMod(id:String):Void {}

public inline function getFileBytesByModId(path:String, modId:String):Null<haxe.io.Bytes>
{
return null;
}

#if lime
public inline function loadFileBytes(path:String):Future<haxe.io.Bytes>
{
return cast Future.withError('Cannot load file bytes from stub file system');
}

/**
* Load the byte data for a file from a specific mod, asynchronously.
*
* @param path The path to retrieve byte data from, relative to the asset root.
* @param modId A specific mod ID to retrieve an asset from.
* @return A future which returns the file bytes.
*/
public inline function loadFileBytesByModId(path:String, modId:String):Future<haxe.io.Bytes>
{
return cast Future.withError('Cannot load file bytes from stub file system');
}
#end

public function onLoadMod(id:String):Void {}

public function onUnloadMod(id:String):Void {}

public inline function readDirectoryRecursive(path:String):Array<String>
{
return [];
Expand Down
Loading
Loading