From 513ae33c5c5f67a72d6149ecef6968b634cad846 Mon Sep 17 00:00:00 2001 From: Anders Date: Mon, 25 Oct 2010 13:48:57 +0100 Subject: [PATCH] Add possibility to specify rebar config for the "main" application --- src/rebar_config.erl | 12 +++++++++++- src/rebar_core.erl | 19 +++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/rebar_config.erl b/src/rebar_config.erl index ccabed0..cba0e64 100644 --- a/src/rebar_config.erl +++ b/src/rebar_config.erl @@ -45,9 +45,19 @@ new() -> opts = []}. new(ParentConfig) -> + %% If we are at the top level we might want to load another rebar.config + %% We can be certain that we are at the top level if we don't have any + %% configs yet since if we are at another level we must have some config. + ConfName = case ParentConfig of + {config, _, []} -> + rebar_config:get_global(config, "rebar.config"); + _ -> + "rebar.config" + end, + %% Load terms from rebar.config, if it exists Dir = rebar_utils:get_cwd(), - ConfigFile = filename:join([Dir, "rebar.config"]), + ConfigFile = filename:join([Dir, ConfName]), case file:consult(ConfigFile) of {ok, Terms} -> %% Found a config file with some terms. We need to be able to diff --git a/src/rebar_core.erl b/src/rebar_core.erl index e92f158..3c64f8d 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -133,6 +133,12 @@ parse_args(Args) -> rebar_config:set_global(jobs, Jobs) end, + %% Set the rebar config to use + case proplists:get_value(config, Options) of + undefined -> ok; + Conf -> rebar_config:set_global(config, Conf) + end, + %% Filter all the flags (i.e. strings of form key=value) from the %% command line arguments. What's left will be the commands to run. filter_flags(NonOptArgs, []); @@ -250,12 +256,13 @@ option_spec_list() -> [Jobs]), [ %% {Name, ShortOpt, LongOpt, ArgSpec, HelpMsg} - {help, $h, "help", undefined, "Show the program options"}, - {commands, $c, "commands", undefined, "Show available commands"}, - {verbose, $v, "verbose", undefined, "Be verbose about what gets done"}, - {version, $V, "version", undefined, "Show version information"}, - {force, $f, "force", undefined, "Force"}, - {jobs, $j, "jobs", integer, JobsHelp} + {help, $h, "help", undefined, "Show the program options"}, + {commands, $c, "commands", undefined, "Show available commands"}, + {verbose, $v, "verbose", undefined, "Be verbose about what gets done"}, + {version, $V, "version", undefined, "Show version information"}, + {force, $f, "force", undefined, "Force"}, + {jobs, $j, "jobs", integer, JobsHelp}, + {config, $C, "config", string, "Rebar config file to use"} ]. %%