Skip to content

Commit abfbfc2

Browse files
committedApr 5, 2012
Improved Windows Support.
1 parent ef8c7f3 commit abfbfc2

10 files changed

+103
-13
lines changed
 

‎Makefile

-8
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,9 @@ SESSION_CONFIG_DIR=priv/test_session_config
1010
all:
1111
@$(REBAR) get-deps
1212
@$(REBAR) compile
13-
$(ERL) -pa ebin -pa deps/*/ebin \
14-
-eval 'erlydtl:compile("src/boss/boss_html_error_template.dtl", boss_html_error_template, [{out_dir, "ebin"}])' \
15-
-eval 'erlydtl:compile("src/boss/boss_html_doc_template.dtl", boss_html_doc_template, [{out_dir, "ebin"}])' \
16-
-noshell -s init stop
1713

1814
boss:
1915
@$(REBAR) compile skip_deps=true
20-
$(ERL) -pa ebin -pa deps/*/ebin \
21-
-eval 'erlydtl:compile("src/boss/boss_html_error_template.dtl", boss_html_error_template, [{out_dir, "ebin"}])' \
22-
-eval 'erlydtl:compile("src/boss/boss_html_doc_template.dtl", boss_html_doc_template, [{out_dir, "ebin"}])' \
23-
-noshell -s init stop
2416

2517
clean:
2618
@$(REBAR) clean

‎priv/rebar/boss_rebar.erl

+33-3
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,20 @@ start_dev_cmd(_RebarConf, BossConf, AppFile) ->
135135
rebar_log:log(info, "Generating dynamic start-dev command~n", []),
136136

137137
AppName = app_name(AppFile),
138-
EbinDirs = all_ebin_dirs(BossConf, AppFile),
139138
SName = sname(BossConf, AppFile),
139+
case os:type() of
140+
{win32, _ } ->
141+
EbinDirs = all_ebin_dirs(windows, BossConf, AppFile),
142+
Dirs = io_lib:format("~p", [lists:flatten(EbinDirs)]), %EbinDirs come back as a list of lists [[],[],[]]
143+
Cmd = io_lib:format("werl -pa ~s -boss developing_app ~s -boot start_sasl -config boss -s reloader -s boss -sname ~s",
144+
[string:join(lists:append(EbinDirs), " -pa "), AppName, SName]),
145+
io:format("~s~n", [Cmd]);
146+
_ ->
147+
EbinDirs = all_ebin_dirs(BossConf, AppFile),
148+
io:format("exec erl -pa ~s -boss developing_app ~s -boot start_sasl -config boss -s reloader -s boss -sname ~s",
149+
[string:join(EbinDirs, " -pa "), AppName, SName])
140150

141-
io:format("exec erl -pa ~s -boss developing_app ~s -boot start_sasl -config boss -s reloader -s boss -sname ~s",
142-
[string:join(EbinDirs, " -pa "), AppName, SName]),
151+
end,
143152
ok.
144153

145154
%%--------------------------------------------------------------------
@@ -323,6 +332,27 @@ all_ebin_dirs(BossConf, _AppFile) ->
323332
[MainEbin, DepsEbin | EbinDirs]
324333
end end, [], lists:reverse(BossConf)).
325334

335+
%%--------------------------------------------------------------------
336+
%% @doc Start the boss app
337+
%% @spec all_ebin_dirs(windows, BossConf, _AppFile)
338+
%% Gets the exact path name of all deps ebin dirs
339+
%% for the apps defined in boss.config for Windows
340+
%% @end
341+
%%--------------------------------------------------------------------
342+
all_ebin_dirs(windows, BossConf, _AppFile) ->
343+
lists:foldl(fun({_App, Config}, EbinDirs) ->
344+
case lists:keyfind(path, 1, Config) of
345+
false -> EbinDirs;
346+
{path, Path} ->
347+
MainEbin = filename:join([Path, "ebin"]),
348+
filelib:ensure_dir(filename:join([MainEbin, "foobar"])),
349+
DepsEbins = case file:list_dir(Path++"/deps") of
350+
{ok, Dirs} -> lists:map(fun(Dir) -> Path ++ "/deps/" ++ Dir ++ "/ebin" end, Dirs);
351+
{error, _Reason} -> []
352+
end,
353+
[lists:append([MainEbin] , DepsEbins) | EbinDirs] % DepsEbins is a list, while MainEbin is a string
354+
end end, [], lists:reverse(BossConf)).
355+
326356
%%--------------------------------------------------------------------
327357
%% @doc Injects the boss.conf configuration to the boss application
328358
%% @spec init_conf(BossConf)

‎rebar

15.8 KB
Binary file not shown.

‎rebar.cmd

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@echo off
2+
setlocal
3+
set rebarscript=%~f0
4+
escript.exe "%rebarscript:.cmd=%" %*

‎rebar.config

+6
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,9 @@
88
{mochiweb, ".*", {git, "git://github.com/mochi/mochiweb.git", {tag, "v2.3.0"}}},
99
{poolboy, ".*", {git, "git://github.com/devinus/poolboy.git", {tag, "855802e0cc"}}}
1010
]}.
11+
{erlydtl_opts, [
12+
{doc_root, "src/boss"},
13+
{out_dir, "ebin"},
14+
{source_ext, ".dtl"},
15+
{module_ext, ""}
16+
]}.

‎skel.template

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
{file, "skel/init.sh", "{{dest}}/init.sh"}.
3535
{file, "skel/init-dev.sh", "{{dest}}/init-dev.sh"}.
3636
{file, "skel/rebar", "{{dest}}/rebar"}.
37+
{file, "skel/rebar.cmd", "{{dest}}/rebar.cmd"}.
3738
{file, "skel/rebar.config", "{{dest}}/rebar.config"}.
3839
{chmod, 8#755, "{{dest}}/init.sh"}.
3940
{chmod, 8#755, "{{dest}}/init-dev.sh"}.

‎skel/rebar

18.8 KB
Binary file not shown.

‎skel/rebar.cmd

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@echo off
2+
setlocal
3+
set rebarscript=%~f0
4+
escript.exe "%rebarscript:.cmd=%" %*

‎skel/start-server.bat

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
make
2-
erl -pa ebin -boot start_sasl -config boss -s reloader -s boss
1+
@ECHO OFF
2+
FOR /F "tokens=*" %%i in ('"rebar.cmd boss c=start_dev_cmd ^| findstr werl"') do set myvar=%%i
3+
START "Erlang Window" %myvar%

‎windows-make.bat

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
@ECHO OFF
2+
REM @echo 1st:%1 2nd:%2 3rd:%3 4th:%4
3+
4+
SET PWD=%cd%
5+
SET APPNAME=%3
6+
for %%* in (.) do set PARENTDIR=%%~n*
7+
8+
IF /I [%1] EQU [] CALL :all
9+
IF /I "%1"=="all" CALL :all
10+
IF /I "%1"=="boss" CALL :boss
11+
IF /I "%1"=="clean" CALL :clean
12+
IF /I "%1"=="get-deps" CALL :get-deps
13+
IF /I "%1"=="deps" CALL :deps
14+
IF /I "%1"=="test" CALL :test
15+
IF /I "%1"=="app" IF /I "%2"=="project" IF [%3] NEQ [] CALL :app
16+
17+
:: End of main program
18+
GOTO End
19+
20+
21+
:all
22+
CALL rebar.cmd get-deps
23+
CALL rebar.cmd compile
24+
GOTO :EOF
25+
26+
:boss
27+
CALL rebar.cmd compile skip_deps=true
28+
GOTO :EOF
29+
30+
:clean
31+
CALL rebar.cmd clean
32+
GOTO :EOF
33+
34+
:get-deps
35+
CALL rebar.cmd get-deps
36+
GOTO :EOF
37+
38+
:deps
39+
CALL rebar.cmd compile
40+
GOTO :EOF
41+
42+
:test
43+
CALL rebar.cmd skip_deps=true eunit
44+
GOTO :EOF
45+
46+
:: example how to invoke: windows-make.bat app PROJECT=awesomename
47+
:app
48+
CALL rebar.cmd create template=skel dest=../%APPNAME% src=../%PARENTDIR% appid=%APPNAME% skip_deps=true
49+
GOTO :EOF
50+
51+
:End
52+
:: End of batch file

0 commit comments

Comments
 (0)
Please sign in to comment.