From a6990152b382cb4f12f10adb5863ae0f09de1a73 Mon Sep 17 00:00:00 2001 From: alisdair sullivan Date: Mon, 7 Jun 2010 17:21:04 -0700 Subject: [PATCH] added makefile and build script --- makefile | 13 ++++++++++++ priv/.DS_Store | Bin 0 -> 6148 bytes priv/jsx | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 makefile create mode 100644 priv/.DS_Store create mode 100755 priv/jsx diff --git a/makefile b/makefile new file mode 100644 index 0000000..d01d450 --- /dev/null +++ b/makefile @@ -0,0 +1,13 @@ +compile: + ./priv/jsx compile + +test: force + ./priv/jsx test + +examples: force + ./priv/jsx examples + +clean: + ./priv/jsx clean + +force: \ No newline at end of file diff --git a/priv/.DS_Store b/priv/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..6a25882ac789f60f7dec7f444480d6a37593dc20 GIT binary patch literal 6148 zcmeHKJxc>Y5PhR50wI#p&iw^~|6mERu(lPHODvRwNKC-;y8P_;=0nMO+FIxg%)Hy# zdAoP7xY-3D^WEwSm;o5m6|vVaG@Vx;*hyp*#nyPlE0);c2`_`{?-RCz;Oog5@#0`+OHG4yj|MyL*kWZXY|!?ZxckC1dWKXW6-WhAfmGn1D!`tt zHl8?UOa)SbRNzwq{XZ1CVh!vZ?bpGe$9J6{DXQ_=?h?cj;~LmGa)u^OB|25&iXl#C zzC>LO>>QmAv7Nb2>@0CZ5!;>lV&#zPm@ySd1^Nn{`f#TG|C;{8{l8DjQ7VuM{3!)w zw76Z&`AN}R2Op=sw$LBwAI4fMXXqUQIM7ynepFZVnRPX=b2K{hMknS$Ky^t=1%5+; Eceo)cDgXcg literal 0 HcmV?d00001 diff --git a/priv/jsx b/priv/jsx new file mode 100755 index 0000000..b1b2136 --- /dev/null +++ b/priv/jsx @@ -0,0 +1,55 @@ +#!/usr/bin/env escript + +main(Args) -> + case Args of + ["compile"|Opts] -> compile(Opts) + ; ["examples"|Opts] -> examples(Opts) + ; ["test"|Opts] -> test(Opts) + ; ["clean"|Opts] -> clean(Opts) + end. + +compile([]) -> + Mods = ["src/jsx"], + compile_files(Mods, [{outdir, "ebin"}]), + compile_backend(). + +compile_files([], _) -> + ok; +compile_files([FileName|Rest], Opts) -> + case compile:file(FileName, Opts) of + {ok, _} -> ok + ; {ok, Name, Bin} -> file:write_file("ebin/" ++ atom_to_list(Name) ++ ".beam", Bin), ok + end, + compile_files(Rest, Opts). + +compile_backend() -> + [ compile_files(["src/jsx_decoder"], [binary, {d, Backend}, {d, name, to_modname(Backend)}]) + || Backend <- [utf8, utf16, utf16le, utf32, utf32le] + ]. + +to_modname(Atom) -> + list_to_atom("jsx_" ++ atom_to_list(Atom)). + + +examples([]) -> + Mods = ["examples/jsx_prettify", + "examples/jsx_parser", + "examples/jsx_stream_parser", + "examples/jsx_verify" + ], + compile_files(Mods, [{outdir, "ebin"}]). + +test(Path) -> + Mods = ["test/jsx_test"], + compile_files(Mods, [{outdir, "ebin"}]), + true = code:add_path("ebin"), + case Path of + [] -> jsx_test:test("test/cases") + ; Path -> jsx_test:test(Path) + end. + +clean([]) -> + [ file:delete(Filename) || Filename <- filelib:wildcard("ebin/*.beam") ]. + + + \ No newline at end of file