summaryrefslogtreecommitdiff
path: root/src/rebar_port_compiler.erl
diff options
context:
space:
mode:
authorTuncer Ayaz <tuncer.ayaz@gmail.com>2012-04-22 21:53:32 +0200
committerTuncer Ayaz <tuncer.ayaz@gmail.com>2012-07-13 15:21:56 +0200
commite185e86bff17fa7d093f8b24fcc45069ffde55ae (patch)
tree08cbdc29922bc67d691f21be9d76d7a5c8d4c668 /src/rebar_port_compiler.erl
parent1948eb4a47c1aa61aebbd046aa951f103a1f8644 (diff)
Remove shared state
Diffstat (limited to 'src/rebar_port_compiler.erl')
-rw-r--r--src/rebar_port_compiler.erl37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl
index 0ccabc8..8f38cd2 100644
--- a/src/rebar_port_compiler.erl
+++ b/src/rebar_port_compiler.erl
@@ -96,14 +96,14 @@
objects = [] :: [file:filename(), ...] | [],
opts = [] ::list() | []}).
-compile(Config, AppFile) ->
- rebar_utils:deprecated(port_sources, port_specs, Config, "soon"),
- rebar_utils:deprecated(so_name, port_specs, Config, "soon"),
- rebar_utils:deprecated(so_specs, port_specs, Config, "soon"),
+compile(Config0, AppFile) ->
+ rebar_utils:deprecated(port_sources, port_specs, Config0, "soon"),
+ rebar_utils:deprecated(so_name, port_specs, Config0, "soon"),
+ rebar_utils:deprecated(so_specs, port_specs, Config0, "soon"),
%% TODO: remove SpecType and OldSources make get_specs/2
%% return list(#spec{}) when removing deprecated options
- {SpecType, {OldSources, Specs}} = get_specs(Config, AppFile),
+ {Config, {SpecType, {OldSources, Specs}}} = get_specs(Config0, AppFile),
case {SpecType, OldSources, Specs} of
{old, [], _} ->
@@ -149,7 +149,7 @@ compile(Config, AppFile) ->
clean(Config, AppFile) ->
%% TODO: remove SpecType and OldSources make get_specs/2
%% return list(#spec{}) when removing deprecated options
- {SpecType, {OldSources, Specs}} = get_specs(Config, AppFile),
+ {Config1, {SpecType, {OldSources, Specs}}} = get_specs(Config, AppFile),
case {SpecType, OldSources, Specs} of
{old, [], _} ->
@@ -163,7 +163,8 @@ clean(Config, AppFile) ->
rebar_file_utils:delete_each([Target]),
rebar_file_utils:delete_each(Objects)
end, Specs)
- end.
+ end,
+ {ok, Config1}.
setup_env(Config) ->
setup_env(Config, []).
@@ -264,9 +265,10 @@ get_specs(Config, AppFile) ->
case rebar_config:get_local(Config, port_specs, undefined) of
undefined ->
%% TODO: DEPRECATED: remove support for non-port_specs syntax
- {old, old_get_specs(Config, AppFile)};
+ {Config1, Specs} = old_get_specs(Config, AppFile),
+ {Config1, {old, Specs}};
PortSpecs ->
- {new, get_port_specs(Config, PortSpecs)}
+ {Config, {new, get_port_specs(Config, PortSpecs)}}
end.
get_port_specs(Config, PortSpecs) ->
@@ -327,31 +329,32 @@ switch_to_dll_or_exe(Target) ->
old_get_specs(Config, AppFile) ->
OsType = os:type(),
SourceFiles = old_get_sources(Config),
- Specs =
+ {NewConfig, Specs} =
case rebar_config:get_local(Config, so_specs, undefined) of
undefined ->
Objects = port_objects(SourceFiles),
%% New form of so_specs is not provided. See if the old form
%% of {so_name} is available instead
Dir = "priv",
- SoName =
+ {Config2, SoName} =
case rebar_config:get_local(Config, so_name, undefined) of
undefined ->
%% Ok, neither old nor new form is
%% available. Use the app name and
%% generate a sensible default.
- AppName = rebar_app_utils:app_name(AppFile),
+ {Config1, AppName} =
+ rebar_app_utils:app_name(Config, AppFile),
DrvName = ?FMT("~s_drv.so", [AppName]),
- filename:join([Dir, DrvName]);
+ {Config1, filename:join([Dir, DrvName])};
AName ->
%% Old form is available -- use it
- filename:join(Dir, AName)
+ {Config, filename:join(Dir, AName)}
end,
- [old_get_so_spec({SoName, Objects}, OsType)];
+ {Config2, [old_get_so_spec({SoName, Objects}, OsType)]};
SoSpecs ->
- [old_get_so_spec(S, OsType) || S <- SoSpecs]
+ {Config, [old_get_so_spec(S, OsType) || S <- SoSpecs]}
end,
- {SourceFiles, Specs}.
+ {NewConfig, {SourceFiles, Specs}}.
old_get_sources(Config) ->
RawSources = rebar_config:get_local(Config, port_sources,