-
Notifications
You must be signed in to change notification settings - Fork 71
/
winbuild
executable file
·86 lines (71 loc) · 3.57 KB
/
winbuild
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env escript
-mode(compile).
% How to make a windows build:
% 1. Install erlang and git for windows
% 2. Add c:\Program Files\erl6.x.x to path
% 3. clone actordb
% 4. build rebar for windows, copy the rebar.cmd file to actordb folder
% 5. rebar get-deps
% 6. rebar compile (yamerl is not windows compatible, remove all makefiles and rebar will be able to compile it)
% 7. winbuild.bat
% 8. Take erlang installation and copy it to win folder. Remove erl.ini files in bin and erts/bin folders
% 9. Use win folder.
main(_Args) ->
filelib:ensure_dir("win/ebin/"),
filelib:ensure_dir("win/priv/"),
filelib:ensure_dir("win/data/"),
filelib:ensure_dir("win/etc/"),
filelib:ensure_dir("win/log/"),
filelib:ensure_dir("win/licenses/"),
filelib:ensure_dir("win/extensions/"),
[file:copy(F,"win/ebin/"++filename:basename(F)) || F <- filelib:wildcard("deps/*/ebin/*")],
[file:copy(F,"win/priv/"++filename:basename(F)) || F <- filelib:wildcard("deps/*/priv/*.dll")],
file:copy("LICENSE","win/licenses/LICENSE"),
[file:copy(F,"win/licenses/LICENSE-"++hd(tl(filename:split(filename:dirname(F))))) || F <- filelib:wildcard("deps/*/LICENSE")],
file:write_file("win/installdeps.bat",deps()),
file:write_file("win/actordb.bat",run()),
file:write_file("win/actordb_console.bat",ctrl()),
file:write_file("win/stop-background-processes.bat",epmd()),
os:cmd("escript.exe priv/mkconsole.escript"),
file:copy("priv/actordb_wxconsole","win/priv/actordb_wxconsole"),
file:copy("rel/files/vm.args","win/etc/vm.args"),
file:copy("rel/files/sqlite_extensions_here","win/extensions/sqlite_extensions_here"),
file:copy("etc/init.sql","win/etc/init.sql"),
{ok,AppFile} = file:read_file("rel/files/app.config"),
AppFile1 = re:replace(AppFile,"{{platform_data_dir}}","data",[global]),
AppFile2 = re:replace(AppFile1,"{{platform_log_dir}}","log",[global]),
AppFile3 = re:replace(AppFile2,"{{extensions_dir}}","extensions",[global]),
file:write_file("win/etc/app.config",AppFile3),
ToolCmd = "cl deps\\actordb_driver\\c_src\\tool.c deps\\actordb_driver\\c_src\\mdb.c deps\\actordb_driver\\c_src\\midl.c deps\\actordb_driver\\c_src\\lz4.c /D_TESTAPP_=1 /DSQLITE_DEFAULT_PAGE_SIZE=4096 /DSQLITE_DEFAULT_WAL_AUTOCHECKPOINT=0 /Ic_src Ws2_32.lib Advapi32.lib",
os:cmd(ToolCmd),
file:rename("tool.exe","win/tool.exe"),
[file:delete(Nm) || Nm <- filelib:wildcard("*.obj")],
ok.
run() ->
check("erl.exe") ++
"start \"\" \"%CD%/erl7.3/bin/werl\" -pa ebin -config etc/app.config -s actordb_core -args_file etc/vm.args\n"++
"exit\n".
deps() ->
check("")++
"start \"\" \"%CD%/erl7.3/vcredist_x64.exe\" /q /norestart\n"++
"exit\n".
epmd() ->
check("")++
"\"%CD%/erl7.3/erts-7.3/bin/epmd\" -kill\n"++
"exit\n".
ctrl() ->
check("escript.exe") ++
%"%CD%/erl7.2.1/bin/escript.exe priv/actordb_console %*\n"++
"start /min \"\" \"%CD%/erl7.3/bin/escript.exe\" priv/actordb_wxconsole %*\n".
%"pause".
check(_Name) ->
"@echo off\n"++
"setlocal\n".
% Used to clean up erlang folder.
%[file:delete(Nm) || Nm <- filelib:wildcard("**"), filename:extension(Nm) == ".erl"].
%[file:delete(Nm) || Nm <- filelib:wildcard("**"), filename:extension(Nm) == ".lib"].
%[file:delete(Nm) || Nm <- filelib:wildcard("**"), filename:extension(Nm) == ".pdb"].
%[file:delete(Nm) || Nm <- filelib:wildcard("**"), filename:extension(Nm) == ".hrl"].
%[file:delete(Nm) || Nm <- filelib:wildcard("**"), filename:extension(Nm) == ".html"].
%[file:delete(Nm) || Nm <- filelib:wildcard("**"), filename:extension(Nm) == ".gif"].
%[file:delete(Nm) || Nm <- filelib:wildcard("**"), filename:extension(Nm) == ".pdf"].