diff options
author | Tim Watson <watson.timothy@gmail.com> | 2011-09-17 00:26:24 +0100 |
---|---|---|
committer | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2011-11-30 19:39:23 +0100 |
commit | 0e3e94c253d2aa458738610e488e15872f954ad5 (patch) | |
tree | 8ac10851e37e6cc3022ec6ef7fcfa0e99b26260c /src | |
parent | d228e94137c322291d6a8694d51b003254f2fff0 (diff) |
Add support for first_files to port compiler
This patch adds support for first_files to the port_compiler, via the
new `port_first_files` rebar config element.
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_port_compiler.erl | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl index f6e6a53..1b46112 100644 --- a/src/rebar_port_compiler.erl +++ b/src/rebar_port_compiler.erl @@ -88,18 +88,37 @@ %% compile(Config, AppFile) -> + %% Allow the user to specify that dependent files get built first + FirstFiles = expand_sources(rebar_config:get(Config, + port_first_files, []), []), + %% Compose list of sources from config file -- defaults to c_src/*.c Sources = expand_sources(rebar_config:get_list(Config, port_sources, ["c_src/*.c"]), []), + Env = setup_env(Config), + + {FirstNewBins, FirstExistingBins} = case FirstFiles of + [] -> + {[], []}; + _ -> + compile_each(FirstFiles, Config, + Env, [], []) + end, case Sources of [] -> ok; _ -> - Env = setup_env(Config), + + %% Remove first files from found files + RestFiles = [Source || Source <- Sources, + not lists:member(Source, FirstFiles)], %% Compile each of the sources - {NewBins, ExistingBins} = compile_each(Sources, Config, Env, - [], []), + {NewBins, ExistingBins} = compile_each(RestFiles, Config, Env, + [], []), + + NewBins = FirstNewBins ++ NewBins, + ExistingBins = FirstExistingBins ++ ExistingBins, %% Construct the driver name and make sure priv/ exists SoSpecs = so_specs(Config, AppFile, NewBins ++ ExistingBins), |