Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[support-o_nif_cc] Support o_nif_cc gpb_opt #163

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
]}.

{deps, [
{'gpb', "~> 4.0"}
{'gpb', "~> 4.19.7"}
tak30 marked this conversation as resolved.
Show resolved Hide resolved
]}.

{dialyzer, [
Expand Down
16 changes: 15 additions & 1 deletion src/rebar3_gpb_compiler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
-define(DEFAULT_PROTO_DIR, "proto").
-define(DEFAULT_OUT_ERL_DIR, "src").
-define(DEFAULT_OUT_HRL_DIR, "include").
-define(DEFAULT_OUT_NIF_DIR, "prv").

%% ===================================================================
%% Public API
Expand All @@ -30,10 +31,17 @@ compile(AppInfo, State) ->
TargetHrlDir = filename:join([AppOutDir,
proplists:get_value(o_hrl, GpbOpts0,
?DEFAULT_OUT_HRL_DIR)]),
TargetNifDir = filename:join([AppOutDir,
proplists:get_value(o_nif_cc, GpbOpts0,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this mean that people not interested in NIF generation will get it anyway?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, by default the NIF generation would be off

Copy link
Author

@tak30 tak30 Mar 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What they would get is the priv folder. Maybe we shouldn't create that folder by default. What do you think @lrascao ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, if it can be avoided that would be best, always good to avoid unexpected things

?DEFAULT_OUT_NIF_DIR)]),


rebar_api:debug("making sure that target erl dir ~p exists", [TargetErlDir]),
ok = ensure_dir(TargetErlDir),
rebar_api:debug("making sure that target hrl dir ~p exists", [TargetHrlDir]),
ok = ensure_dir(TargetHrlDir),
rebar_api:debug("making sure that target nif dir ~p exists", [TargetNifDir]),
ok = ensure_dir(TargetHrlDir),
tak30 marked this conversation as resolved.
Show resolved Hide resolved
rebar_api:debug("reading proto files from ~p, generating \".erl\" to ~p "
"and \".hrl\" to ~p",
[SourceDirs, TargetErlDir, TargetHrlDir]),
Expand Down Expand Up @@ -61,7 +69,9 @@ compile(AppInfo, State) ->
proto_include_paths(AppDir, Protos,
default_include_opts(AppDir, DepsDir,
target_erl_opt(TargetErlDir,
target_hrl_opt(TargetHrlDir, GpbOpts0))))),
target_hrl_opt(TargetHrlDir,
target_nif_opt(TargetNifDir, GpbOpts0)
))))),

compile(Protos, TargetErlDir, GpbOpts, Protos),
ok.
Expand Down Expand Up @@ -230,6 +240,10 @@ target_erl_opt(Dir, Opts) ->
target_hrl_opt(Dir, Opts) ->
lists:keystore(o_hrl, 1, Opts, {o_hrl, Dir}).

-spec target_nif_opt(string(), proplists:proplist()) -> proplists:proplist().
target_nif_opt(Dir, Opts) ->
lists:keystore(o_nif_cc, 1, Opts, {o_nif_cc, Dir}).

-spec remove_plugin_opts(proplists:proplists()) -> proplists:proplist().
remove_plugin_opts(Opts) ->
remove_plugin_opts(Opts, [recursive, ipath]).
Expand Down