mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 03:00:17 +00:00
Merge pull request #15 from rebar/dss-restore-ports
Restore support for so_name, port_envs and port_sources
This commit is contained in:
commit
9d42b72bcc
1 changed files with 41 additions and 10 deletions
|
@ -92,8 +92,8 @@
|
||||||
objects = [] :: [file:filename(), ...],
|
objects = [] :: [file:filename(), ...],
|
||||||
opts = [] ::list() | []}).
|
opts = [] ::list() | []}).
|
||||||
|
|
||||||
compile(Config, _AppFile) ->
|
compile(Config, AppFile) ->
|
||||||
case get_specs(Config) of
|
case get_specs(Config, AppFile) of
|
||||||
[] ->
|
[] ->
|
||||||
ok;
|
ok;
|
||||||
Specs ->
|
Specs ->
|
||||||
|
@ -130,8 +130,8 @@ compile(Config, _AppFile) ->
|
||||||
end, Specs)
|
end, Specs)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
clean(Config, _AppFile) ->
|
clean(Config, AppFile) ->
|
||||||
case get_specs(Config) of
|
case get_specs(Config, AppFile) of
|
||||||
[] ->
|
[] ->
|
||||||
ok;
|
ok;
|
||||||
Specs ->
|
Specs ->
|
||||||
|
@ -154,7 +154,12 @@ setup_env(Config, ExtraEnv) ->
|
||||||
%% merge with the default for this operating system. This enables
|
%% merge with the default for this operating system. This enables
|
||||||
%% max flexibility for users.
|
%% max flexibility for users.
|
||||||
DefaultEnv = filter_env(default_env(), []),
|
DefaultEnv = filter_env(default_env(), []),
|
||||||
RawPortEnv = rebar_config:get_list(Config, port_env, []),
|
|
||||||
|
%% Get any port-specific envs; use port_env first and then fallback
|
||||||
|
%% to port_envs for compatibility
|
||||||
|
RawPortEnv = rebar_config:get_list(Config, port_env,
|
||||||
|
rebar_config:get_list(Config, port_envs, [])),
|
||||||
|
|
||||||
PortEnv = filter_env(RawPortEnv, []),
|
PortEnv = filter_env(RawPortEnv, []),
|
||||||
Defines = get_defines(Config),
|
Defines = get_defines(Config),
|
||||||
OverrideEnv = Defines ++ PortEnv ++ filter_env(ExtraEnv, []),
|
OverrideEnv = Defines ++ PortEnv ++ filter_env(ExtraEnv, []),
|
||||||
|
@ -242,11 +247,37 @@ needs_link(SoName, NewBins) ->
|
||||||
%% == port_specs ==
|
%% == port_specs ==
|
||||||
%%
|
%%
|
||||||
|
|
||||||
get_specs(Config) ->
|
get_specs(Config, AppFile) ->
|
||||||
PortSpecs = rebar_config:get_local(Config, port_specs, []),
|
case rebar_config:get_local(Config, port_specs, []) of
|
||||||
Filtered = filter_port_specs(PortSpecs),
|
[] ->
|
||||||
OsType = os:type(),
|
%% No spec provided. Construct a spec
|
||||||
[get_port_spec(Config, OsType, Spec) || Spec <- Filtered].
|
%% from old-school so_name and sources
|
||||||
|
[port_spec_from_legacy(Config, AppFile)];
|
||||||
|
PortSpecs ->
|
||||||
|
Filtered = filter_port_specs(PortSpecs),
|
||||||
|
OsType = os:type(),
|
||||||
|
[get_port_spec(Config, OsType, Spec) || Spec <- Filtered]
|
||||||
|
end.
|
||||||
|
|
||||||
|
port_spec_from_legacy(Config, AppFile) ->
|
||||||
|
%% Get the target from the so_name variable
|
||||||
|
Target = case rebar_config:get(Config, so_name, undefined) of
|
||||||
|
undefined ->
|
||||||
|
%% Generate a sensible default from app file
|
||||||
|
{_, AppName} = rebar_app_utils:app_name(Config, AppFile),
|
||||||
|
filename:join("priv",
|
||||||
|
lists:concat([AppName, "_drv.so"]));
|
||||||
|
AName ->
|
||||||
|
%% Old form is available -- use it
|
||||||
|
filename:join("priv", AName)
|
||||||
|
end,
|
||||||
|
%% Get the list of source files from port_sources
|
||||||
|
Sources = port_sources(rebar_config:get_list(Config, port_sources,
|
||||||
|
["c_src/*.c"])),
|
||||||
|
#spec { type = target_type(Target),
|
||||||
|
target = maybe_switch_extension(os:type(), Target),
|
||||||
|
sources = Sources,
|
||||||
|
objects = port_objects(Sources) }.
|
||||||
|
|
||||||
filter_port_specs(Specs) ->
|
filter_port_specs(Specs) ->
|
||||||
[S || S <- Specs, filter_port_spec(S)].
|
[S || S <- Specs, filter_port_spec(S)].
|
||||||
|
|
Loading…
Reference in a new issue