mirror of
https://github.com/correl/rebar.git
synced 2024-11-15 03:00:18 +00:00
Move asn1 generated *.hrl to include
This commit is contained in:
parent
e7ea53f724
commit
f16ebd13dc
1 changed files with 16 additions and 10 deletions
|
@ -44,27 +44,33 @@ compile(Config, _AppFile) ->
|
||||||
|
|
||||||
-spec clean(Config::rebar_config:config(), AppFile::file:filename()) -> 'ok'.
|
-spec clean(Config::rebar_config:config(), AppFile::file:filename()) -> 'ok'.
|
||||||
clean(_Config, _AppFile) ->
|
clean(_Config, _AppFile) ->
|
||||||
rebar_file_utils:delete_each(asn_generated_files("asn1", "src")),
|
GeneratedFiles = asn_generated_files("asn1", "src", "include"),
|
||||||
|
ok = rebar_file_utils:delete_each(GeneratedFiles),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
-spec compile_asn1(file:filename(), file:filename(),
|
-spec compile_asn1(file:filename(), file:filename(),
|
||||||
rebar_config:config()) -> ok.
|
rebar_config:config()) -> ok.
|
||||||
compile_asn1(Source, Target, Config) ->
|
compile_asn1(Source, Target, Config) ->
|
||||||
ok = rebar_utils:ensure_dir(Target),
|
ok = filelib:ensure_dir(Target),
|
||||||
|
ok = filelib:ensure_dir(filename:join("include", "dummy.hrl")),
|
||||||
Opts = [{outdir, "src"}, noobj] ++ rebar_config:get(Config, asn1_opts, []),
|
Opts = [{outdir, "src"}, noobj] ++ rebar_config:get(Config, asn1_opts, []),
|
||||||
case asn1ct:compile(Source, Opts) of
|
case asn1ct:compile(Source, Opts) of
|
||||||
ok ->
|
ok ->
|
||||||
|
Asn1 = filename:basename(Source, ".asn1"),
|
||||||
|
HrlFile = filename:join("src", Asn1 ++ ".hrl"),
|
||||||
|
ok = rebar_file_utils:mv(HrlFile, "include"),
|
||||||
ok;
|
ok;
|
||||||
{error, _Reason} ->
|
{error, _Reason} ->
|
||||||
?FAIL
|
?FAIL
|
||||||
end.
|
end.
|
||||||
|
|
||||||
asn_generated_files(AsnDir, SrcDir) ->
|
asn_generated_files(AsnDir, SrcDir, IncDir) ->
|
||||||
lists:foldl(
|
lists:foldl(
|
||||||
fun(AsnFile, Acc) ->
|
fun(AsnFile, Acc) ->
|
||||||
Base = filename:rootname(filename:basename(AsnFile)),
|
Base = filename:rootname(filename:basename(AsnFile)),
|
||||||
filelib:wildcard(filename:join([SrcDir, Base ++ ".*"])) ++ Acc
|
[filename:join([IncDir, Base ++ ".hrl"])|
|
||||||
end,
|
filelib:wildcard(filename:join([SrcDir, Base ++ ".*"]))] ++ Acc
|
||||||
[],
|
end,
|
||||||
filelib:wildcard(filename:join([AsnDir, "*.asn1"]))
|
[],
|
||||||
).
|
filelib:wildcard(filename:join([AsnDir, "*.asn1"]))
|
||||||
|
).
|
||||||
|
|
Loading…
Reference in a new issue