瀏覽代碼

ft: 模块重命名 防止模块重名

master
SisMaker 4 年之前
父節點
當前提交
9a8aa5cf99
共有 8 個檔案被更改,包括 82 行新增82 行删除
  1. +7
    -7
      bootstrap
  2. 二進制
      eNpc
  3. +5
    -5
      include/rebar.hrl
  4. +2
    -2
      src/eNpc.erl
  5. +29
    -29
      src/npRCompiler.erl
  6. +5
    -5
      src/npRConfig.erl
  7. +25
    -25
      src/npRMain.erl
  8. +9
    -9
      src/npRUtils.erl

+ 7
- 7
bootstrap 查看文件

@ -24,8 +24,8 @@ main(Args) ->
true -> true ->
rm("ebin/*.beam"); rm("ebin/*.beam");
false -> false ->
case filelib:is_file("ebin/rebar.beam") of
true -> rm("ebin/rebar.beam");
case filelib:is_file("ebin/npRMain.beam") of
true -> rm("ebin/npRMain.beam");
false -> io:fwrite("No beam files found.~n") false -> io:fwrite("No beam files found.~n")
end end
end, end,
@ -44,7 +44,7 @@ main(Args) ->
%% At the same time, their counterparts dict() and digraph() are to be %% At the same time, their counterparts dict() and digraph() are to be
%% deprecated in Erlang 18. namespaced_types option is used to select %% deprecated in Erlang 18. namespaced_types option is used to select
%% proper type name depending on the OTP version used. %% proper type name depending on the OTP version used.
%% Extract the system info of the version of OTP we use to compile rebar
%% Extract the system info of the version of OTP we use to compile npRMain
%% NamespacedTypes = %% NamespacedTypes =
%% case is_otp(OtpInfo, "^[0-9]+") of %% case is_otp(OtpInfo, "^[0-9]+") of
%% true -> {d, namespaced_types}; %% true -> {d, namespaced_types};
@ -53,7 +53,7 @@ main(Args) ->
%% Compile all src/*.erl to ebin %% Compile all src/*.erl to ebin
%% To not accidentally try to compile files like Mac OS X resource forks, %% To not accidentally try to compile files like Mac OS X resource forks,
%% we only look for rebar source files that start with a letter.
%% we only look for npRMain source files that start with a letter.
Opts = [ Opts = [
DebugFlag, DebugFlag,
{outdir, "ebin"}, {outdir, "ebin"},
@ -82,10 +82,10 @@ main(Args) ->
%% Add ebin/ to our path %% Add ebin/ to our path
true = code:add_path("ebin"), true = code:add_path("ebin"),
%% Run rebar compile to do proper .app validation etc.
%% and rebar escriptize to create the rebar script
%% Run npRMain compile to do proper .app validation etc.
%% and npRMain escriptize to create the npRMain script
%% RebarArgs = Args -- ["debug"], %% Avoid trying to run 'debug' command %% RebarArgs = Args -- ["debug"], %% Avoid trying to run 'debug' command
% rebar:main(["compile"] ++ RebarArgs),
% npRMain:main(["compile"] ++ RebarArgs),
escriptize(), escriptize(),

二進制
eNpc 查看文件


+ 5
- 5
include/rebar.hrl 查看文件

@ -1,9 +1,9 @@
-define(FAIL, rebarUtils:abort()).
-define(ABORT(Str, Args), rebarUtils:abort(Str, Args)).
-define(FAIL, npRUtils:abort()).
-define(ABORT(Str, Args), npRUtils:abort(Str, Args)).
-define(INFO(Str, Args), rebar:log(info, Str, Args)).
-define(WARN(Str, Args), rebar:log(warn, Str, Args)).
-define(ERROR(Str, Args), rebar:log(error, Str, Args)).
-define(INFO(Str, Args), npRMain:log(info, Str, Args)).
-define(WARN(Str, Args), npRMain:log(warn, Str, Args)).
-define(ERROR(Str, Args), npRMain:log(error, Str, Args)).
-define(CONSOLE(Str, Args), io:format(Str, Args)). -define(CONSOLE(Str, Args), io:format(Str, Args)).
-define(FMT(Str, Args), lists:flatten(io_lib:format(Str, Args))). -define(FMT(Str, Args), lists:flatten(io_lib:format(Str, Args))).

+ 2
- 2
src/eNpc.erl 查看文件

@ -15,7 +15,7 @@ main(Args) ->
{ok, CurDir} = file:get_cwd(), {ok, CurDir} = file:get_cwd(),
io:format("eNpc cur ~p: ~-18.s, cur pwd:~p ~n", [Args, File, CurDir]), io:format("eNpc cur ~p: ~-18.s, cur pwd:~p ~n", [Args, File, CurDir]),
file:set_cwd(File), file:set_cwd(File),
rebar:main(Args),
npRMain:main(Args),
file:set_cwd(".."); file:set_cwd("..");
_ -> _ ->
ignore ignore
@ -25,7 +25,7 @@ main(Args) ->
{ok, Files} -> {ok, Files} ->
lists:foreach(FunCom, Files); lists:foreach(FunCom, Files);
_Err -> _Err ->
rebar:log(error, "eNpc start compile error ~p ~n", [_Err])
npRMain:log(error, "eNpc start compile error ~p ~n", [_Err])
end. end.

src/rebarNpCompiler.erl → src/npRCompiler.erl 查看文件

@ -1,4 +1,4 @@
-module(rebarNpCompiler).
-module(npRCompiler).
-include("rebar.hrl"). -include("rebar.hrl").
@ -28,7 +28,7 @@ compile(Config, AppFile) ->
[] -> [] ->
ok; ok;
Specs -> Specs ->
SharedEnv = rebarConfig:getEnv(Config, ?MODULE),
SharedEnv = npRConfig:getEnv(Config, ?MODULE),
%% Compile each of the sources %% Compile each of the sources
NewBins = compileSources(Config, Specs, SharedEnv), NewBins = compileSources(Config, Specs, SharedEnv),
@ -52,7 +52,7 @@ compile(Config, AppFile) ->
LinkTemplate = selectLinkTemplate(LinkLang, Target), LinkTemplate = selectLinkTemplate(LinkLang, Target),
Env = proplists:get_value(env, Opts, SharedEnv), Env = proplists:get_value(env, Opts, SharedEnv),
Cmd = expandCommand(LinkTemplate, Env, string:join(Bins, " "), Target), Cmd = expandCommand(LinkTemplate, Env, string:join(Bins, " "), Target),
rebarUtils:sh(Cmd, [{env, Env}]);
npRUtils:sh(Cmd, [{env, Env}]);
false -> false ->
?INFO("Skipping relink of ~s\n", [Target]), ?INFO("Skipping relink of ~s\n", [Target]),
ok ok
@ -67,9 +67,9 @@ clean(Config, AppFile) ->
Specs -> Specs ->
lists:foreach( lists:foreach(
fun(#spec{target = Target, objects = Objects}) -> fun(#spec{target = Target, objects = Objects}) ->
rebarUtils:deleteEach([Target]),
rebarUtils:deleteEach(Objects),
rebarUtils:deleteEach(portDeps(Objects))
npRUtils:deleteEach([Target]),
npRUtils:deleteEach(Objects),
npRUtils:deleteEach(portDeps(Objects))
end, Specs) end, Specs)
end, end,
ok. ok.
@ -156,8 +156,8 @@ infoHelp(Description) ->
%% set REBAR_DEPS_DIR and ERL_LIBS environment variables %% set REBAR_DEPS_DIR and ERL_LIBS environment variables
defaultEnv(Config) -> defaultEnv(Config) ->
BaseDir = rebarUtils:baseDir(Config),
DepsDir0 = rebarConfig:getXconf(Config, deps_dir, "deps"),
BaseDir = npRUtils:baseDir(Config),
DepsDir0 = npRConfig:getXconf(Config, deps_dir, "deps"),
DepsDir = filename:dirname(filename:join([BaseDir, DepsDir0, "dummy"])), DepsDir = filename:dirname(filename:join([BaseDir, DepsDir0, "dummy"])),
%% include rebar's DepsDir in ERL_LIBS %% include rebar's DepsDir in ERL_LIBS
@ -185,10 +185,10 @@ setupEnv(Config, ExtraEnv) ->
%% Get any port-specific envs; use port_env first and then fallback %% Get any port-specific envs; use port_env first and then fallback
%% to port_envs for compatibility %% to port_envs for compatibility
RawPortEnv = rebarConfig:getList(
RawPortEnv = npRConfig:getList(
Config, Config,
port_env, port_env,
rebarConfig:getList(Config, port_envs, [])),
npRConfig:getList(Config, port_envs, [])),
PortEnv = filterEnv(RawPortEnv, []), PortEnv = filterEnv(RawPortEnv, []),
Defines = getDefines(Config), Defines = getDefines(Config),
@ -197,7 +197,7 @@ setupEnv(Config, ExtraEnv) ->
expandVarsLoop(mergeEachVar(RawEnv, [])). expandVarsLoop(mergeEachVar(RawEnv, [])).
getDefines(Config) -> getDefines(Config) ->
RawDefines = rebarConfig:getXconf(Config, defines, []),
RawDefines = npRConfig:getXconf(Config, defines, []),
Defines = string:join(["-D" ++ D || D <- RawDefines], " "), Defines = string:join(["-D" ++ D || D <- RawDefines], " "),
[{"ERL_CFLAGS", "$ERL_CFLAGS " ++ Defines}]. [{"ERL_CFLAGS", "$ERL_CFLAGS " ++ Defines}].
@ -264,7 +264,7 @@ cdbEntry(Src, Cmd, SrcRest) ->
string:tokens(Cmd, " ")), string:tokens(Cmd, " ")),
" "), " "),
Cwd = rebarUtils:getCwd(),
Cwd = npRUtils:getCwd(),
%% If there are more source files, make sure we end the CDB entry %% If there are more source files, make sure we end the CDB entry
%% with a comma. %% with a comma.
Sep = case SrcRest of Sep = case SrcRest of
@ -279,10 +279,10 @@ cdbEntry(Src, Cmd, SrcRest) ->
[Src, Cwd, CDBCmd, Sep]). [Src, Cwd, CDBCmd, Sep]).
execCompiler(Config, Source, Cmd, ShOpts) -> execCompiler(Config, Source, Cmd, ShOpts) ->
case rebarUtils:sh(Cmd, ShOpts) of
case npRUtils:sh(Cmd, ShOpts) of
{error, {_RC, RawError}} -> {error, {_RC, RawError}} ->
AbsSource = AbsSource =
case rebarUtils:processingBaseDir(Config) of
case npRUtils:processingBaseDir(Config) of
true -> true ->
Source; Source;
false -> false ->
@ -337,7 +337,7 @@ needsLink(SoName, NewBins) ->
getSpecs(Config, AppFile) -> getSpecs(Config, AppFile) ->
Specs = Specs =
case rebarConfig:getLocal(Config, port_specs, []) of
case npRConfig:getLocal(Config, port_specs, []) of
[] -> [] ->
%% No spec provided. Construct a spec %% No spec provided. Construct a spec
%% from old-school so_name and sources %% from old-school so_name and sources
@ -352,17 +352,17 @@ getSpecs(Config, AppFile) ->
portSpecFromLegacy(Config, AppFile) -> portSpecFromLegacy(Config, AppFile) ->
%% Get the target from the so_name variable %% Get the target from the so_name variable
Target = Target =
case rebarConfig:get(Config, so_name, undefined) of
case npRConfig:get(Config, so_name, undefined) of
undefined -> undefined ->
%% Generate a sensible default from app file %% Generate a sensible default from app file
{_, AppName} = rebarUtils:appName(Config, AppFile),
{_, AppName} = npRUtils:appName(Config, AppFile),
filename:join("priv", lists:concat([AppName, "_drv.so"])); filename:join("priv", lists:concat([AppName, "_drv.so"]));
AName -> AName ->
%% Old form is available -- use it %% Old form is available -- use it
filename:join("priv", AName) filename:join("priv", AName)
end, end,
%% Get the list of source files from port_sources %% Get the list of source files from port_sources
Sources = portSources(rebarConfig:getList(Config, port_sources, ["c_src/*.c"])),
Sources = portSources(npRConfig:getList(Config, port_sources, ["c_src/*.c"])),
#spec{ #spec{
type = targetType(Target), type = targetType(Target),
link_lang = cc, link_lang = cc,
@ -375,9 +375,9 @@ filterPortSpecs(Specs) ->
[S || S <- Specs, filterPortSpec(S)]. [S || S <- Specs, filterPortSpec(S)].
filterPortSpec({ArchRegex, _, _, _}) -> filterPortSpec({ArchRegex, _, _, _}) ->
rebarUtils:isArch(ArchRegex);
npRUtils:isArch(ArchRegex);
filterPortSpec({ArchRegex, _, _}) -> filterPortSpec({ArchRegex, _, _}) ->
rebarUtils:isArch(ArchRegex);
npRUtils:isArch(ArchRegex);
filterPortSpec({_, _}) -> filterPortSpec({_, _}) ->
true. true.
@ -459,7 +459,7 @@ applyDefaults(Vars, Defaults) ->
fun(Key, VarValue, DefaultValue) -> fun(Key, VarValue, DefaultValue) ->
case isExpandable(DefaultValue) of case isExpandable(DefaultValue) of
true -> true ->
rebarUtils:expandEnvVariable(DefaultValue,
npRUtils:expandEnvVariable(DefaultValue,
Key, Key,
VarValue); VarValue);
false -> VarValue false -> VarValue
@ -481,10 +481,10 @@ mergeEachVar([{Key, Value} | Rest], Vars) ->
error -> error ->
%% Nothing yet defined for this key/value. %% Nothing yet defined for this key/value.
%% Expand any self-references as blank. %% Expand any self-references as blank.
rebarUtils:expandEnvVariable(Value, Key, "");
npRUtils:expandEnvVariable(Value, Key, "");
{ok, Value0} -> {ok, Value0} ->
%% Use previous definition in expansion %% Use previous definition in expansion
rebarUtils:expandEnvVariable(Value, Key, Value0)
npRUtils:expandEnvVariable(Value, Key, Value0)
end, end,
mergeEachVar(Rest, orddict:store(Key, Evalue, Vars)). mergeEachVar(Rest, orddict:store(Key, Evalue, Vars)).
@ -537,7 +537,7 @@ expandKeysInValue([Key | Rest], Value, Vars) ->
NewValue = NewValue =
case dict:find(Key, Vars) of case dict:find(Key, Vars) of
{ok, KValue} -> {ok, KValue} ->
rebarUtils:expandEnvVariable(Value, Key, KValue);
npRUtils:expandEnvVariable(Value, Key, KValue);
error -> error ->
Value Value
end, end,
@ -545,8 +545,8 @@ expandKeysInValue([Key | Rest], Value, Vars) ->
expandCommand(TmplName, Env, InFiles, OutFile) -> expandCommand(TmplName, Env, InFiles, OutFile) ->
Cmd0 = proplists:get_value(TmplName, Env), Cmd0 = proplists:get_value(TmplName, Env),
Cmd1 = rebarUtils:expandEnvVariable(Cmd0, "PORT_IN_FILES", InFiles),
rebarUtils:expandEnvVariable(Cmd1, "PORT_OUT_FILE", OutFile).
Cmd1 = npRUtils:expandEnvVariable(Cmd0, "PORT_IN_FILES", InFiles),
npRUtils:expandEnvVariable(Cmd1, "PORT_OUT_FILE", OutFile).
%% %%
%% Given a string, determine if it is expandable %% Given a string, determine if it is expandable
@ -564,7 +564,7 @@ isExpandable(InStr) ->
filterEnv([], Acc) -> filterEnv([], Acc) ->
lists:reverse(Acc); lists:reverse(Acc);
filterEnv([{ArchRegex, Key, Value} | Rest], Acc) -> filterEnv([{ArchRegex, Key, Value} | Rest], Acc) ->
case rebarUtils:isArch(ArchRegex) of
case npRUtils:isArch(ArchRegex) of
true -> true ->
filterEnv(Rest, [{Key, Value} | Acc]); filterEnv(Rest, [{Key, Value} | Acc]);
false -> false ->
@ -671,8 +671,8 @@ defaultEnv() ->
])}, ])},
{"ERL_EI_LIBDIR", lists:concat(["\"", erlInterfaceDir(lib), "\""])}, {"ERL_EI_LIBDIR", lists:concat(["\"", erlInterfaceDir(lib), "\""])},
{"ERL_LDFLAGS", " -L$ERL_EI_LIBDIR -lei"}, {"ERL_LDFLAGS", " -L$ERL_EI_LIBDIR -lei"},
{"ERLANG_ARCH", rebarUtils:wordsize()},
{"ERLANG_TARGET", rebarUtils:getArch()},
{"ERLANG_ARCH", npRUtils:wordsize()},
{"ERLANG_TARGET", npRUtils:getArch()},
{"darwin", "DRV_LDFLAGS", {"darwin", "DRV_LDFLAGS",
"-bundle -flat_namespace -undefined suppress $ERL_LDFLAGS"}, "-bundle -flat_namespace -undefined suppress $ERL_LDFLAGS"},

src/rebarConfig.erl → src/npRConfig.erl 查看文件

@ -1,4 +1,4 @@
-module(rebarConfig).
-module(npRConfig).
-include("rebar.hrl"). -include("rebar.hrl").
@ -39,18 +39,18 @@
-spec baseConfig(config()) -> config(). -spec baseConfig(config()) -> config().
baseConfig(GlobalConfig) -> baseConfig(GlobalConfig) ->
ConfName = rebarConfig:getGlobal(GlobalConfig, config, ?DEFAULT_NAME),
ConfName = npRConfig:getGlobal(GlobalConfig, config, ?DEFAULT_NAME),
new(GlobalConfig, ConfName). new(GlobalConfig, ConfName).
-spec new() -> config(). -spec new() -> config().
new() -> new() ->
#config{dir = rebarUtils:getCwd()}.
#config{dir = npRUtils:getCwd()}.
-spec new(file:filename() | config()) -> config(). -spec new(file:filename() | config()) -> config().
new(ConfigFile) when is_list(ConfigFile) -> new(ConfigFile) when is_list(ConfigFile) ->
case consultFile(ConfigFile) of case consultFile(ConfigFile) of
{ok, Opts} -> {ok, Opts} ->
#config{dir = rebarUtils:getCwd(),
#config{dir = npRUtils:getCwd(),
opts = Opts}; opts = Opts};
Other -> Other ->
?ABORT("Failed to load ~s: ~p~n", [ConfigFile, Other]) ?ABORT("Failed to load ~s: ~p~n", [ConfigFile, Other])
@ -140,7 +140,7 @@ getXconf(Config, Key, Default) ->
-spec new(config(), file:filename()) -> config(). -spec new(config(), file:filename()) -> config().
new(ParentConfig, ConfName) -> new(ParentConfig, ConfName) ->
%% Load terms from rebar.config, if it exists %% Load terms from rebar.config, if it exists
Dir = rebarUtils:getCwd(),
Dir = npRUtils:getCwd(),
ConfigFile = filename:join([Dir, ConfName]), ConfigFile = filename:join([Dir, ConfName]),
Opts0 = ParentConfig#config.opts, Opts0 = ParentConfig#config.opts,
Opts = case consultFile(ConfigFile) of Opts = case consultFile(ConfigFile) of

src/rebar.erl → src/npRMain.erl 查看文件

@ -1,4 +1,4 @@
-module(rebar).
-module(npRMain).
-export([ -export([
main/1, main/1,
@ -26,12 +26,12 @@ main(Args) ->
ok -> ok ->
ok; ok;
rebar_abort -> rebar_abort ->
rebarUtils:delayedHalt(1);
npRUtils:delayedHalt(1);
Error -> Error ->
%% Nothing should percolate up from rebar_core; %% Nothing should percolate up from rebar_core;
%% Dump this error to console %% Dump this error to console
io:format("Uncaught error in rebar_core: ~p\n", [Error]), io:format("Uncaught error in rebar_core: ~p\n", [Error]),
rebarUtils:delayedHalt(1)
npRUtils:delayedHalt(1)
end. end.
log(Level, Format, Args) -> log(Level, Format, Args) ->
@ -74,13 +74,13 @@ loadRebarApp() ->
{error, {already_loaded,eNpc}} -> {error, {already_loaded,eNpc}} ->
ok; ok;
_ -> _ ->
rebarUtils:delayedHalt(1)
npRUtils:delayedHalt(1)
end. end.
help(compile) -> help(compile) ->
rebarNpCompiler:info(help, compile);
npRCompiler:info(help, compile);
help(clean) -> help(clean) ->
rebarNpCompiler:info(help, clean);
npRCompiler:info(help, clean);
help(Command) -> help(Command) ->
?CONSOLE("eNpc no help available for \"~p\"~n", [Command]). ?CONSOLE("eNpc no help available for \"~p\"~n", [Command]).
@ -89,17 +89,17 @@ parseArgs([]) ->
parseArgs(["-h" | _]) -> parseArgs(["-h" | _]) ->
usage(), usage(),
help(compile), help(compile),
rebarUtils:delayedHalt(0);
npRUtils:delayedHalt(0);
parseArgs(["--help" | _]) -> parseArgs(["--help" | _]) ->
usage(), usage(),
help(compile), help(compile),
rebarUtils:delayedHalt(0);
npRUtils:delayedHalt(0);
parseArgs(["-v" | _]) -> parseArgs(["-v" | _]) ->
version(), version(),
rebarUtils:delayedHalt(0);
npRUtils:delayedHalt(0);
parseArgs(["--version" | _]) -> parseArgs(["--version" | _]) ->
version(), version(),
rebarUtils:delayedHalt(0);
npRUtils:delayedHalt(0);
parseArgs(["-c", FileName | Rest]) -> parseArgs(["-c", FileName | Rest]) ->
{Opts, NonOpts} = parseArgs(Rest), {Opts, NonOpts} = parseArgs(Rest),
{[{config, FileName} | Opts], NonOpts}; {[{config, FileName} | Opts], NonOpts};
@ -118,9 +118,9 @@ initConfig({Options, _NonOptArgs}) ->
GlobalConfig = GlobalConfig =
case filelib:is_regular(GlobalConfigFile) of case filelib:is_regular(GlobalConfigFile) of
true -> true ->
rebarConfig:new(GlobalConfigFile);
npRConfig:new(GlobalConfigFile);
false -> false ->
rebarConfig:new()
npRConfig:new()
end, end,
%% Set the rebar config to use %% Set the rebar config to use
@ -129,24 +129,24 @@ initConfig({Options, _NonOptArgs}) ->
undefined -> undefined ->
GlobalConfig; GlobalConfig;
Conf -> Conf ->
rebarConfig:setGlobal(GlobalConfig, config, Conf)
npRConfig:setGlobal(GlobalConfig, config, Conf)
end, end,
BaseConfig = rebarConfig:baseConfig(GlobalConfig1),
BaseConfig = npRConfig:baseConfig(GlobalConfig1),
%% Keep track of how many operations we do, so we can detect bad commands %% Keep track of how many operations we do, so we can detect bad commands
BaseConfig1 = rebarConfig:setXconf(BaseConfig, operations, 0),
BaseConfig1 = npRConfig:setXconf(BaseConfig, operations, 0),
%% Initialize vsn cache %% Initialize vsn cache
rebarUtils:initVsnCache(BaseConfig1).
npRUtils:initVsnCache(BaseConfig1).
initConfig_1(BaseConfig) -> initConfig_1(BaseConfig) ->
%% Determine the location of the rebar executable; important for pulling %% Determine the location of the rebar executable; important for pulling
%% resources out of the escript %% resources out of the escript
ScriptName = filename:absname(escript:script_name()), ScriptName = filename:absname(escript:script_name()),
BaseConfig1 = rebarConfig:setXconf(BaseConfig, escript, ScriptName),
BaseConfig1 = npRConfig:setXconf(BaseConfig, escript, ScriptName),
%% Note the top-level directory for reference %% Note the top-level directory for reference
AbsCwd = filename:absname(rebarUtils:getCwd()),
rebarConfig:setXconf(BaseConfig1, base_dir, AbsCwd).
AbsCwd = filename:absname(npRUtils:getCwd()),
npRConfig:setXconf(BaseConfig1, base_dir, AbsCwd).
runAux(BaseConfig, Commands) -> runAux(BaseConfig, Commands) ->
%% Make sure crypto is running %% Make sure crypto is running
@ -182,22 +182,22 @@ setupEnvs(Config, Modules) ->
lists:foldl( lists:foldl(
fun(Module, CfgAcc) -> fun(Module, CfgAcc) ->
Env = Module:setupEnv(CfgAcc), Env = Module:setupEnv(CfgAcc),
rebarConfig:saveEnv(CfgAcc, Module, Env)
npRConfig:saveEnv(CfgAcc, Module, Env)
end, Config, Modules). end, Config, Modules).
processCommand(compile, Config, AppFile) -> processCommand(compile, Config, AppFile) ->
rebarNpCompiler:compile(Config, AppFile);
npRCompiler:compile(Config, AppFile);
processCommand(clean, Config, AppFile) -> processCommand(clean, Config, AppFile) ->
rebarNpCompiler:clean(Config, AppFile);
npRCompiler:clean(Config, AppFile);
processCommand(Other, _, _) -> processCommand(Other, _, _) ->
?CONSOLE("Unknown command: ~s~n", [Other]), ?CONSOLE("Unknown command: ~s~n", [Other]),
rebarUtils:delayedHalt(1).
npRUtils:delayedHalt(1).
saveOptions(Config, {Options, NonOptArgs}) -> saveOptions(Config, {Options, NonOptArgs}) ->
GlobalDefines = proplists:get_all_values(defines, Options), GlobalDefines = proplists:get_all_values(defines, Options),
Config1 = rebarConfig:setXconf(Config, defines, GlobalDefines),
Config1 = npRConfig:setXconf(Config, defines, GlobalDefines),
filterFlags(Config1, NonOptArgs, []). filterFlags(Config1, NonOptArgs, []).
%% show version information and halt %% show version information and halt
@ -222,7 +222,7 @@ filterFlags(Config, [Item | Rest], Commands) ->
_ -> _ ->
RawValue RawValue
end, end,
Config1 = rebarConfig:setGlobal(Config, Key, Value),
Config1 = npRConfig:setGlobal(Config, Key, Value),
filterFlags(Config1, Rest, Commands); filterFlags(Config1, Rest, Commands);
Other -> Other ->
?CONSOLE("Ignoring command line argument: ~p\n", [Other]), ?CONSOLE("Ignoring command line argument: ~p\n", [Other]),

src/rebarUtils.erl → src/npRUtils.erl 查看文件

@ -1,4 +1,4 @@
-module(rebarUtils).
-module(npRUtils).
-include("rebar.hrl"). -include("rebar.hrl").
@ -49,7 +49,7 @@ get_system_arch(Arch) ->
Arch. Arch.
isAppDir() -> isAppDir() ->
isAppDir(rebarUtils:getCwd()).
isAppDir(npRUtils:getCwd()).
isAppDir(Dir) -> isAppDir(Dir) ->
SrcDir = filename:join([Dir, "src"]), SrcDir = filename:join([Dir, "src"]),
@ -91,11 +91,11 @@ appName(Config, AppFile) ->
loadAppFile(Config, Filename) -> loadAppFile(Config, Filename) ->
AppFile = {app_file, Filename}, AppFile = {app_file, Filename},
case rebarConfig:getXconf(Config, {appfile, AppFile}, undefined) of
case npRConfig:getXconf(Config, {appfile, AppFile}, undefined) of
undefined -> undefined ->
case consultAppFile(Filename) of case consultAppFile(Filename) of
{ok, {application, AppName, AppData}} -> {ok, {application, AppName, AppData}} ->
Config1 = rebarConfig:setXconf(Config,
Config1 = npRConfig:setXconf(Config,
{appfile, AppFile}, {appfile, AppFile},
{AppName, AppData}), {AppName, AppData}),
{ok, Config1, AppName, AppData}; {ok, Config1, AppName, AppData};
@ -114,7 +114,7 @@ consultAppFile(Filename) ->
true -> true ->
file:consult(Filename); file:consult(Filename);
false -> false ->
rebarConfig:consultFile(Filename)
npRConfig:consultFile(Filename)
end, end,
case Result of case Result of
{ok, [Term]} -> {ok, [Term]} ->
@ -188,11 +188,11 @@ initVsnCache(Config) ->
initVsnCache(Config, os:getenv("REBAR_VSN_CACHE_FILE")). initVsnCache(Config, os:getenv("REBAR_VSN_CACHE_FILE")).
initVsnCache(Config, false) -> initVsnCache(Config, false) ->
rebarConfig:setXconf(Config, vsn_cache, dict:new());
npRConfig:setXconf(Config, vsn_cache, dict:new());
initVsnCache(Config, CacheFile) -> initVsnCache(Config, CacheFile) ->
{ok, CacheList} = file:consult(CacheFile), {ok, CacheList} = file:consult(CacheFile),
CacheDict = dict:from_list(CacheList), CacheDict = dict:from_list(CacheList),
rebarConfig:setXconf(Config, vsn_cache, CacheDict).
npRConfig:setXconf(Config, vsn_cache, CacheDict).
-spec delayedHalt(integer()) -> no_return(). -spec delayedHalt(integer()) -> no_return().
delayedHalt(Code) -> delayedHalt(Code) ->
@ -229,10 +229,10 @@ deleteEach([File | Rest]) ->
end. end.
baseDir(Config) -> baseDir(Config) ->
rebarConfig:getXconf(Config, base_dir).
npRConfig:getXconf(Config, base_dir).
processingBaseDir(Config) -> processingBaseDir(Config) ->
Cwd = rebarUtils:getCwd(),
Cwd = npRUtils:getCwd(),
processingBaseDir(Config, Cwd). processingBaseDir(Config, Cwd).
processingBaseDir(Config, Dir) -> processingBaseDir(Config, Dir) ->

Loading…
取消
儲存