当宏更改时强制 erl -make 重新编译文件
我尝试做类似的事情 如何将 Makefile 中的两个不同源目录输出到一个 bin 目录?,所以我有这些文件(相对于我的项目根目录):
Emakefile:
% EMakefile
% -*- mode: erlang -*-
{["src/*", "src/*/*", "src/*/*/*"],
[{i, "include"}, {outdir, "ebin"}, debug_info]}.
test/Emakefile:
% EMakefile
% -*- mode: erlang -*-
{["../src/*", "../src/*/*", "../src/*/*/*"],
[{i, "../include"}, {outdir, "../ebin"}, debug_info, {d, 'TEST'}]}.
Makefile:
EPATH=-pa ebin
all: before_compile
erl -make
all_test: before_compile
cd test
erl -make
cd ..
before_compile: mk_ebin copy_sqlite create_db copy_config copy_dot_app
test: all_test
erl -noshell $(EPATH) \
-s tests run \
-s init stop
rm -f ct.db
clean:
rm -fv ebin/*
... dependencies of before_compile
问题是运行 make test
不会重新编译任何已使用 make
编译的模块。似乎 erl -make 并不关心它们是在没有定义 TEST 的情况下编译的,它只是检查模块本身是否比梁文件旧。如何强制它重新编译(并在不需要时避免重新编译)?
更新:奇怪的是,在make clean
之后立即运行make all_test
时,似乎使用了./Emakefile
test/Emakefile
:我得到了
Recompile: src/tests
Recompile: src/server_protocol_client
等等,并且没有测试,而是
Recompile: ../src/tests
Recompile: ../src/server_protocol_client
通过执行 cd test; 得到了测试; erl -make 手动。知道为什么吗?无论如何,我通过删除
test/Emakefile
并替换 Makefile
中的 all_test
解决了这个问题:
all_test: before_compile
erl -noshell -eval "make:all([{d, 'TEST'}])." -s init stop
I tried to do something similar to How to make two different source directories in a Makefile output to one bin directory?, so I have these files (relative to my project root):
Emakefile:
% EMakefile
% -*- mode: erlang -*-
{["src/*", "src/*/*", "src/*/*/*"],
[{i, "include"}, {outdir, "ebin"}, debug_info]}.
test/Emakefile:
% EMakefile
% -*- mode: erlang -*-
{["../src/*", "../src/*/*", "../src/*/*/*"],
[{i, "../include"}, {outdir, "../ebin"}, debug_info, {d, 'TEST'}]}.
Makefile:
EPATH=-pa ebin
all: before_compile
erl -make
all_test: before_compile
cd test
erl -make
cd ..
before_compile: mk_ebin copy_sqlite create_db copy_config copy_dot_app
test: all_test
erl -noshell $(EPATH) \
-s tests run \
-s init stop
rm -f ct.db
clean:
rm -fv ebin/*
... dependencies of before_compile
The problem is that running make test
doesn't recompile any modules which are already compiled with make
. It seems erl -make
doesn't care that they were compiled without TEST
defined, it just checks that the modules themselves are older than beam-files. How do I force it to recompile (and avoid recompilation when it isn't needed)?
UPDATE: Strangely, when running make all_test
immediately after make clean
, it appears that ./Emakefile
is used instead of test/Emakefile
: I am getting
Recompile: src/tests
Recompile: src/server_protocol_client
etc. and no tests instead of
Recompile: ../src/tests
Recompile: ../src/server_protocol_client
which I get by doing cd test; erl -make
manually. Any idea why? Anyway, I've fixed this problem by removing test/Emakefile
and replacing all_test
in Makefile
:
all_test: before_compile
erl -noshell -eval "make:all([{d, 'TEST'}])." -s init stop
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是不正确的。每条生产线都有自己的生产流程。这样做:
This is incorrect. Each line produces its own process. Do such: