diff --git a/src/jsx_decoder.hrl b/include/jsx_decoder.hrl similarity index 100% rename from src/jsx_decoder.hrl rename to include/jsx_decoder.hrl diff --git a/src/jsx_types.hrl b/include/jsx_types.hrl similarity index 100% rename from src/jsx_types.hrl rename to include/jsx_types.hrl diff --git a/makefile b/makefile index 037d48f..3c64ce1 100644 --- a/makefile +++ b/makefile @@ -1,23 +1,9 @@ compile: expand - ./priv/jsx_compile.escript\ - src/jsx\ - src/jsx_utf8\ - src/jsx_utf16\ - src/jsx_utf16le\ - src/jsx_utf32\ - src/jsx_utf32le - -debug: expand - ./priv/jsx_compile.escript -d\ - src/jsx\ - src/jsx_utf8\ - src/jsx_utf16\ - src/jsx_utf16le\ - src/jsx_utf32\ - src/jsx_utf32le + ./rebar compile + ./priv/backends.escript clean expand: - ./priv/jsx_expand.escript utf8 utf16 utf16le utf32 utf32le + ./priv/backends.escript create test: compile ./priv/jsx_test.escript test/cases @@ -26,9 +12,5 @@ prove: prove ./priv/jsx_test.escript clean: - ./priv/jsx_clean.escript - -install: clean compile - ./priv/jsx_install.escript - -force: \ No newline at end of file + ./rebar clean + ./priv/backends.escript clean \ No newline at end of file diff --git a/priv/jsx_expand.escript b/priv/backends.escript similarity index 82% rename from priv/jsx_expand.escript rename to priv/backends.escript index 580567b..cb813bf 100755 --- a/priv/jsx_expand.escript +++ b/priv/backends.escript @@ -22,8 +22,14 @@ %% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN %% THE SOFTWARE. -main(Backends) -> - lists:foreach(fun(X) -> to_src(X) end, [ to_abf(Backend) || Backend <- Backends ]). +main(["create"]) -> + lists:foreach( + fun(X) -> to_src(X) end, + [ to_abf(Backend) || Backend <- ["utf8", "utf16", "utf16le", "utf32", "utf32le"] ] + ); + +main(["clean"]) -> + [ file:delete(Filename) || Filename <- ["src/jsx_utf8.erl", "src/jsx_utf16.erl", "src/jsx_utf16le.erl", "src/jsx_utf32.erl", "src/jsx_utf32le.erl"] ]. to_abf(Backend) -> case os:getenv("TMPDIR") of @@ -32,7 +38,7 @@ to_abf(Backend) -> end, Name = to_modname(Backend), {ok, _, ABF} = compile:file( - "src/jsx_decoder.erl", + "priv/jsx_decoder.erl", [binary, 'P', {outdir, Out}, {d, list_to_atom(Backend)}, {d, name, Name}] ), {Name, ABF}. diff --git a/priv/jsx_clean.escript b/priv/jsx_clean.escript deleted file mode 100755 index ddd16b5..0000000 --- a/priv/jsx_clean.escript +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env escript - -%% The MIT License - -%% Copyright (c) 2010 Alisdair Sullivan - -%% Permission is hereby granted, free of charge, to any person obtaining a copy -%% of this software and associated documentation files (the "Software"), to deal -%% in the Software without restriction, including without limitation the rights -%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -%% copies of the Software, and to permit persons to whom the Software is -%% furnished to do so, subject to the following conditions: - -%% The above copyright notice and this permission notice shall be included in -%% all copies or substantial portions of the Software. - -%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -%% THE SOFTWARE. - - -main([]) -> - [ file:delete(Filename) || Filename <- filelib:wildcard("ebin/*.beam") ], - [ file:delete(Filename) || Filename <- filelib:wildcard("src/jsx_u*.erl") ]. diff --git a/priv/jsx_compile.escript b/priv/jsx_compile.escript deleted file mode 100755 index 92669b5..0000000 --- a/priv/jsx_compile.escript +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env escript - -%% The MIT License - -%% Copyright (c) 2010 Alisdair Sullivan - -%% Permission is hereby granted, free of charge, to any person obtaining a copy -%% of this software and associated documentation files (the "Software"), to deal -%% in the Software without restriction, including without limitation the rights -%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -%% copies of the Software, and to permit persons to whom the Software is -%% furnished to do so, subject to the following conditions: - -%% The above copyright notice and this permission notice shall be included in -%% all copies or substantial portions of the Software. - -%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -%% THE SOFTWARE. - -main(["-d"|Mods]) -> - compile_files(Mods, [{outdir, "ebin"}, debug_info]); - -main(Mods) -> - compile_files(Mods, [{outdir, "ebin"}]). - -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). - - - \ No newline at end of file diff --git a/src/jsx_decoder.erl b/priv/jsx_decoder.erl similarity index 99% rename from src/jsx_decoder.erl rename to priv/jsx_decoder.erl index 7f9e0af..f884135 100644 --- a/src/jsx_decoder.erl +++ b/priv/jsx_decoder.erl @@ -29,8 +29,8 @@ -export([parse/2]). --include("jsx_decoder.hrl"). --include("jsx_types.hrl"). +-include("./include/jsx_decoder.hrl"). +-include("./include/jsx_types.hrl"). -spec parse(JSON::json(), Opts::jsx_opts()) -> jsx_parser_result(). diff --git a/priv/jsx_install.escript b/priv/jsx_install.escript deleted file mode 100755 index 244d117..0000000 --- a/priv/jsx_install.escript +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env escript - -%% The MIT License - -%% Copyright (c) 2010 Alisdair Sullivan - -%% Permission is hereby granted, free of charge, to any person obtaining a copy -%% of this software and associated documentation files (the "Software"), to deal -%% in the Software without restriction, including without limitation the rights -%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -%% copies of the Software, and to permit persons to whom the Software is -%% furnished to do so, subject to the following conditions: - -%% The above copyright notice and this permission notice shall be included in -%% all copies or substantial portions of the Software. - -%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -%% THE SOFTWARE. - - -main([]) -> - os:cmd("mkdir -p " ++ appdir()), - os:cmd("cp -r " ++ "ebin " ++ appdir()). - -appdir() -> - {ok, [{application, jsx, AppInfo}]} = file:consult("ebin/jsx.app"), - code:lib_dir() ++ "/jsx-" ++ proplists:get_value(vsn, AppInfo). \ No newline at end of file diff --git a/rebar b/rebar new file mode 100755 index 0000000..823976b Binary files /dev/null and b/rebar differ diff --git a/src/jsx.erl b/src/jsx.erl index 736f5c7..438aec6 100644 --- a/src/jsx.erl +++ b/src/jsx.erl @@ -28,7 +28,7 @@ -export([parser/0, parser/1]). %% types for function specifications --include("jsx_types.hrl"). +-include("./include/jsx_types.hrl"). %% opts record -record(opts, {