开发者

Forcing erl -make to recompile files when macros are changed

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 w开发者_开发技巧hy? 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


all_test: before_compile
    cd test
    erl -make
    cd ..

This is incorrect. Each line produces its own process. Do such:

all_test: before_compile
    cd test; \
    erl -make
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜