Browse Source

More improvements for building dependencies

Loïc Hoguin 10 years ago
parent
commit
418969e804
5 changed files with 59 additions and 36 deletions
  1. 37 20
      core/deps.mk
  2. 3 3
      packages.v1.tsv
  3. 3 3
      packages.v1.txt
  4. 3 3
      packages.v2.tsv
  5. 13 7
      plugins/c_src.mk

+ 37 - 20
core/deps.mk

@@ -82,45 +82,62 @@ endef
 ifeq ($(NO_AUTOPATCH_ERLANG_MK),)
 define dep_autopatch_erlang_mk
 	rm -f $(DEPS_DIR)/$(1)/erlang.mk; \
-	cd $(DEPS_DIR)/$(1)/ && ln -s ../../erlang.mk
+	cd $(DEPS_DIR)/$(1)/ && ln -s ../../erlang.mk; \
+	$(call erlang,$(call dep_autopatch_appsrc.erl,$(1)))
 endef
 else
 define dep_autopatch_erlang_mk
-	echo -n
+	$(call erlang,$(call dep_autopatch_appsrc.erl,$(1)))
 endef
 endif
 
 define dep_autopatch_gen
 	printf "%s\n" \
 		"ERLC_OPTS = +debug_info" \
-		"include ../../erlang.mk" > $(DEPS_DIR)/$(1)/Makefile
+		"include ../../erlang.mk" > $(DEPS_DIR)/$(1)/Makefile; \
+	$(call erlang,$(call dep_autopatch_appsrc.erl,$(1)))
 endef
 
 define dep_autopatch_rebar
-	$(call erlang,$(call dep_autopatch_rebar.erl,$(1)))
+	rm -f $(DEPS_DIR)/$(1)/Makefile; \
+	$(call erlang,$(call dep_autopatch_rebar.erl,$(1))); \
+	$(call erlang,$(call dep_autopatch_appsrc.erl,$(1)))
 endef
 
 define dep_autopatch_rebar.erl
-	DepDir = "$(DEPS_DIR)/$(1)/",
+	{ok, Conf} = file:consult("$(DEPS_DIR)/$(1)/rebar.config"),
+	Write = fun (Text) ->
+		file:write_file("$(DEPS_DIR)/$(1)/Makefile", Text, [append])
+	end,
+	Write("ERLC_OPTS = +debug_info\n\n"),
+	fun() ->
+		File = case lists:keyfind(deps, 1, Conf) of
+			false -> [];
+			{_, Deps} ->
+				[begin
+					Name = element(1, Dep),
+					{Method, Repo, Commit} = case element(3, Dep) of
+						{git, R} -> {git, R, master};
+						{M, R, {branch, C}} -> {M, R, C};
+						{M, R, {tag, C}} -> {M, R, C};
+						{M, R, C} -> {M, R, C}
+					end,
+					Write(io_lib:format("DEPS += ~s\ndep_~s = ~s ~s ~s~n", [Name, Name, Method, Repo, Commit]))
+				end || Dep <- Deps, tuple_size(Dep) > 2]
+		end
+	end(),
 	fun() ->
-		{ok, Conf} = file:consult(DepDir ++ "rebar.config"),
-		File = case lists:keyfind(deps, 1, Conf) of false -> []; {_, Deps} ->
-			[begin {Method, Repo, Commit} = case Repos of
-				{git, R} -> {git, R, master};
-				{M, R, {branch, C}} -> {M, R, C};
-				{M, R, {tag, C}} -> {M, R, C};
-				{M, R, C} -> {M, R, C}
-			end,
-			io_lib:format("DEPS += ~s\ndep_~s = ~s ~s ~s~n", [Name, Name, Method, Repo, Commit]) 
-			end || {Name, _, Repos} <- Deps, {Name, _, Repos, [raw]} <- Deps]
-		end,
 		First = case lists:keyfind(erl_first_files, 1, Conf) of false -> []; {_, Files} ->
-			Names = [[" ", begin "lre." ++ R = lists:reverse(F), lists:reverse(R) end]
+			Names = [[" ", begin "lre." ++ Elif = lists:reverse(F), lists:reverse(Elif) end]
 				 || "src/" ++ F <- Files],
-			io_lib:format("COMPILE_FIRST +=~s\n", [Names])
-		end,
-		ok = file:write_file("$(DEPS_DIR)/$(1)/Makefile", ["ERLC_OPTS = +debug_info\n\n", File, First, "\ninclude ../../erlang.mk"])
+			Write(io_lib:format("COMPILE_FIRST +=~s\n", [Names]))
+		end
 	end(),
+	Write("\ninclude ../../erlang.mk"),
+	halt()
+endef
+
+define dep_autopatch_appsrc.erl
 	AppSrcOut = "$(DEPS_DIR)/$(1)/src/$(1).app.src",
 	AppSrcIn = case filelib:is_regular(AppSrcOut) of false -> "$(DEPS_DIR)/$(1)/ebin/$(1).app"; true -> AppSrcOut end,
 	fun() ->

+ 3 - 3
packages.v1.tsv

@@ -1,4 +1,4 @@
-apns4erl	https://github.com/inaka/apns4erl	http://inaka.github.com/apns4erl	Apple Push Notification Server for Erlang
+apns	https://github.com/inaka/apns4erl	http://inaka.github.com/apns4erl	Apple Push Notification Server for Erlang
 cake	https://github.com/darach/cake-erl	https://github.com/darach/cake-erl	Really simple terminal colorization
 classifier	https://github.com/inaka/classifier	https://github.com/inaka/classifier	An Erlang Bayesian Filter and Text Classifier
 cowboy	https://github.com/ninenines/cowboy	http://ninenines.eu	Small, fast and modular HTTP server.
@@ -32,6 +32,7 @@ ibrowse	https://github.com/cmullaparthi/ibrowse	https://github.com/cmullaparthi/
 itweet	https://github.com/inaka/itweet	http://inaka.github.com/itweet/	Twitter Stream API on ibrowse
 jiffy	https://github.com/davisp/jiffy	https://github.com/davisp/jiffy	JSON NIFs for Erlang.
 jiffy_v	https://github.com/shizzard/jiffy-v	https://github.com/shizzard/jiffy-v	JSON validation utility
+jobs	https://github.com/esl/jobs	https://github.com/esl/jobs	a Job scheduler for load regulation
 jsx	https://github.com/talentdeficit/jsx	https://github.com/talentdeficit/jsx	An Erlang application for consuming, producing and manipulating JSON.
 katja	https://github.com/nifoc/katja	https://github.com/nifoc/katja	A simple Riemann client written in Erlang.
 lager	https://github.com/basho/lager	https://github.com/basho/lager	A logging framework for Erlang/OTP.
@@ -45,12 +46,11 @@ poolboy	https://github.com/devinus/poolboy	https://github.com/devinus/poolboy	A
 ptrackerl	https://github.com/inaka/ptrackerl	https://github.com/inaka/ptrackerl	Pivotal Tracker API Client written in Erlang
 qdate	https://github.com/choptastic/qdate	https://github.com/choptastic/qdate	Date, time, and timezone parsing, formatting, and conversion for Erlang.
 ranch	https://github.com/ninenines/ranch	http://ninenines.eu	Socket acceptor pool for TCP protocols.
-rec2json	https://github.com/lordnull/rec2json	https://github.com/lordnull/rec2json	Compile erlang record definitions into modules to convert them to/from json easily.
 recon	https://github.com/ferd/recon	https://github.com/ferd/recon	Collection of functions and scripts to debug Erlang in production.
 record_info	https://github.com/bipthelin/erlang-record_info	https://github.com/bipthelin/erlang-record_info	Convert between record and proplist
 resource_discovery	https://github.com/erlware/resource_discovery	http://erlware.org/	An application used to dynamically discover resources present in an Erlang node cluster.
 sfmt-erlang	https://github.com/jj1bdx/sfmt-erlang	https://github.com/jj1bdx/sfmt-erlang	SFMT pseudo random number generator for Erlang.
-shotgun	https://github.com/inaka/shotgun	https://github.com/inaka/shotgun	better than just a gun
+sheriff	https://github.com/extend/sheriff	http://ninenines.eu	Parse transform for type based validation.
 sqerl	https://github.com/hairyhum/sqerl	https://github.com/hairyhum/sqerl	An Erlang-flavoured SQL DSL
 swab	https://github.com/crownedgrouse/swab	https://github.com/crownedgrouse/swab	General purpose buffer handling module
 sync	https://github.com/rustyio/sync	https://github.com/rustyio/sync	On-the-fly recompiling and reloading in Erlang.

+ 3 - 3
packages.v1.txt

@@ -1,4 +1,4 @@
-apns4erl	https://github.com/inaka/apns4erl	http://inaka.github.com/apns4erl	Apple Push Notification Server for Erlang
+apns	https://github.com/inaka/apns4erl	http://inaka.github.com/apns4erl	Apple Push Notification Server for Erlang
 cake	https://github.com/darach/cake-erl	https://github.com/darach/cake-erl	Really simple terminal colorization
 classifier	https://github.com/inaka/classifier	https://github.com/inaka/classifier	An Erlang Bayesian Filter and Text Classifier
 cowboy	https://github.com/ninenines/cowboy	http://ninenines.eu	Small, fast and modular HTTP server.
@@ -32,6 +32,7 @@ ibrowse	https://github.com/cmullaparthi/ibrowse	https://github.com/cmullaparthi/
 itweet	https://github.com/inaka/itweet	http://inaka.github.com/itweet/	Twitter Stream API on ibrowse
 jiffy	https://github.com/davisp/jiffy	https://github.com/davisp/jiffy	JSON NIFs for Erlang.
 jiffy_v	https://github.com/shizzard/jiffy-v	https://github.com/shizzard/jiffy-v	JSON validation utility
+jobs	https://github.com/esl/jobs	https://github.com/esl/jobs	a Job scheduler for load regulation
 jsx	https://github.com/talentdeficit/jsx	https://github.com/talentdeficit/jsx	An Erlang application for consuming, producing and manipulating JSON.
 katja	https://github.com/nifoc/katja	https://github.com/nifoc/katja	A simple Riemann client written in Erlang.
 lager	https://github.com/basho/lager	https://github.com/basho/lager	A logging framework for Erlang/OTP.
@@ -45,12 +46,11 @@ poolboy	https://github.com/devinus/poolboy	https://github.com/devinus/poolboy	A
 ptrackerl	https://github.com/inaka/ptrackerl	https://github.com/inaka/ptrackerl	Pivotal Tracker API Client written in Erlang
 qdate	https://github.com/choptastic/qdate	https://github.com/choptastic/qdate	Date, time, and timezone parsing, formatting, and conversion for Erlang.
 ranch	https://github.com/ninenines/ranch	http://ninenines.eu	Socket acceptor pool for TCP protocols.
-rec2json	https://github.com/lordnull/rec2json	https://github.com/lordnull/rec2json	Compile erlang record definitions into modules to convert them to/from json easily.
 recon	https://github.com/ferd/recon	https://github.com/ferd/recon	Collection of functions and scripts to debug Erlang in production.
 record_info	https://github.com/bipthelin/erlang-record_info	https://github.com/bipthelin/erlang-record_info	Convert between record and proplist
 resource_discovery	https://github.com/erlware/resource_discovery	http://erlware.org/	An application used to dynamically discover resources present in an Erlang node cluster.
 sfmt-erlang	https://github.com/jj1bdx/sfmt-erlang	https://github.com/jj1bdx/sfmt-erlang	SFMT pseudo random number generator for Erlang.
-shotgun	https://github.com/inaka/shotgun	https://github.com/inaka/shotgun	better than just a gun
+sheriff	https://github.com/extend/sheriff	http://ninenines.eu	Parse transform for type based validation.
 sqerl	https://github.com/hairyhum/sqerl	https://github.com/hairyhum/sqerl	An Erlang-flavoured SQL DSL
 swab	https://github.com/crownedgrouse/swab	https://github.com/crownedgrouse/swab	General purpose buffer handling module
 sync	https://github.com/rustyio/sync	https://github.com/rustyio/sync	On-the-fly recompiling and reloading in Erlang.

+ 3 - 3
packages.v2.tsv

@@ -1,4 +1,4 @@
-apns4erl	git	https://github.com/inaka/apns4erl	1.0.4	http://inaka.github.com/apns4erl	Apple Push Notification Server for Erlang
+apns	git	https://github.com/inaka/apns4erl	1.0.4	http://inaka.github.com/apns4erl	Apple Push Notification Server for Erlang
 cake	git	https://github.com/darach/cake-erl	v0.1.2	https://github.com/darach/cake-erl	Really simple terminal colorization
 classifier	git	https://github.com/inaka/classifier	master	https://github.com/inaka/classifier	An Erlang Bayesian Filter and Text Classifier
 cowboy	git	https://github.com/ninenines/cowboy	1.0.1	http://ninenines.eu	Small, fast and modular HTTP server.
@@ -32,6 +32,7 @@ ibrowse	git	https://github.com/cmullaparthi/ibrowse	v4.1.1	https://github.com/cm
 itweet	git	https://github.com/inaka/itweet	v2.0	http://inaka.github.com/itweet/	Twitter Stream API on ibrowse
 jiffy	git	https://github.com/davisp/jiffy	master	https://github.com/davisp/jiffy	JSON NIFs for Erlang.
 jiffy_v	git	https://github.com/shizzard/jiffy-v	0.3.3	https://github.com/shizzard/jiffy-v	JSON validation utility
+jobs	git	https://github.com/esl/jobs	0.3	https://github.com/esl/jobs	a Job scheduler for load regulation
 jsx	git	https://github.com/talentdeficit/jsx	master	https://github.com/talentdeficit/jsx	An Erlang application for consuming, producing and manipulating JSON.
 katja	git	https://github.com/nifoc/katja	master	https://github.com/nifoc/katja	A simple Riemann client written in Erlang.
 lager	git	https://github.com/basho/lager	master	https://github.com/basho/lager	A logging framework for Erlang/OTP.
@@ -45,12 +46,11 @@ poolboy	git	https://github.com/devinus/poolboy	master	https://github.com/devinus
 ptrackerl	git	https://github.com/inaka/ptrackerl	master	https://github.com/inaka/ptrackerl	Pivotal Tracker API Client written in Erlang
 qdate	git	https://github.com/choptastic/qdate	0.4.0	https://github.com/choptastic/qdate	Date, time, and timezone parsing, formatting, and conversion for Erlang.
 ranch	git	https://github.com/ninenines/ranch	1.1.0	http://ninenines.eu	Socket acceptor pool for TCP protocols.
-rec2json	git	https://github.com/lordnull/rec2json	master	https://github.com/lordnull/rec2json	Compile erlang record definitions into modules to convert them to/from json easily.
 recon	git	https://github.com/ferd/recon	2.2.1	https://github.com/ferd/recon	Collection of functions and scripts to debug Erlang in production.
 record_info	git	https://github.com/bipthelin/erlang-record_info	master	https://github.com/bipthelin/erlang-record_info	Convert between record and proplist
 resource_discovery	git	https://github.com/erlware/resource_discovery	master	http://erlware.org/	An application used to dynamically discover resources present in an Erlang node cluster.
 sfmt-erlang	git	https://github.com/jj1bdx/sfmt-erlang	master	https://github.com/jj1bdx/sfmt-erlang	SFMT pseudo random number generator for Erlang.
-shotgun	git	https://github.com/inaka/shotgun	0.1.0	https://github.com/inaka/shotgun	better than just a gun
+sheriff	git	https://github.com/extend/sheriff	master	http://ninenines.eu	Parse transform for type based validation.
 sqerl	git	https://github.com/hairyhum/sqerl	master	https://github.com/hairyhum/sqerl	An Erlang-flavoured SQL DSL
 swab	git	https://github.com/crownedgrouse/swab	master	https://github.com/crownedgrouse/swab	General purpose buffer handling module
 sync	git	https://github.com/rustyio/sync	master	https://github.com/rustyio/sync	On-the-fly recompiling and reloading in Erlang.

+ 13 - 7
plugins/c_src.mk

@@ -2,7 +2,6 @@
 # This file is part of erlang.mk and subject to the terms of the ISC License.
 
 .PHONY: clean-c_src distclean-c_src-env
-# todo
 
 # Configuration.
 
@@ -50,7 +49,11 @@ link_verbose = $(link_verbose_$(V))
 ifeq ($(wildcard $(C_SRC_DIR)),)
 else ifneq ($(wildcard $(C_SRC_DIR)/Makefile),)
 app::
-	$(MAKE) -C $(C_SRC_DIR)
+	$(MAKE) -C $(C_SRC_DIR) \
+		CFLAGS="$(CFLAGS)" \
+		CXXFLAGS="$(CXXFLAGS)" \
+		LDLIBS="$(LDLIBS)" \
+		LDFLAGS="$(LDFLAGS)"
 
 clean::
 	$(MAKE) -C $(C_SRC_DIR) clean
@@ -80,6 +83,14 @@ $(C_SRC_OUTPUT): $(OBJECTS)
 %.o: %.cpp
 	$(COMPILE_CPP) $(OUTPUT_OPTION) $<
 
+clean:: clean-c_src
+
+clean-c_src:
+	$(gen_verbose) rm -f $(C_SRC_OUTPUT) $(OBJECTS)
+
+endif
+
+ifneq ($(wildcard $(C_SRC_DIR)),)
 $(C_SRC_ENV):
 	@$(ERL) -eval "file:write_file(\"$(C_SRC_ENV)\", \
 		io_lib:format( \
@@ -91,11 +102,6 @@ $(C_SRC_ENV):
 			code:lib_dir(erl_interface, lib)])), \
 		halt()."
 
-clean:: clean-c_src
-
-clean-c_src:
-	$(gen_verbose) rm -f $(C_SRC_OUTPUT) $(OBJECTS)
-
 distclean:: distclean-c_src-env
 
 distclean-c_src-env: