Erlang里的make

Erlang自带一个make工具
我们看一个例子

目录结构:
--Emakefile
-include
 --test.hrl
-src
 --test.erl
-ebin


Emakefile:
{'src/*', [{i, "include"}, {outdir, "ebin"}]}.


test.hrl:
-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]).


使用Erlang的make:
erl -make


运行:
erl -noshell -pa ./ebin -s test start -s init stop


结果:
"127.0.0.1"
80
10

你可能感兴趣的:(erlang)