Skip to content

Commit

Permalink
Package for haxelib
Browse files Browse the repository at this point in the history
  • Loading branch information
boronine committed Dec 17, 2016
1 parent 6272170 commit 3ef48fc
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 47 deletions.
41 changes: 32 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,70 @@ The reference implementation is [written in Haxe](https://github.com/hsluv/hsluv

## Building

Requirements: [Nix package manage](http://nixos.org/nix/).
Requirements: [Nix package manage](http://nixos.org/nix/). If you want to build without Nix you
will require GNU Make, Haxe 3 and JDK 7+. See `default.nix` for command line instructions.

To run full test suite:

```sh
```
nix-build -A test
```

To build JavaScript distributions (server and client):

```sh
```
nix-build -A jsPublicNodePackage
nix-build -A jsPublicMin
```

To build Haxe documentation:

```sh
```
nix-build -A docs
```

To build website:

```sh
```
nix-build -A website
```

To build website and start localhost server:

```sh
```
(nix-build -A website && cd result && python3 -m http.server)
```

To deploy website (after building):

```sh
```
surge --project ./result
```

If you want to build without Nix you will require GNU Make, Haxe 3 and JDK 7+.
See `default.nix` for command line instructions.
## Testing

The snapshot file is stored for regression testing. If a backwards-incompatible change is made,
a new snapshot file can be generated as follows:

```
nix-build -A snapshotJson
```

The format of the file is as follows:

```
{
"#000000": {
rgb: [ 0, 0, 0 ],
xyz: [ 0, 0, 0 ],
luv: [ 0, 0, 0 ],
lch: [ 0, 0, 0 ],
hsluv: [ 0, 0, 0 ],
hpluv: [ 0, 0, 0 ]
},
...
}
```

## Versioning

Expand Down
20 changes: 15 additions & 5 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ rec {
pkgs = import (pkgsSrc) {};

jre = pkgs.jre;
zip = pkgs.zip;
haxe = pkgs.haxe;
neko = pkgs.neko;
nodejs = pkgs.nodejs;
haxeSrc = ./haxe/src;
haxeTestSrc = ./haxe/test;
closureCompiler = pkgs.closurecompiler;
snapshotRev4 = ./snapshots/snapshot-rev4.json;
closureCompiler = pkgs.closurecompiler;

doxZip = pkgs.fetchurl {
url = "https://github.com/HaxeFoundation/dox/archive/a4dd456418a4a540fe1d25a764927119bb892f72.zip";
Expand Down Expand Up @@ -79,10 +80,7 @@ rec {

docs = pkgs.stdenv.mkDerivation rec {
name = "docs";
inherit neko;
inherit haxe;
inherit haxeSrc;
inherit doxZip;
inherit neko haxe haxeSrc doxZip;
builder = builtins.toFile "builder.sh" ''
source $stdenv/setup
PATH=$haxe/bin:$neko/bin:$PATH
Expand All @@ -96,6 +94,18 @@ rec {
'';
};

haxelibZip = pkgs.stdenv.mkDerivation rec {
name = "haxelib";
inherit zip haxe;
haxeRoot = ./haxe;
builder = builtins.toFile "builder.sh" ''
source $stdenv/setup
mkdir $out
(cd $haxeRoot && $zip/bin/zip -r $out/hsluv.zip .)
echo "$haxe/bin/haxelib submit hsluv.zip" > $out/submit.sh
'';
};

haxeJs = { targets, export } : pkgs.stdenv.mkDerivation rec {
inherit haxe haxeSrc export;
name = "hsluv-js";
Expand Down
33 changes: 5 additions & 28 deletions haxe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,42 +77,19 @@ haxe -cp src -cp test -main RunTests -resource ../snapshots/snapshot-rev4.json@s
haxe -cp src -cp test -main RunTests -resource ../snapshots/snapshot-rev4.json@snapshot-rev4 -cs bin/cs -cmd mono bin/cs/RunTests.exe
# C# Windows
haxe -cp src -cp test -main RunTests -resource ../snapshots/snapshot-rev4.json@snapshot-rev4 -cs bin/cs -cmd bin/cs/RunTests.exe
# Java
# Java
haxe -cp src -cp test -main RunTests -resource ../snapshots/snapshot-rev4.json@snapshot-rev4 -java bin/java -cmd java -jar bin/java/RunTests.jar
# PHP
# PHP
haxe -cp src -cp test -main RunTests -resource ../snapshots/snapshot-rev4.json@snapshot-rev4 -php bin/php -cmd php bin/php/index.php
# NodeJS
# NodeJS
haxe -cp src -cp test -main RunTests -resource ../snapshots/snapshot-rev4.json@snapshot-rev4 -js bin/js/RunTests.js -cmd node bin/js/RunTests.js
# Python
# Python
haxe -cp src -cp test -main RunTests -resource ../snapshots/snapshot-rev4.json@snapshot-rev4 -python bin/python/RunTests.py -cmd python bin/python/RunTests.py
# Lua
# Lua
haxe -cp src -cp test -main RunTests -resource ../snapshots/snapshot-rev4.json@snapshot-rev4 -lua bin/lua/RunTests.lua -cmd lua bin/lua/RunTests.lua
# And so on...
```

The snapshot file is stored for regression testing. If a backwards-incompatible change is made,
a new snapshot file can be generated as follows:

```sh
haxe -cp src -cp test -main Snapshot --interp > new-snapshot.json
```

The format of the file is as follows:

```
{
"#000000": {
rgb: [ 0, 0, 0 ],
xyz: [ 0, 0, 0 ],
luv: [ 0, 0, 0 ],
lch: [ 0, 0, 0 ],
hsluv: [ 0, 0, 0 ],
hpluv: [ 0, 0, 0 ]
},
...
}
```

# Notes

This code work on some targets, but here are some tests that couldn't pass on my computer:
Expand Down
9 changes: 4 additions & 5 deletions haxe/haxelib.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"name": "hsluv",
"url" : "https://github.com/hsluv/hsluv",
"url" : "http://www.hsluv.org/",
"license": "MIT",
"tags": ["cross", "color"],
"description": "Human-friendly HSL.",
"version": "1.0.0",
"version": "0.0.1",
"classPath": "src/",
"releasenote": "Initial release, everything is working correctly.",
"contributors": ["Eiyeron"],
"dependencies": {
}
"contributors": ["hsluv"],
"dependencies": {}
}

0 comments on commit 3ef48fc

Please sign in to comment.