Skip to content
Draft
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
86 changes: 86 additions & 0 deletions .github/workflows/build-samples.yml
Original file line number Diff line number Diff line change
@@ -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


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.HScriptRedirectDefines.run()" if="POLYMOD_REDIRECT_HSCRIPT" />
Expand Down
9 changes: 8 additions & 1 deletion polymod/Polymod.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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`.
Expand Down Expand Up @@ -943,7 +950,7 @@ class Polymod
*/
public static function debug(message:String, ?posInfo:haxe.PosInfos):Void
{
if (PolymodConfig.debug)
if (PolymodConfig.debug && onError != null)
{
onError(new PolymodError(PolymodErrorType.DEBUG, null, message, UNKNOWN));
}
Expand Down
13 changes: 9 additions & 4 deletions polymod/backends/HEAPSBackend.hx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,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 @@ -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
Expand Down
2 changes: 1 addition & 1 deletion polymod/backends/LimeBackend.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package polymod.backends;

import lime.system.ThreadPool;
import polymod.backends.PolymodAssetLibrary;
import polymod.backends.PolymodAssets.PolymodAssetType;
import polymod.fs.PolymodFileSystem;
Expand All @@ -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;
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
6 changes: 3 additions & 3 deletions polymod/backends/PolymodAssetLibrary.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import polymod.Polymod.FrameworkParams;
#if firetongue
import firetongue.FireTongue;
#end
#if openfl
#if (openfl && !macro)
import openfl.text.Font;
#end

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions polymod/fs/MemoryZipFileSystem.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions polymod/hscript/HScriptable.hx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package polymod.hscript;

import haxe.Json;
import polymod.hscript._internal.Expr;
#if !macro
import polymod.Polymod;
import polymod.hscript._internal.Expr;
import polymod.util.Util;
#end

/**
* This interface triggers the execution of a macro on any elements which use the `@:hscript` annotation.
Expand Down Expand Up @@ -185,6 +187,7 @@ typedef ScriptOutput =
var script_variables:Map<String, Dynamic>;
}

#if !macro
class ScriptRunner
{
/**
Expand All @@ -209,7 +212,7 @@ class ScriptRunner

var scriptPath = scriptPath(name);
Polymod.debug('Fetching script "$scriptPath"...');
if (!assetHandler.exists(scriptPath))
if (!assetHandler.exists(scriptPath, null))
{
// Error will only be thrown if hscriptParams.optional == false (the default).
Polymod.debug('Note: Script at path "$scriptPath" not found! This may cause problems if it is not optional...');
Expand Down Expand Up @@ -301,3 +304,4 @@ class Script
};
}
}
#end
2 changes: 1 addition & 1 deletion polymod/hscript/_internal/HScriptableMacro.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion polymod/hscript/_internal/PolymodScriptClass.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import polymod.hscript._internal.Expr.ClassImport;
import polymod.hscript._internal.Expr.FieldDecl;
import polymod.hscript._internal.Expr.FunctionDecl;
import polymod.hscript._internal.Expr.VarDecl;
import polymod.hscript._internal.Printer;
import polymod.util.Util;

using StringTools;
Expand Down Expand Up @@ -183,6 +182,7 @@ class PolymodScriptClass
}
}

#if lime
static function registerScriptClassByPathAsync(path:String):lime.app.Future<Bool>
{
var promise = new lime.app.Promise<Bool>();
Expand Down Expand Up @@ -231,6 +231,7 @@ class PolymodScriptClass
// Await the promise
return promise.future;
}
#end

/**
* Returns a list of all registered classes.
Expand Down
2 changes: 2 additions & 0 deletions samples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.haxelib
hmm.json
4 changes: 3 additions & 1 deletion samples/flixel/hmm.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
},
{
"name": "thx.semver",
"type": "haxelib"
"type": "git",
"ref": "master",
"url": "https://github.com/fponticelli/thx.semver"
}
]
}
21 changes: 19 additions & 2 deletions samples/flixel_zip/hmm.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
"type": "haxelib",
"version": null
},
{
"name": "jsonpatch",
"type": "haxelib",
"version": null
},
{
"name": "jsonpath",
"type": "haxelib",
"version": null
},
{
"name": "lime",
"type": "haxelib",
Expand All @@ -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"
}
]
}
26 changes: 24 additions & 2 deletions samples/heaps/hmm.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"dependencies": [
{
"name": "format",
"type": "haxelib",
"version": null
},
{
"name": "heaps",
"type": "haxelib",
Expand All @@ -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"
}
]
}
1 change: 1 addition & 0 deletions samples/heaps/res/data/greeting.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello, world!
Loading
Loading