diff --git a/README.md b/README.md index 798861b..b39ef8c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,11 @@ An OTP library Build ----- - $ rebar3 compile + $ rebar3 escriptize + +Use +----- + genProto ProtoInputDir HrlOutDir ErlOutDir # 简单描述 diff --git a/rebar.config b/rebar.config index f618f3e..1e04d1a 100644 --- a/rebar.config +++ b/rebar.config @@ -1,2 +1,8 @@ {erl_opts, [debug_info]}. -{deps, []}. \ No newline at end of file +{deps, []}. + +{escript_main_app, genProto}. % specify which app is the escript app +{escript_name, genProto}. % name of final generated escript +%%{escript_emu_args, "%%! -escript main Module\n"}. % emulator args +%%{escript_shebang, "#!/usr/bin/env escript\n"}. % executable line +%%{escript_comment, "%%\n"}. % comment at top of escript file \ No newline at end of file diff --git a/src/genProto.erl b/src/genProto.erl index a04dc94..b82523b 100644 --- a/src/genProto.erl +++ b/src/genProto.erl @@ -2,6 +2,8 @@ -include("genDef.hrl"). +-export([main/1]). + -export([ convertFile/1 , convert/1 @@ -10,6 +12,10 @@ , convertDir/3 ]). +main(Args) -> + [ProtoDir, HrlDir, ErlDir] = Args, + convertDir(ProtoDir, HrlDir, ErlDir). + convertFile(File) -> erlang:erase(), erlang:put(pd_errlist, []), diff --git a/test/gen.bat b/test/gen.bat new file mode 100644 index 0000000..ccae33e --- /dev/null +++ b/test/gen.bat @@ -0,0 +1 @@ +genProto ../proto ./ ./ diff --git a/test/gen.sh b/test/gen.sh new file mode 100644 index 0000000..ac49ae1 --- /dev/null +++ b/test/gen.sh @@ -0,0 +1 @@ +protoGen ../proto ./ ./ diff --git a/test/genProto b/test/genProto new file mode 100644 index 0000000..3ee183b Binary files /dev/null and b/test/genProto differ diff --git a/test/genProto.bat b/test/genProto.bat deleted file mode 100644 index 4c446f7..0000000 --- a/test/genProto.bat +++ /dev/null @@ -1 +0,0 @@ -erl -pa ../ebin -s genProto convert ../proto ./ ./ diff --git a/test/genProto.cmd b/test/genProto.cmd new file mode 100644 index 0000000..179789b --- /dev/null +++ b/test/genProto.cmd @@ -0,0 +1,2 @@ +@echo off +escript.exe "%~dpn0" %* diff --git a/test/genProto.sh b/test/genProto.sh deleted file mode 100644 index 017c66d..0000000 --- a/test/genProto.sh +++ /dev/null @@ -1 +0,0 @@ -erl -pa ../ebin -s protoGen convert ../proto ./ ./