Browse Source

重命令为 eNpc

master
SisMaker 4 years ago
parent
commit
1780cc26b6
9 changed files with 34 additions and 29 deletions
  1. +1
    -0
      .gitignore
  2. +4
    -4
      README.md
  3. +9
    -9
      bootstrap
  4. BIN
      eNpc
  5. +4
    -0
      eNpc.cmd
  6. +3
    -3
      ebin/eNpc.app
  7. +4
    -4
      src/eNpc.erl
  8. +7
    -7
      src/rebar.erl
  9. +2
    -2
      src/rebarUtils.erl

+ 1
- 0
.gitignore View File

@ -17,4 +17,5 @@ _build/
_checkouts/
.idea
*.iml

+ 4
- 4
README.md View File

@ -7,12 +7,12 @@
default_env
1. Clone this repository
1. Run `make` in this directory
1. Copy `erlNpc` to your project "c_src" dir and commit it
1. Copy `eNpc` to your project "c_src" dir and commit it
1. Add these (or similar) hooks to your rebar.config:
```erlang
{pre_hooks, [{"", compile, "escript c_src/erlNpc compile"}]}.
{post_hooks, [{"", clean, "escript c_src/erlNpc clean"}]}.
{pre_hooks, [{"", compile, "escript c_src/eNpc compile"}]}.
{post_hooks, [{"", clean, "escript c_src/eNpc clean"}]}.
```
After that erlNpc should read your old rebar.config `port\_specs` and `port\_env` settings as expected (it is rebar2's port compiler after all...).
After that eNpc should read your old rebar.config `port_specs` and `port_env` settings as expected (it is rebar2's port compiler after all...).

+ 9
- 9
bootstrap View File

@ -66,16 +66,16 @@ main(Args) ->
up_to_date ->
ok;
error ->
io:format("Failed to compile erlNpc files!\n"),
io:format("Failed to compile eNpc files!\n"),
halt(1)
end,
%% Make sure file:consult can parse the .app file
case file:consult("ebin/erlNpc.app") of
case file:consult("ebin/eNpc.app") of
{ok, _} ->
ok;
{error, Reason} ->
io:format("Invalid syntax in ebin/erlNpc.app: ~p\n", [Reason]),
io:format("Invalid syntax in ebin/eNpc.app: ~p\n", [Reason]),
halt(1)
end,
@ -93,7 +93,7 @@ main(Args) ->
%% or write out script files on win32.
case os:type() of
{unix, _} ->
[] = os:cmd("chmod u+x erlNpc"),
[] = os:cmd("chmod u+x eNpc"),
ok;
{win32, _} ->
writeWindowsScripts(),
@ -104,10 +104,10 @@ main(Args) ->
%% Add a helpful message
io:format(<<"Congratulations! You now have a self-contained script called"
" \"erlNpc\" in\n"
" \"eNpc\" in\n"
"your current working directory. "
"Place this script anywhere in your path\n"
"and you can use erlNpc to build native code for Erlang\n">>).
"and you can use eNpc to build native code for Erlang\n">>).
usage() ->
io:format(<<"Usage: bootstrap [OPTION]...~n">>),
@ -157,12 +157,12 @@ writeWindowsScripts() ->
"setlocal\r\n"
"set rebarscript=%~f0\r\n"
"escript.exe \"%rebarscript:.cmd=%\" %*\r\n",
ok = file:write_file("erlNpc.cmd", CmdScript).
ok = file:write_file("eNpc.cmd", CmdScript).
escriptize() ->
AppName = "erlNpc",
ScriptName = "erlNpc",
AppName = "eNpc",
ScriptName = "eNpc",
Files = loadEScriptFiles(AppName, "ebin", "*"),

BIN
eNpc View File


+ 4
- 0
eNpc.cmd View File

@ -0,0 +1,4 @@
@echo off
setlocal
set rebarscript=%~f0
escript.exe "%rebarscript:.cmd=%" %*

ebin/erlNpc.app → ebin/eNpc.app View File

@ -1,9 +1,9 @@
{application,erlNpc,
[{description,"erlNpc: Erlang Native Compiler"},
{application,eNpc,
[{description,"eNpc: Erlang Native Compiler"},
{vsn,"0.1.0"},
{registered,[]},
{applications,[kernel,stdlib]},
{modules,[erlNpc,rebar,rebarConfig,rebarNpCompiler,rebarUtils]},
{modules,[eNpc,rebar,rebarConfig,rebarNpCompiler,rebarUtils]},
{licenses,["Apache 2.0"]},
{links,[]},
{env,[{log_level,warn}]}]}.

src/erlNpc.erl → src/eNpc.erl View File

@ -1,4 +1,4 @@
-module(erlNpc).
-module(eNpc).
-export([
main/1
@ -7,13 +7,13 @@
main(Args) ->
file:set_cwd("c_src"),
{ok, Dir} = file:get_cwd(),
io:format("erlNpc begin compile pwd:~15.p ~n", [Dir]),
io:format("eNpc begin compile pwd:~15.p ~n", [Dir]),
FunCom =
fun(File) ->
case filelib:is_dir(File) == true andalso lists:nth(1, File) =/= 46 andalso filename:basename(File) =/= "include" of
true ->
{ok, CurDir} = file:get_cwd(),
io:format("erlNpc 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),
rebar:main(Args),
file:set_cwd("..");
@ -25,7 +25,7 @@ main(Args) ->
{ok, Files} ->
lists:foreach(FunCom, Files);
_Err ->
rebar:log(error, "erlNpc start compile error ~p ~n", [_Err])
rebar:log(error, "eNpc start compile error ~p ~n", [_Err])
end.

+ 7
- 7
src/rebar.erl View File

@ -35,7 +35,7 @@ main(Args) ->
end.
log(Level, Format, Args) ->
{ok, LimitLevel} = application:get_env(erlNpc, log_level),
{ok, LimitLevel} = application:get_env(eNpc, log_level),
case levelInt(LimitLevel) >= levelInt(Level) of
true ->
io:format(destination(Level), Format, Args);
@ -68,10 +68,10 @@ run(RawArgs) ->
loadRebarApp() ->
%% Pre-load the rebar app so that we get default configuration
case application:load(erlNpc) of
case application:load(eNpc) of
ok ->
ok;
{error, {already_loaded,erlNpc}} ->
{error, {already_loaded,eNpc}} ->
ok;
_ ->
rebarUtils:delayedHalt(1)
@ -82,7 +82,7 @@ help(compile) ->
help(clean) ->
rebarNpCompiler:info(help, clean);
help(Command) ->
?CONSOLE("erlNpc no help available for \"~p\"~n", [Command]).
?CONSOLE("eNpc no help available for \"~p\"~n", [Command]).
parseArgs([]) ->
{[], []};
@ -110,7 +110,7 @@ parseArgs([NonOpt | Rest]) ->
{Opts, [NonOpt | NonOpts]}.
usage() ->
?CONSOLE("erlNpc [-hv] [-c CONFIG_FILE] COMMAND [COMMAND ...]~n~n", []).
?CONSOLE("eNpc [-hv] [-c CONFIG_FILE] COMMAND [COMMAND ...]~n~n", []).
initConfig({Options, _NonOptArgs}) ->
%% If $HOME/.rebar/config exists load and use as global config
@ -202,8 +202,8 @@ saveOptions(Config, {Options, NonOptArgs}) ->
%% show version information and halt
version() ->
{ok, Vsn} = application:get_key(erlNpc, vsn),
?CONSOLE("erlNpc ~s ~s ~s ~s\n", [Vsn, ?OTP_INFO, ?BUILD_TIME, ?VCS_INFO]).
{ok, Vsn} = application:get_key(eNpc, vsn),
?CONSOLE("eNpc ~s ~s ~s ~s\n", [Vsn, ?OTP_INFO, ?BUILD_TIME, ?VCS_INFO]).
%% Seperate all commands (single-words) from flags (key=value) and store
%% values into the rebar_config global storage.

+ 2
- 2
src/rebarUtils.erl View File

@ -240,12 +240,12 @@ processingBaseDir(Config, Dir) ->
AbsDir =:= baseDir(Config).
otpRelease() ->
case application:get_env(erlNpc, memoized_otp_release) of
case application:get_env(eNpc, memoized_otp_release) of
{ok, Return} ->
Return;
undefined ->
Return = otpRelease_1(erlang:system_info(otp_release)),
application:set_env(erlNpc, memoized_otp_release, Return),
application:set_env(eNpc, memoized_otp_release, Return),
Return
end.

Loading…
Cancel
Save