Browse files

added escript and dialyzer ignors warning

  • Loading branch information...
1 parent 459382e commit dcc59e40f8d0d64ec39c48738a38b732d8dc29fc @freke committed Apr 25, 2012
Showing with 102 additions and 15 deletions.
  1. +1 −0 .gitignore
  2. +8 −0 README.markdown
  3. +0 −10 bin/protoc-erl
  4. +24 −0 dialyzer.ignore-warnings
  5. +36 −1 makefile
  6. +6 −2 rebar.config
  7. +2 −2 src/protobuffs_compile.erl
  8. +25 −0 src/protoc-erl.erl
View
1 .gitignore
@@ -1,4 +1,5 @@
ebin
+bin
*.beam
*.gz
*~
View
8 README.markdown
@@ -52,6 +52,13 @@ Person message into records.
How cool is that? From .proto files, we create modules that export encode and
decode functions for the messages defined.
+## script
+
+It't also posible to create a escript "bin/protoc-erl" this self contained script
+generates a source code (.erl) file and a header (.hrl) file.
+
+ &>./protoc-erl path_to_proto_file
+
## no_debug_info
The protobuffs_compile module relies on the pokemon_pb module being compiled
@@ -83,6 +90,7 @@ A simple makefile is also included
&>make ct
+ &>make escriptize
## CREDITS
View
10 bin/protoc-erl
@@ -1,10 +0,0 @@
-#!/usr/bin/env escript
-%% -*- erlang -*-
-%%! -sasl errlog_type error -boot start_sasl -noshell
-
-main ([File]) ->
- protobuffs_compile:generate_source (File);
-main (_) ->
- io:format ("usage: ~s <protofile>~n",
- [filename:basename (escript:script_name())]),
- halt (1).
View
24 dialyzer.ignore-warnings
@@ -0,0 +1,24 @@
+leexinc.hrl:49: The pattern <Rest, Line, {'token', T, Push}, Ts> can never match the type <_,_,'error' | 'skip_token',[{atom(),_} | {'float',_,float()} | {'integer',_,[any()] | integer()} | {'string',_,[any()]} | {'var',_,atom()}]>
+leexinc.hrl:52: The pattern <Rest, Line, {'end_token', T}, Ts> can never match the type <_,_,'error' | 'skip_token',[{atom(),_} | {'float',_,float()} | {'integer',_,[any()] | integer()} | {'string',_,[any()]} | {'var',_,atom()}]>
+leexinc.hrl:54: The pattern <Rest, Line, {'end_token', T, Push}, Ts> can never match the type <_,_,'error' | 'skip_token',[{atom(),_} | {'float',_,float()} | {'integer',_,[any()] | integer()} | {'string',_,[any()]} | {'var',_,atom()}]>
+leexinc.hrl:59: The pattern <Rest, Line, {'skip_token', Push}, Ts> can never match the type <_,_,'error',[{atom(),_} | {'float',_,float()} | {'integer',_,[any()] | integer()} | {'string',_,[any()]} | {'var',_,atom()}]>
+leexinc.hrl:62: The pattern <_Rest, Line, {'error', S}, _Ts> can never match the type <_,_,'error',[{atom(),_} | {'float',_,float()} | {'integer',_,[any()] | integer()} | {'string',_,[any()]} | {'var',_,atom()}]>
+leexinc.hrl:118: The pattern <Rest, Line, {'token', T, Push}> can never match the type <_,_,'error' | 'skip_token'>
+leexinc.hrl:121: The pattern <Rest, Line, {'end_token', T}> can never match the type <_,_,'error' | 'skip_token'>
+leexinc.hrl:123: The pattern <Rest, Line, {'end_token', T, Push}> can never match the type <_,_,'error' | 'skip_token'>
+leexinc.hrl:128: The pattern <Rest, Line, {'skip_token', Push}> can never match the type <_,_,'error'>
+leexinc.hrl:131: The pattern <Rest, Line, {'error', S}> can never match the type <_,_,'error'>
+leexinc.hrl:192: The pattern <Rest, Line, {'token', T, Push}, Ts> can never match the type <_,_,'error' | 'skip_token',_>
+leexinc.hrl:195: The pattern <Rest, Line, {'end_token', T}, Ts> can never match the type <_,_,'error' | 'skip_token',_>
+leexinc.hrl:197: The pattern <Rest, Line, {'end_token', T, Push}, Ts> can never match the type <_,_,'error' | 'skip_token',_>
+leexinc.hrl:202: The pattern <Rest, Line, {'skip_token', Push}, Ts> can never match the type <_,_,'error',_>
+leexinc.hrl:205: The pattern <Rest, Line, {'error', S}, _Ts> can never match the type <_,_,'error',_>
+leexinc.hrl:243: The pattern <Rest, Line, {'token', _T, Push}, Error> can never match the type <_,_,'error' | 'skip_token',_>
+leexinc.hrl:246: The pattern <Rest, Line, {'end_token', _T}, Error> can never match the type <_,_,'error' | 'skip_token',_>
+leexinc.hrl:248: The pattern <Rest, Line, {'end_token', _T, Push}, Error> can never match the type <_,_,'error' | 'skip_token',_>
+leexinc.hrl:253: The pattern <Rest, Line, {'skip_token', Push}, Error> can never match the type <_,_,'error',_>
+leexinc.hrl:256: The pattern <Rest, Line, {'error', _S}, Error> can never match the type <_,_,'error',_>
+leexinc.hrl:260: Function yyrev/2 will never be called
+pokemon_pb.erl:43: The variable _ can never match since previous clauses completely covered the type #pikachu{}
+pokemon_pb.erl:52: The pattern <Default, _> can never match since previous clauses completely covered the type <_,'none'>
+pokemon_pb.erl:53: The pattern <Val, _> can never match since previous clauses completely covered the type <_,'none'>
View
37 makefile
@@ -1,13 +1,16 @@
REBAR=`which rebar` || ./rebar
-all: get-deps compile
+all: get-deps compile escriptize
get-deps:
@$(REBAR) get-deps
compile:
@$(REBAR) compile
+escriptize:
+ @$(REBAR) escriptize
+
ct:
@$(REBAR) skip_deps=true ct
@@ -18,3 +21,35 @@ test: compile eunit ct
clean:
@$(REBAR) clean
+
+check: compile xref dialyzer
+
+xref:
+ @$(REBAR) skip_deps=true xref
+
+APPS = kernel stdlib sasl erts syntax_tools compiler
+COMBO_PLT = $(HOME)/.protobuffs_combo_dialyzer_plt
+
+check_plt: compile
+ dialyzer --check_plt --plt $(COMBO_PLT) --apps $(APPS) ebin
+
+
+build_plt: compile
+ dialyzer --build_plt --output_plt $(COMBO_PLT) --apps $(APPS) ebin
+
+dialyzer: compile
+ @echo
+ @echo Use "'make check_plt'" to check PLT prior to using this target.
+ @echo Use "'make build_plt'" to build PLT prior to using this target.
+ @echo
+ @sleep 1
+ dialyzer -Wno_return -Wunmatched_returns -Werror_handling -Wrace_conditions --plt $(COMBO_PLT) ebin | \
+ fgrep -v -f dialyzer.ignore-warnings
+
+cleanplt:
+ @echo
+ @echo "Are you sure? It takes about 1/2 hour to re-build."
+ @echo Deleting $(COMBO_PLT) in 5 seconds.
+ @echo
+ sleep 5
+ rm $(COMBO_PLT)
View
8 rebar.config
@@ -1,7 +1,8 @@
{erl_opts, [debug_info,warn_missing_spec]}.
{deps,[{proper,"1.*", {git, "https://github.com/manopapad/proper.git", "master"}},
- {meck,"0.*", {git, "https://github.com/eproxus/meck.git", {branch, "master"}}}
+ {meck,"0.*", {git, "https://github.com/eproxus/meck.git", {branch, "master"}}},
+ {getopt, "0.4.*", {git, "https://github.com/jcomellas/getopt.git", {branch, "master"}}}
]}.
{clean_files, ["*~","**/*~","**/*.beam","logs/*","**/*.orig","**/*.bak*"]}.
@@ -11,5 +12,8 @@
{eunit_opts, [verbose,
{report, {eunit_surefire, [{dir, "."}]}}]}.
-{escript_name, "protobuffs_compile"}.
+{xref_checks, [undefined_function_calls]}.
+
+{escript_name, "bin/protoc-erl"}.
{escript_emu_args, "%%! -sasl errlog_type error -boot start_sasl -noshell\n"}.
+{escript_incl_apps, [getopt]}.
View
4 src/protobuffs_compile.erl
@@ -171,11 +171,11 @@ generate_output(Options, Basename, String, OutputFunction) ->
Options).
create_forms(Basename, Messages, Enums) ->
- PokemonBeamFile = code:where_is_file("pokemon_pb.beam"),
+ {_,Binary,_} = code:get_object_code(pokemon_pb),
{ok,
{_,
[{abstract_code,
- {_, Forms}}]}} = beam_lib:chunks(PokemonBeamFile,
+ {_, Forms}}]}} = beam_lib:chunks(Binary,
[abstract_code]),
protobuffs_compile_lib:filter_forms(Messages, Enums, Forms, Basename, []).
View
25 src/protoc-erl.erl
@@ -0,0 +1,25 @@
+%%% @author David Åberg <>
+%%% @copyright (C) 2012, David Åberg
+%%% @doc
+%%%
+%%% @end
+%%% Created : 25 Apr 2012 by David Åberg <>
+
+-module('protoc-erl').
+
+-export([main/1]).
+
+main(Args) ->
+ OptSpecList = [{file, undefined, undefined, string, "Input protobuf file"}],
+ case getopt:parse(OptSpecList, Args) of
+ {ok,{Opt,_Rest}} ->
+ case proplists:get_value(file,Opt) of
+ undefined -> getopt:usage(OptSpecList, "protoc-erl");
+ File ->
+ protobuffs_compile:generate_source (File)
+ end;
+ _ ->
+ getopt:usage(OptSpecList, "protoc-erl")
+ end.
+
+

0 comments on commit dcc59e4

Please sign in to comment.