diff --git a/.github/workflows/build-samples.yml b/.github/workflows/build-samples.yml new file mode 100644 index 00000000..dd5c80e7 --- /dev/null +++ b/.github/workflows/build-samples.yml @@ -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 + + diff --git a/include.xml b/include.xml index 9a6efc6d..c7e46176 100644 --- a/include.xml +++ b/include.xml @@ -1,6 +1,9 @@ + + + diff --git a/samples/openfl_hscript_class/hmm.json b/samples/openfl_hscript_class/hmm.json index 0bfaa61d..e1ee973c 100644 --- a/samples/openfl_hscript_class/hmm.json +++ b/samples/openfl_hscript_class/hmm.json @@ -1,17 +1,22 @@ { "dependencies": [ { - "name": "hscript", + "name": "hxcpp", "type": "haxelib", "version": null }, { - "name": "hxcpp", + "name": "hxcpp-debug-server", "type": "haxelib", "version": null }, { - "name": "hxcpp-debug-server", + "name": "jsonpatch", + "type": "haxelib", + "version": null + }, + { + "name": "jsonpath", "type": "haxelib", "version": null }, @@ -30,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" } ] } diff --git a/samples/openfl_hscript_class/project.xml b/samples/openfl_hscript_class/project.xml index 9dc38ff2..6979e8c6 100644 --- a/samples/openfl_hscript_class/project.xml +++ b/samples/openfl_hscript_class/project.xml @@ -11,7 +11,6 @@ - diff --git a/samples/run.hxml b/samples/run.hxml new file mode 100644 index 00000000..8a04b532 --- /dev/null +++ b/samples/run.hxml @@ -0,0 +1,3 @@ +--class-path scripts +--main SamplesHMMBuilder +--interp diff --git a/samples/scripts/SamplesHMMBuilder.hx b/samples/scripts/SamplesHMMBuilder.hx new file mode 100644 index 00000000..274b5446 --- /dev/null +++ b/samples/scripts/SamplesHMMBuilder.hx @@ -0,0 +1,83 @@ +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, +} + +/** + * A simple tool to build a `hmm.json` file for the samples directory, + * by scanning for `hmm.json` files in each sample subdirectory and merging + * their dependencies into a single `hmm.json` file. + */ +class SamplesHMMBuilder +{ + /** + * A list of sample directories to ignore when scanning for `hmm.json` files. + * This is useful if certain samples do not work well with the system. + */ + static final IGNORE_LIST:Array = []; + + public static function main() + { + var scriptsPath:String = Path.directory(Sys.programPath()); + var 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; + + var 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, ' ')); + } +}