diff --git a/.gitignore b/.gitignore index 0b66f73..19adb84 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ _build/ _checkouts/ .idea +*.iml diff --git a/README.md b/README.md index 559ce8e..86f02c1 100644 --- a/README.md +++ b/README.md @@ -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...). diff --git a/bootstrap b/bootstrap index 6e7ff3c..7422f73 100644 --- a/bootstrap +++ b/bootstrap @@ -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", "*"), diff --git a/eNpc b/eNpc new file mode 100644 index 0000000..bab264a Binary files /dev/null and b/eNpc differ diff --git a/eNpc.cmd b/eNpc.cmd new file mode 100644 index 0000000..6c7a1ca --- /dev/null +++ b/eNpc.cmd @@ -0,0 +1,4 @@ +@echo off +setlocal +set rebarscript=%~f0 +escript.exe "%rebarscript:.cmd=%" %* diff --git a/ebin/erlNpc.app b/ebin/eNpc.app similarity index 57% rename from ebin/erlNpc.app rename to ebin/eNpc.app index 76ed1ee..53d695d 100644 --- a/ebin/erlNpc.app +++ b/ebin/eNpc.app @@ -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}]}]}. diff --git a/src/erlNpc.erl b/src/eNpc.erl similarity index 71% rename from src/erlNpc.erl rename to src/eNpc.erl index 1212810..9b94263 100644 --- a/src/erlNpc.erl +++ b/src/eNpc.erl @@ -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. diff --git a/src/rebar.erl b/src/rebar.erl index ee71287..dc2dd20 100644 --- a/src/rebar.erl +++ b/src/rebar.erl @@ -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. diff --git a/src/rebarUtils.erl b/src/rebarUtils.erl index 72fedd0..0e538dd 100644 --- a/src/rebarUtils.erl +++ b/src/rebarUtils.erl @@ -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.