summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@rabbitmq.com>2010-11-12 00:28:45 +0000
committerMatthew Sackman <matthew@rabbitmq.com>2010-11-12 00:28:45 +0000
commit0cef8cb483d0108cd21a252952376e4455559e71 (patch)
treed581e26a5dec32a33ea738969575e642afaeec00
parent44cf639fb82a396082f8c79bcd7ec018d344de13 (diff)
parenta2945751a9b0369ec19db1c02acb46aa1fa655a6 (diff)
downloadrabbitmq-server-0cef8cb483d0108cd21a252952376e4455559e71.tar.gz
Merging bug 23481 to default
-rw-r--r--Makefile2
-rw-r--r--generate_deps23
2 files changed, 14 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index b43808a1..8e33b83c 100644
--- a/Makefile
+++ b/Makefile
@@ -93,7 +93,7 @@ all: $(TARGETS)
$(DEPS_FILE): $(SOURCES) $(INCLUDES)
rm -f $@
- escript generate_deps $(INCLUDE_DIR) $(SOURCE_DIR) \$$\(EBIN_DIR\) $@
+ echo $(subst : ,:,$(foreach FILE,$^,$(FILE):)) | escript generate_deps $@ $(EBIN_DIR)
$(EBIN_DIR)/rabbit.app: $(EBIN_DIR)/rabbit_app.in $(BEAM_TARGETS) generate_app
escript generate_app $(EBIN_DIR) $@ < $<
diff --git a/generate_deps b/generate_deps
index 29587b5a..ddfca816 100644
--- a/generate_deps
+++ b/generate_deps
@@ -2,18 +2,21 @@
%% -*- erlang -*-
-mode(compile).
-main([IncludeDir, ErlDir, EbinDir, TargetFile]) ->
- ErlDirContents = filelib:wildcard("*.erl", ErlDir),
- ErlFiles = [filename:join(ErlDir, FileName) || FileName <- ErlDirContents],
+%% We expect the list of Erlang source and header files to arrive on
+%% stdin, with the entries colon-separated.
+main([TargetFile, EbinDir]) ->
+ ErlsAndHrls = [ string:strip(S,left) ||
+ S <- string:tokens(io:get_line(""), ":\n")],
+ ErlFiles = [F || F <- ErlsAndHrls, lists:suffix(".erl", F)],
Modules = sets:from_list(
[list_to_atom(filename:basename(FileName, ".erl")) ||
- FileName <- ErlDirContents]),
- Headers = sets:from_list(
- [filename:join(IncludeDir, FileName) ||
- FileName <- filelib:wildcard("*.hrl", IncludeDir)]),
+ FileName <- ErlFiles]),
+ HrlFiles = [F || F <- ErlsAndHrls, lists:suffix(".hrl", F)],
+ IncludeDirs = lists:usort([filename:dirname(Path) || Path <- HrlFiles]),
+ Headers = sets:from_list(HrlFiles),
Deps = lists:foldl(
fun (Path, Deps1) ->
- dict:store(Path, detect_deps(IncludeDir, EbinDir,
+ dict:store(Path, detect_deps(IncludeDirs, EbinDir,
Modules, Headers, Path),
Deps1)
end, dict:new(), ErlFiles),
@@ -33,8 +36,8 @@ main([IncludeDir, ErlDir, EbinDir, TargetFile]) ->
ok = file:sync(Hdl),
ok = file:close(Hdl).
-detect_deps(IncludeDir, EbinDir, Modules, Headers, Path) ->
- {ok, Forms} = epp:parse_file(Path, [IncludeDir], [{use_specs, true}]),
+detect_deps(IncludeDirs, EbinDir, Modules, Headers, Path) ->
+ {ok, Forms} = epp:parse_file(Path, IncludeDirs, [{use_specs, true}]),
lists:foldl(
fun ({attribute, _LineNumber, Attribute, Behaviour}, Deps)
when Attribute =:= behaviour orelse Attribute =:= behavior ->