Erlang自带一个make工具
我们看一个例子
目录结构:
- --Emakefile
- -include
- --test.hrl
- -src
- --test.erl
- -ebin
--Emakefile
-include
--test.hrl
-src
--test.erl
-ebin
Emakefile:
- { 'src/*' , [{i, "include" }, {outdir, "ebin" }]}.
{'src/*', [{i, "include"}, {outdir, "ebin"}]}.
test.hrl:
- -record(server_opts,
- {port,
- ip="127.0.0.1" ,
- max_connections=10 }).
-record(server_opts,
{port,
ip="127.0.0.1",
max_connections=10}).
test.erl:
- -module(test).
- -include("test.hrl" ).
- -export([start/0 ]).
- start() ->
- Opts1 = #server_opts{port=80 },
- io:format("~p~n" , [Opts1#server_opts.ip]),
- io:format("~p~n" , [Opts1#server_opts.port]),
- io:format("~p~n" , [Opts1#server_opts.max_connections]).
-module(test).
-include("test.hrl").
-export([start/0]).
start() ->
Opts1 = #server_opts{port=80},
io:format("~p~n", [Opts1#server_opts.ip]),
io:format("~p~n", [Opts1#server_opts.port]),
io:format("~p~n", [Opts1#server_opts.max_connections]).
使用Erlang的make:
- erl -make
erl -make
运行:
- erl -noshell -pa ./ebin -s test start -s init stop
erl -noshell -pa ./ebin -s test start -s init stop
结果:
- "127.0.0.1"
- 80
- 10
1554

被折叠的 条评论
为什么被折叠?



