added makefile and build script
This commit is contained in:
parent
50b0d03083
commit
a6990152b3
3 changed files with 68 additions and 0 deletions
13
makefile
Normal file
13
makefile
Normal file
|
@ -0,0 +1,13 @@
|
|||
compile:
|
||||
./priv/jsx compile
|
||||
|
||||
test: force
|
||||
./priv/jsx test
|
||||
|
||||
examples: force
|
||||
./priv/jsx examples
|
||||
|
||||
clean:
|
||||
./priv/jsx clean
|
||||
|
||||
force:
|
BIN
priv/.DS_Store
vendored
Normal file
BIN
priv/.DS_Store
vendored
Normal file
Binary file not shown.
55
priv/jsx
Executable file
55
priv/jsx
Executable file
|
@ -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") ].
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue