summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKevin Smith <kevin@hypotheticalabs.com>2010-01-05 10:39:08 -0500
committerKevin Smith <kevin@hypotheticalabs.com>2010-01-05 10:39:08 -0500
commitbfcb54cbc90712091ed886077e52bba2e43f42eb (patch)
treed519c35dbec719e46673abc74ca5db233cb92e50 /src
parent21f60bff748b7679e107d2afd6d9d3da8e890972 (diff)
Added so_name entry to rebar.config so linked-in drivers can specify custom .so names
Diffstat (limited to 'src')
-rw-r--r--src/rebar_port_compiler.erl31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl
index a602f01..46ce954 100644
--- a/src/rebar_port_compiler.erl
+++ b/src/rebar_port_compiler.erl
@@ -90,7 +90,7 @@ compile(Config, AppFile) ->
{NewBins, ExistingBins} = compile_each(Sources, Config, Env, [], []),
%% Construct the driver name and make sure priv/ exists
- SoName = so_name(AppFile),
+ SoName = so_name(Config, AppFile),
ok = filelib:ensure_dir(SoName),
%% Only relink if necessary, given the SoName and list of new binaries
@@ -110,7 +110,7 @@ clean(Config, AppFile) ->
rebar_file_utils:delete_each([source_to_bin(S) || S <- Sources]),
%% Delete the .so file
- rebar_file_utils:delete_each([so_name(AppFile)]),
+ rebar_file_utils:delete_each([so_name(Config, AppFile)]),
%% Run the cleanup script, if it exists
run_cleanup_hook(Config).
@@ -263,16 +263,21 @@ source_to_bin(Source) ->
Ext = filename:extension(Source),
filename:rootname(Source, Ext) ++ ".o".
-so_name(AppFile) ->
- %% Get the app name, which we'll use to generate the linked port driver name
- case rebar_app_utils:load_app_file(AppFile) of
- {ok, AppName, _} ->
- ok;
- error ->
- AppName = undefined,
- ?FAIL
- end,
+so_name(Config, AppFile) ->
+ %% Check config to see if a custom so_name has been specified
+ PortName = case rebar_config:get(Config, so_name, undefined) of
+ undefined ->
+ %% Get the app name, which we'll use to
+ %% generate the linked port driver name
+ case rebar_app_utils:load_app_file(AppFile) of
+ {ok, AppName, _} ->
+ AppName;
+ error ->
+ ?FAIL
+ end;
+ Soname ->
+ Soname
+ end,
%% Construct the driver name
- ?FMT("priv/~s_drv.so", [AppName]).
-
+ ?FMT("priv/~s_drv.so", [PortName]).