Browse Source

Make sure auto patched dependencies recompile fine

Loïc Hoguin 10 years ago
parent
commit
a34d21e62d
3 changed files with 13 additions and 0 deletions
  1. 8 0
      core/deps.mk
  2. 3 0
      plugins/c_src.mk
  3. 2 0
      test/Makefile

+ 8 - 0
core/deps.mk

@@ -148,6 +148,14 @@ define dep_autopatch_rebar.erl
 			_ -> ok
 		end
 	end(),
+	fun() ->
+		case filelib:is_dir("$(DEPS_DIR)/$(1)/c_src") of
+			false -> ok;
+			true ->
+				Sources = [[" ./c_src/", S] || S <- filelib:wildcard("*.{c,C,cc,cpp}", "$(DEPS_DIR)/$(1)/c_src")],
+				Write(io_lib:format("SOURCES := ~s\n", [Sources]))
+		end
+	end(),
 	Write("\n\nrebar_dep: pre-deps deps pre-app app\n"),
 	Write("\npre-deps::\n"),
 	Write("\npre-app::\n"),

+ 3 - 0
plugins/c_src.mk

@@ -59,7 +59,10 @@ clean::
 	$(MAKE) -C $(C_SRC_DIR) clean
 
 else
+
+ifeq ($(SOURCES),)
 SOURCES := $(shell find $(C_SRC_DIR) -type f \( -name "*.c" -o -name "*.C" -o -name "*.cc" -o -name "*.cpp" \))
+endif
 OBJECTS = $(addsuffix .o, $(basename $(SOURCES)))
 
 COMPILE_C = $(c_verbose) $(CC) $(CFLAGS) $(CPPFLAGS) -c

+ 2 - 0
test/Makefile

@@ -217,6 +217,7 @@ pkg-$(1)-clean:
 pkg-$(1)-app1:
 	$(call app1_setup)
 
+# Running 'make' twice to make sure it recompiles fine.
 pkg-$(1): pkg-$(1)-clean pkg-$(1)-app1
 	$i
 	$i "  pkgs: Checking that '$(1)' builds correctly"
@@ -228,6 +229,7 @@ pkg-$(1): pkg-$(1)-clean pkg-$(1)-app1
 		> app1/Makefile
 	cp ../packages.v2.tsv app1/.erlang.mk.packages.v2
 	$t make -C app1
+	$t make -C app1
 endef
 
 $(foreach pkg,$(shell awk '{print $$1}' ../packages.v2.tsv),$(eval $(call pkg_test_target,$(pkg))))