我尝试做类似于如何在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
Run Code Online (Sandbox Code Playgroud)
问题是运行make test不会重新编译已编译的任何模块make.它似乎erl -make并不关心它们是在没有TEST定义的情况下编译的,只是检查模块本身是否比beam-files更旧.如何强制它重新编译(并避免在不需要时重新编译)?
更新:奇怪的是,当make all_test立即运行时make clean,它似乎./Emakefile被用来代替test/Emakefile:我得到了
Recompile: src/tests
Recompile: src/server_protocol_client
Run Code Online (Sandbox Code Playgroud)
等,而不是测试而不是
Recompile: ../src/tests
Recompile: ../src/server_protocol_client
Run Code Online (Sandbox Code Playgroud)
我cd test; erl -make手动做的.知道为什么吗?无论如何,我通过删除test/Emakefile和替换all_test来解决这个问题Makefile:
all_test: before_compile
erl -noshell -eval "make:all([{d, 'TEST'}])." -s init stop
Run Code Online (Sandbox Code Playgroud)
小智 3
all_test: before_compile
cd test
erl -make
cd ..
Run Code Online (Sandbox Code Playgroud)
这是不正确的。每条生产线都有自己的生产流程。这样做:
all_test: before_compile
cd test; \
erl -make
Run Code Online (Sandbox Code Playgroud)