Permalink
Browse files

fix broken rebar build

In commit cb49390 I broke the ability for yaws to be used as a rebar
dependency for other projects. Move src/yaws.app.src.in back to
src/yaws.app.src. Move the code in rebar.config.script to
src/yaws.app.src.script file to process the app dependencies for
src/yaws.app.src. Change src/Makefile to process app dependencies when
creating ebin/yaws.app.
  • Loading branch information...
1 parent 580a0f5 commit e549f866e9a0021b85303f2c884662d14e982fd6 @vinoski vinoski committed Apr 29, 2014
Showing with 39 additions and 23 deletions.
  1. +1 −1 configure.in
  2. +1 −0 include.mk.in
  3. +4 −22 rebar.config.script
  4. +3 −0 src/Makefile
  5. 0 src/{yaws.app.src.in → yaws.app.src}
  6. +30 −0 src/yaws.app.src.script
View
@@ -375,7 +375,7 @@ dnl pkg-config support
AC_SUBST(YAWS_VSN)
AC_CONFIG_FILES([include.mk])
-AC_CONFIG_FILES([src/yaws_charset.hrl src/yaws_appdeps.hrl src/yaws.app.src])
+AC_CONFIG_FILES([src/yaws_charset.hrl src/yaws_appdeps.hrl])
AC_CONFIG_FILES([test/support/include.mk test/support/include.sh])
AC_CONFIG_FILES([yaws.pc])
View
@@ -28,6 +28,7 @@ HAVE_SENDFILE = @HAVE_SENDFILE@
HAVE_ERLANG_SENDFILE = @HAVE_ERLANG_SENDFILE@
BITS_SUPPORT = @BITS_SUPPORT@
HAVE_CRYPTO_HASH = @HAVE_CRYPTO_HASH@
+APPDEPS = @APPDEPS@
ifdef debug
ERLC_FLAGS+=-Ddebug
View
@@ -1,13 +1,15 @@
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ft=erlang ts=4 sw=4 et
+Dir = filename:dirname(SCRIPT),
+
%% generate a default test/t11/src/srcdir_test.hrl file so rebar can
%% compile the tests
-ok = file:write_file("test/t11/src/srcdir_test.hrl",
+ok = file:write_file(filename:join(Dir, "test/t11/src/srcdir_test.hrl"),
<<"-define(SRCDIR_VERSION, \"1.0\").\n">>),
%% generate a charset include file
-ok = file:write_file("src/yaws_charset.hrl",
+ok = file:write_file(filename:join(Dir, "src/yaws_charset.hrl"),
case os:getenv("YAWS_CHARSET") of
false ->
<<"-define(YAWS_CHARSET, undefined).\n">>;
@@ -16,26 +18,6 @@ ok = file:write_file("src/yaws_charset.hrl",
Charset, <<"\").\n">>]
end),
-%% generate src/yaws.app.src file from src/yaws.app.src.in and
-%% src/yaws_appdeps.hrl from src/yaws_appdeps.hrl.in
-AppDeps = case os:getenv("YAWS_APPDEPS") of
- false ->
- "";
- AppDeps0 ->
- case string:tokens(AppDeps0, " ,") of
- [] ->
- "";
- AppDepsList ->
- ","++string:join(AppDepsList, ",")
- end
- end,
-{ok, AppBin0} = file:read_file("src/yaws.app.src.in"),
-AppBin = binary:replace(AppBin0, <<"@APPDEPS@">>, list_to_binary(AppDeps)),
-ok = file:write_file("src/yaws.app.src", AppBin),
-{ok, AppHrl0} = file:read_file("src/yaws_appdeps.hrl.in"),
-AppHrl = binary:replace(AppHrl0, <<"@APPDEPS@">>, list_to_binary(AppDeps)),
-ok = file:write_file("src/yaws_appdeps.hrl", AppHrl),
-
SoapDeps = [{erlsom, ".*", {git, "git://github.com/willemdj/erlsom.git", {branch, "master"}}},
{xmlrpc, ".*", {git, "git://github.com/rwbr/exmlrpc.git", {branch, "master"}}}],
View
@@ -78,6 +78,9 @@ $(EBIN_FILES) : ../include/yaws.hrl ../include/yaws_api.hrl
../ebin/yaws_sendfile.$(EMULATOR): yaws_configure.hrl
../ebin/yaws.$(EMULATOR): yaws_appdeps.hrl
+../ebin/yaws.app: yaws.app.src
+ perl -pe 's/\@APPDEPS\@/'$(APPDEPS)'/;' $< | perl -e $(APPSCRIPT) "$(VSN)" $(MODULES) > $@
+
yaws_generated.erl: yaws_generated.template ../vsn.mk
$(MAKE) IS_LOCAL_INSTALL=true gen_yaws_generated
File renamed without changes.
@@ -0,0 +1,30 @@
+%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ft=erlang ts=4 sw=4 et
+
+AppDeps = case os:getenv("YAWS_APPDEPS") of
+ false ->
+ [];
+ AppDeps0 ->
+ string:tokens(AppDeps0, " ,")
+ end,
+AppDepsList = ","++string:join(AppDeps, ","),
+
+%% generate src/yaws_appdeps.hrl from src/yaws_appdeps.hrl.in
+Dir = filename:dirname(SCRIPT),
+InFile = filename:join(Dir, "yaws_appdeps.hrl.in"),
+OutFile = filename:join(Dir, "yaws_appdeps.hrl"),
+{ok, AppHrl0} = file:read_file(InFile),
+AppHrl = binary:replace(AppHrl0, <<"@APPDEPS@">>, list_to_binary(AppDepsList)),
+ok = file:write_file(OutFile, AppHrl),
+
+%% replace @APPDEPS@ in application dependencies with any apps specified in
+%% the YAWS_APPDEPS OS env var
+[{application,yaws,Cfg}] = CONFIG,
+{applications,Apps0} = lists:keyfind(applications, 1, Cfg),
+Apps = lists:flatmap(fun('stdlib@APPDEPS@') ->
+ [stdlib]++[list_to_atom(A) || A <- AppDeps];
+ (A) ->
+ [A]
+ end, Apps0),
+[{application,yaws,lists:keyreplace(applications, 1, Cfg,
+ {applications, Apps})}].

0 comments on commit e549f86

Please sign in to comment.