From bfd962a82dcf3e92f2cabb0e54984919a4561326 Mon Sep 17 00:00:00 2001 From: Pablo Lopez Date: Mon, 13 Feb 2023 12:43:19 +0100 Subject: [PATCH 1/3] [support-o_nif_cc] Support o_nif_cc gpb_opt --- rebar.config | 2 +- src/rebar3_gpb_compiler.erl | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/rebar.config b/rebar.config index 7d9833e..b43c024 100644 --- a/rebar.config +++ b/rebar.config @@ -12,7 +12,7 @@ ]}. {deps, [ - {'gpb', "~> 4.0"} + {'gpb', "~> 4.19.7"} ]}. {dialyzer, [ diff --git a/src/rebar3_gpb_compiler.erl b/src/rebar3_gpb_compiler.erl index 6a6d8dc..2bbdfbd 100644 --- a/src/rebar3_gpb_compiler.erl +++ b/src/rebar3_gpb_compiler.erl @@ -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 @@ -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, + ?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), rebar_api:debug("reading proto files from ~p, generating \".erl\" to ~p " "and \".hrl\" to ~p", [SourceDirs, TargetErlDir, TargetHrlDir]), @@ -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. @@ -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]). From 51098186a2ea9ed8c38babf295b356a0194c3351 Mon Sep 17 00:00:00 2001 From: Pablo Lopez Date: Mon, 6 Mar 2023 13:52:31 +0100 Subject: [PATCH 2/3] [support-o_nif_cc] Removing gpb version bump and applied suggestions by @lrascao --- rebar.config | 2 +- src/rebar3_gpb_compiler.erl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rebar.config b/rebar.config index b43c024..7d9833e 100644 --- a/rebar.config +++ b/rebar.config @@ -12,7 +12,7 @@ ]}. {deps, [ - {'gpb', "~> 4.19.7"} + {'gpb', "~> 4.0"} ]}. {dialyzer, [ diff --git a/src/rebar3_gpb_compiler.erl b/src/rebar3_gpb_compiler.erl index 2bbdfbd..121dfce 100644 --- a/src/rebar3_gpb_compiler.erl +++ b/src/rebar3_gpb_compiler.erl @@ -41,7 +41,7 @@ compile(AppInfo, State) -> 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), + ok = ensure_dir(TargetNifDir), rebar_api:debug("reading proto files from ~p, generating \".erl\" to ~p " "and \".hrl\" to ~p", [SourceDirs, TargetErlDir, TargetHrlDir]), From e940f7d7fad07e583ac32eb38f92c53dc9874496 Mon Sep 17 00:00:00 2001 From: Pablo Lopez Date: Mon, 6 Mar 2023 15:51:48 +0100 Subject: [PATCH 3/3] [support-o_nif_cc] typo fix --- src/rebar3_gpb_compiler.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rebar3_gpb_compiler.erl b/src/rebar3_gpb_compiler.erl index 121dfce..148ca53 100644 --- a/src/rebar3_gpb_compiler.erl +++ b/src/rebar3_gpb_compiler.erl @@ -6,7 +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"). +-define(DEFAULT_OUT_NIF_DIR, "priv"). %% =================================================================== %% Public API