diff --git a/.gitignore b/.gitignore index 249a92d..3045e5a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,9 @@ /ebin /.eunit +/deps + +# created by get-deps +/priv/piqi-binary # vim *.swp diff --git a/Makefile b/Makefile index 3e9cdfd..ace785b 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,7 @@ clean: distclean: clean + $(REBAR) delete-deps rm -rf ebin deps diff --git a/examples/addressbook/deps/piqi_binary b/examples/addressbook/deps/piqi_binary new file mode 120000 index 0000000..b89edb0 --- /dev/null +++ b/examples/addressbook/deps/piqi_binary @@ -0,0 +1 @@ +../../../deps/piqi_binary \ No newline at end of file diff --git a/examples/custom-types/deps/piqi_binary b/examples/custom-types/deps/piqi_binary new file mode 120000 index 0000000..b89edb0 --- /dev/null +++ b/examples/custom-types/deps/piqi_binary @@ -0,0 +1 @@ +../../../deps/piqi_binary \ No newline at end of file diff --git a/examples/untyped-json-xml/deps/piqi_binary b/examples/untyped-json-xml/deps/piqi_binary new file mode 120000 index 0000000..b89edb0 --- /dev/null +++ b/examples/untyped-json-xml/deps/piqi_binary @@ -0,0 +1 @@ +../../../deps/piqi_binary \ No newline at end of file diff --git a/rebar.config b/rebar.config index 8234314..84d9563 100644 --- a/rebar.config +++ b/rebar.config @@ -4,6 +4,12 @@ {sub_dirs, ["piqic-erlang"]}. +{deps, [ + % "piqi" binary executables pre-built for various platforms + {piqi_binary, "", {git, "git://github.com/alavrik/piqi-binary.git", {tag, "v0.6.1"}}, [raw]} +]}. + + % tolerate edoc quirks by #ifndef-ing several adjacent -spec {edoc_opts, [{preprocess, true}, {macros, [{'EDOC', 1}]}]}. @@ -14,7 +20,11 @@ {post_hooks, [ - {clean, "make -C src -f Makefile.piqi clean"} + {clean, "make -C src -f Makefile.piqi clean"}, + + {'get-deps', "rm -rf priv/piqi-binary"}, + {'get-deps', "cp -a \"$REBAR_DEPS_DIR/piqi_binary\" priv/piqi-binary"}, + {'delete-deps', "rm -rf priv/piqi-binary"} ]}. diff --git a/src/Makefile b/src/Makefile index 1478bb0..5e94d93 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,6 @@ -# TODO: uncomment this once the the new (fixed) version of piqi is released -#PIQI = ../priv/bin-"`uname -s`-`uname -m`"/piqi -PIQI = piqi +#PIQI = piqi +PIQI = ../priv/piqi-binary/"`uname -s`-`uname -m`"/piqi #PIQIC = ../piqic-erlang/piqic-erlang PIQIC = ERL_FLAGS="-pa ../piqic-erlang/ebin" ../priv/bin/piqic-erlang diff --git a/src/piqi.erl b/src/piqi.erl index c69a01b..fe2dfe3 100644 --- a/src/piqi.erl +++ b/src/piqi.erl @@ -46,9 +46,9 @@ find_piqi() -> PiqiDir -> KernelName = os:cmd("uname -s") -- "\n", Machine = os:cmd("uname -m") -- "\n", - BinDir = lists:concat(["bin-", KernelName, "-", Machine]), + Arch = lists:concat([KernelName, "-", Machine]), % path to "piqi" executable within "piqi" application directory - FullName = filename:join([PiqiDir, "priv", BinDir, "piqi"]), + FullName = filename:join([PiqiDir, "priv", "piqi-binary", Arch, "piqi"]), case filelib:is_regular(FullName) of true -> FullName; diff --git a/src/piqic_erlang.erl b/src/piqic_erlang.erl index a9e7cdd..d438495 100644 --- a/src/piqic_erlang.erl +++ b/src/piqic_erlang.erl @@ -210,9 +210,9 @@ get_cwd(_NewCwd) -> find_piqi_executable() -> KernelName = os:cmd("uname -s") -- "\n", Machine = os:cmd("uname -m") -- "\n", - BinDir = lists:concat(["bin-", KernelName, "-", Machine]), + Arch = lists:concat([KernelName, "-", Machine]), % path to "piqi" executable within "piqi" application directory - AppPath = filename:join(["priv", BinDir, "piqi"]), + AppPath = filename:join(["priv", "piqi-binary", Arch, "piqi"]), try case os:getenv("REBAR_DEPS_DIR") of false ->