Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lime support #6

Closed
wants to merge 8 commits into from
Closed
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
10 changes: 10 additions & 0 deletions demo/heaps/src/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Main extends hxd.App {
override function init() {
var tf = new h2d.Text(hxd.res.DefaultFont.get(), s2d);
tf.text = "Hello World !";
}

static function main() {
new Main();
}
}
Empty file added demo/lime/Assets/info.txt
Empty file.
47 changes: 47 additions & 0 deletions demo/lime/src/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package;

import lime.app.Application;
import lime.graphics.RenderContext;

class Main extends Application {
public function new() {
super();

trace("Hello World");
}

public override function render(context:RenderContext):Void {
switch (context.type) {
case CAIRO:
var cairo = context.cairo;

cairo.setSourceRGB(0.75, 1, 0);
cairo.paint();

case CANVAS:
var ctx = context.canvas2D;

ctx.fillStyle = "#BFFF00";
ctx.fillRect(0, 0, window.width, window.height);

case DOM:
var element = context.dom;

element.style.backgroundColor = "#BFFF00";

case FLASH:
var sprite = context.flash;

sprite.graphics.beginFill(0xBFFF00);
sprite.graphics.drawRect(0, 0, window.width, window.height);

case OPENGL, OPENGLES, WEBGL:
var gl = context.webgl;

gl.clearColor(0.75, 1, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT);

default:
}
}
}
9 changes: 0 additions & 9 deletions demo/src/Main.hx

This file was deleted.

138 changes: 86 additions & 52 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
};
# Dox : the documentation tool
dox = {
url ="github:HaxeFoundation/dox";
url = "github:HaxeFoundation/dox";
flake = false;
};
# format : the format support library
Expand All @@ -38,68 +38,102 @@
};
};

outputs = { self, ... }@inputs:
let
# multiplatform support
# only tested on x86_64 linux
systems = [
"x86_64-linux"
# "aarch64-linux" <- not supported yet
"aarch64-darwin"
"x86_64-darwin"
];
forAllSystems = f: inputs.nixpkgs.lib.genAttrs systems f;
outputs = {self, ...} @ inputs: let
# multiplatform support
# only tested on x86_64 linux
systems = [
"x86_64-linux"
# "aarch64-linux" <- not supported yet
"aarch64-darwin"
"x86_64-darwin"
];
forAllSystems = f: inputs.nixpkgs.lib.genAttrs systems f;

# import functions:
haxix = system: (import ./nix { inherit inputs system; });
# import functions:
haxix = system: (import ./nix {inherit inputs system;});

# an example of a game
demo = system:
# an example of a game
demo = system: engine:
if engine == "heaps"
then
(haxix system).heaps.mkGame {
name = "helloworld";
src = ./demo;
src = ./. + "/demo/${engine}";
version = "0.0.1-alpha";
native = false;
}
else if engine == "lime"
then
(haxix system).lime.mkGame {
name = "helloworld";
src = ./. + "/demo/${engine}";
version = "0.0.1-alpha";
target = "html5";
}
else
(haxix system).heaps.mkGame {
name = "helloworld";
src = ./demo/heaps;
version = "0.0.1-alpha";
native = false;
};
in {
# template for heaps projects :
templates.default = {
path = ./template;
description = "A simple haxe/heaps game project";
welcomeText = "";
};

in {
templates.heaps = {
path = ./template/heaps;
description = "A simple haxe/heaps game project";
welcomeText = "";
};

# template for heaps projects :
templates.default = {
path = ./template;
description = "A simple haxe/heaps game project";
welcomeText = "";
};
templates.lime = {
path = ./template/lime;
description = "A simple haxe/lime app";
welcomeText = "";
};

# expose functions :
lib = forAllSystems (system: {
mkHaxelib = (haxix system).haxelib.mkHaxelib;
mkHaxedoc = (haxix system).dox.mkHaxedoc;
mkHeapsGame = (haxix system).heaps.mkGame;
mkHeapsShell = (haxix system).heaps.mkShell;
});
# expose functions :
lib = forAllSystems (system: {
mkHaxelib = (haxix system).haxelib.mkHaxelib;
mkHaxedoc = (haxix system).dox.mkHaxedoc;
mkHeapsGame = (haxix system).heaps.mkGame;
mkLimeGame = (haxix system).lime.mkGame;
mkHeapsShell = (haxix system).heaps.mkShell;
mkLimeShell = (haxix system).lime.mkShell;
});

# All important packages and the demo
packages = forAllSystems (system: {
# haxelang :
haxe = (haxix system).haxe.haxe_latest;
hashlink = (haxix system).hashlink.hashlink_latest;
# libs :
format = (haxix system).format.format_latest;
dox = (haxix system).dox.dox_latest;
# helloworld :
demo = demo system;
});
# All important packages and the demo
packages = forAllSystems (system: {
# haxelang :
haxe = (haxix system).haxe.haxe_latest;
hashlink = (haxix system).hashlink.hashlink_latest;
# libs :
format = (haxix system).format.format_latest;
dox = (haxix system).dox.dox_latest;
# demos :
heaps_demo = demo system "heaps";
lime_demo = demo system "lime";
});

# checks
# TODO : improve to only build minimal checks
checks = forAllSystems (system: { demo = demo system; });
# checks
# TODO : improve to only build minimal checks
checks = forAllSystems (system: {
heaps_demo = demo system "heaps";
lime_demo = demo system "lime";
});

# shell for the demo
devShells = forAllSystems
(system: {
default = (haxix system).shell;
demo = (haxix system).heaps.mkShell (demo system);
});
};
# shell for the demo
devShells =
forAllSystems
(system: {
default = (haxix system).shell;
lime_demo = (haxix system).lime.mkShell (demo system "lime");
heaps_demo = (haxix system).lime.mkShell (demo system "heaps");
});
};
}
30 changes: 21 additions & 9 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
# default.nix
# expose every function/derivations here
# also detect linux/MacOS and give the correct version
{ inputs, system }:
with builtins;
let
{
inputs,
system,
}:
with builtins; let
inherit (inputs.nixpkgs.lib) platforms;

systemSwitch = linux: darwin:
if elem system platforms.darwin then darwin
else if elem system platforms.linux then linux
if elem system platforms.darwin
then darwin
else if elem system platforms.linux
then linux
else throw "unsupported system";

# nixpkgs : support MacOS
nixpkgs = systemSwitch inputs.nixpkgs inputs.nixpkgs-darwin;
pkgs = import nixpkgs { system = systemSwitch "x86_64-linux" "x86_64-darwin"; };
pkgs = import nixpkgs {system = systemSwitch "x86_64-linux" "x86_64-darwin";};

# haxe language and compiler
# does not build in aaarch64-darwin
Expand All @@ -23,7 +27,7 @@ let
};

# a way to install haxelibs
haxelib = import ./haxelib.nix { inherit pkgs; };
haxelib = import ./haxelib.nix {inherit pkgs;};

# format library
format = import ./format.nix {
Expand Down Expand Up @@ -56,14 +60,22 @@ let
inherit (haxe) haxe_latest;
};

# lime
lime = import ./lime.nix {
inherit pkgs haxelib;
inherit (format) format_latest;
inherit (haxe) haxe_latest;
};

shell = pkgs.mkShell {
buildInputs = [
haxe.haxe_latest
hashlink.hashlink_latest
format.format_latest
heaps.heaps_latest
dox.dox_latest
lime.lime_8_1_1
pkgs.neko
];
};

in { inherit haxe hashlink heaps format dox shell; }
in {inherit haxe hashlink heaps format dox shell lime;}
64 changes: 37 additions & 27 deletions nix/dox.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# dox.nix
# a haxe library for creating beautiful docs
{ pkgs, dox , haxe_latest, haxelib }:
let
{
pkgs,
dox,
haxe_latest,
haxelib,
}: let
# dox haxelib
dox_latest = haxelib.mkHaxelib {
version = "latest";
Expand All @@ -15,30 +19,36 @@ let

# haxedoc : the resulting documentation of a haxe derivation :
# TODO: support for custom Compile.hxml
mkHaxedoc = {haxeDrv, srcDir ? "src", main ? "Main", haxeLibs ? []} :
pkgs.stdenvNoCC.mkDerivation {
# TODO : check/fix versionned names
name = "${haxeDrv.name}-doc";
src = haxeDrv.src;
buildInputs = [haxe_latest dox_latest] ++ haxeDrv.buildInputs;
unpackPhase = ''
cp -R $src/src/* ./
'';
buildPhase = ''
ls -la
${haxe_latest}/bin/haxe -xml docs/doc.xml -D doc-gen \
${builtins.concatStringsSep " " (map (x: "-lib ${x}") haxeLibs)}
haxelib run dox -i docs
'';
installPhase = ''
mkdir -p $out/doc
cp pages/* $out/doc
'';
meta = haxeDrv.meta // {
description = "Documentation of ${haxeDrv.name}";
};
};

mkHaxedoc = {
haxeDrv,
srcDir ? "src",
main ? "Main",
haxeLibs ? [],
}:
pkgs.stdenvNoCC.mkDerivation {
# TODO : check/fix versionned names
name = "${haxeDrv.name}-doc";
src = haxeDrv.src;
buildInputs = [haxe_latest dox_latest] ++ haxeDrv.buildInputs;
unpackPhase = ''
cp -R $src/src/* ./
'';
buildPhase = ''
ls -la
${haxe_latest}/bin/haxe -xml docs/doc.xml -D doc-gen \
${builtins.concatStringsSep " " (map (x: "-lib ${x}") haxeLibs)}
haxelib run dox -i docs
'';
installPhase = ''
mkdir -p $out/doc
cp pages/* $out/doc
'';
meta =
haxeDrv.meta
// {
description = "Documentation of ${haxeDrv.name}";
};
};
in {
inherit dox_latest mkHaxedoc;
}
}
Loading