diff --git a/README.md b/README.md index f2c1e27..70ecb7a 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ The options are as follows: the specific order to compile the ASN.1 files where the first tuple-element is one of `wildcard` | `file` | `dir` and the second the filename in string format. Defaults to - `[{wildcard, \"**/*.asn1\"}]`. + `[{wildcard, \"**/*.{asn1,asn}\"}]`. * `--overrides -O` An Erlang term consisting of a tuple-list of the compile options that will override the options per file. The first tuple-element is one of `file` | `re` and the second the filename diff --git a/src/provider_asn1_clean.erl b/src/provider_asn1_clean.erl index 6354a96..b79ec5e 100644 --- a/src/provider_asn1_clean.erl +++ b/src/provider_asn1_clean.erl @@ -48,10 +48,10 @@ do_clean(State, AppPath) -> IncludePath = filename:join(AppPath, "include"), SrcPath = filename:join(AppPath, "src"), - Asns = filelib:wildcard("**/*.asn1", AsnPath), + Asns = filelib:wildcard("**/*.{asn1,asn}", AsnPath), lists:foreach( fun(AsnFile) -> - Base = filename:basename(AsnFile, ".asn1"), + Base = provider_asn1_util:asn_basename(AsnFile), provider_asn1_util:delete_file(State, SrcPath, Base ++ ".erl"), provider_asn1_util:delete_file(State, IncludePath, Base ++ ".hrl") end, Asns), diff --git a/src/provider_asn1_compile.erl b/src/provider_asn1_compile.erl index 0213b95..7e74684 100644 --- a/src/provider_asn1_compile.erl +++ b/src/provider_asn1_compile.erl @@ -6,7 +6,7 @@ -define(PROVIDER, 'compile'). -define(DEPS, [{default, app_discovery}]). -define(DEFAULTS, [{verbose, false}, {encoding, ber}, {compile_opts, []}, - {compile_order, [{wildcard, "**/*.asn1"}]}]). + {compile_order, [{wildcard, "**/*.{asn1,asn}"}]}]). %% =================================================================== %% Public API @@ -110,7 +110,7 @@ process_app(State, AppPath) -> move_asns(State, GenPath, SrcPath, IncludePath, Asns) -> lists:foreach( fun(AsnFile) -> - Base = filename:basename(AsnFile, ".asn1"), + Base = provider_asn1_util:asn_basename(AsnFile), provider_asn1_util:move_file(State, GenPath, Base ++ ".erl", SrcPath), provider_asn1_util:delete_file(State, GenPath, Base ++ ".asn1db"), provider_asn1_util:move_file(State, GenPath, Base ++ ".hrl", IncludePath) @@ -158,7 +158,7 @@ find_asn_files(State, BasePath) -> [filename:join(BasePath, File)]; ({dir, Dir}) -> D = filename:join(BasePath, Dir), - [filename:join(D, F) || F <- filelib:wildcard("*.asn1", D)] + [filename:join(D, F) || F <- filelib:wildcard("*.{asn1,asn}", D)] end, Order), uniq(Fs). @@ -177,7 +177,7 @@ uniq(Fs) -> is_latest(ASNFileName, ASNPath, GenPath) -> Source = filename:join(ASNPath, ASNFileName), - TargetFileName = filename:basename(ASNFileName, ".asn1") ++ ".erl", + TargetFileName = provider_asn1_util:asn_basename(ASNFileName) ++ ".erl", Target = filename:join(GenPath, TargetFileName), filelib:last_modified(Source) > filelib:last_modified(Target). diff --git a/src/provider_asn1_util.erl b/src/provider_asn1_util.erl index 5c090c1..9f7a932 100644 --- a/src/provider_asn1_util.erl +++ b/src/provider_asn1_util.erl @@ -7,7 +7,9 @@ resolve_args/2, get_args/1, get_arg/2, - set_arg/3]). + set_arg/3, + asn_basename/1 + ]). verbose_out(State, FormatString, Args)-> CommArgs = get_args(State), @@ -71,3 +73,6 @@ set_arg(State, Key, Val) -> Args = rebar_state:get(State, asn1_args, []), ArgsMap = maps:from_list(Args), rebar_state:set(State, asn1_args, maps:to_list(maps:put(Key, Val, ArgsMap))). + +asn_basename(ASNFileName) -> + filename:basename(filename:basename(filename:basename(ASNFileName, ".asn1"), ".asn"), ".set").