Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

allow extra app dependencies for yaws.app to be configured

Yaws can depend on crypto for random numbers and hashes, and on the
compiler for .yaws pages. But the default yaws.app file specifies only
kernel and stdlib as application dependencies, since not all Yaws
deployments use crypto or compiler. Still, if a Yaws system uses crypto and
compiler without including them in the yaws.app file, building and
deploying an Erlang/OTP release for that system will fail.

Add --enable-crypto and --enable-compiler options to the configure script
to allow the user to add either or both of these applications to the
yaws.app file. Specifying the --enable-crypto option also causes the Yaws
startup code to start the crypto application; likewise for
--enable-compiler and the compiler application.

For rebar builds, enhance rebar.config.script to generate the same files
the configure script generates for any extra app dependencies. Setting the
YAWS_APPDEPS environment variable to a space- or comma-separated list of
addition applications to add to yaws.app, e.g.

YAWS_APPDEPS='crypto compiler'

causes rebar to add those apps to the generated yaws.app file and ensure
they're started before Yaws started.
  • Loading branch information...
commit cb493908da3561afc6e013b06e382a629d6a3b3e 1 parent 52e7b4c
Steve Vinoski vinoski authored
2  .gitignore
View
@@ -21,6 +21,8 @@ src/mime_types.erl
src/yaws_configure.hrl
src/yaws_generated.erl
src/yaws_charset.hrl
+src/yaws_appdeps.hrl
+src/yaws.app.src
test/ibrowse
test/ibrowse.tar.gz
test/support/include.mk
22 configure.in
View
@@ -54,6 +54,16 @@ fi
AC_SUBST(EPAM)
+APPDEPS=
+AC_ARG_ENABLE(crypto, AS_HELP_STRING([--enable-crypto], [adds crypto application to yaws.app file]))
+if test "x$enable_crypto" = "xyes"; then
+ APPDEPS=',crypto'
+fi
+AC_ARG_ENABLE(compiler, AS_HELP_STRING([--enable-compiler], [adds compiler application to yaws.app file]))
+if test "x$enable_compiler" = "xyes"; then
+ APPDEPS="${APPDEPS},compiler"
+fi
+AC_SUBST(APPDEPS)
dnl ----------------------------------------------------------------------
dnl
@@ -359,12 +369,14 @@ AC_SUBST(HAVE_CRYPTO_HASH)
YTOP=`pwd`
AC_SUBST(YTOP)
-AC_OUTPUT(include.mk)
-AC_OUTPUT(src/yaws_charset.hrl)
-AC_OUTPUT(test/support/include.mk)
-AC_OUTPUT(test/support/include.sh)
dnl pkg-config support
. ./vsn.mk
AC_SUBST(YAWS_VSN)
-AC_OUTPUT(yaws.pc)
+
+AC_CONFIG_FILES([include.mk])
+AC_CONFIG_FILES([src/yaws_charset.hrl src/yaws_appdeps.hrl src/yaws.app.src])
+AC_CONFIG_FILES([test/support/include.mk test/support/include.sh])
+AC_CONFIG_FILES([yaws.pc])
+
+AC_OUTPUT
21 rebar.config.script
View
@@ -16,6 +16,26 @@ 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"}}}],
@@ -80,4 +100,3 @@ Cfg1 = lists:keyreplace(erl_opts, 1, Cfg0, {erl_opts, ErlOpts2}),
Cfg2 = lists:keyreplace(port_env, 1, Cfg1, {port_env, PortEnv1}),
Cfg3 = lists:keyreplace(port_specs, 1, Cfg2, {port_specs, PortSpecs1}),
Cfg3.
-
2  src/Makefile
View
@@ -76,6 +76,7 @@ dav:
$(EBIN_FILES) : ../include/yaws.hrl ../include/yaws_api.hrl
../ebin/yaws_sendfile.$(EMULATOR): yaws_configure.hrl
+../ebin/yaws.$(EMULATOR): yaws_appdeps.hrl
yaws_generated.erl: yaws_generated.template ../vsn.mk
$(MAKE) IS_LOCAL_INSTALL=true gen_yaws_generated
@@ -91,7 +92,6 @@ mime_types.erl: yaws_charset.hrl ../priv/mime.types \
../ebin/yaws_generated.$(EMULATOR) ../ebin/mime_type_c.$(EMULATOR)
$(ERL) -noshell -pa ../ebin -s mime_type_c generate
-
debug:
$(MAKE) TYPE=debug
2  src/yaws.app.src → src/yaws.app.src.in
View
@@ -17,4 +17,4 @@
% {pam_use_acct, true}, % true | false
% {pam_use_sess, true} % true | false
]},
- {applications,[kernel,stdlib]}]}.
+ {applications,[kernel,stdlib@APPDEPS@]}]}.
16 src/yaws.erl
View
@@ -10,6 +10,7 @@
-include("../include/yaws.hrl").
-include("../include/yaws_api.hrl").
+-include("yaws_appdeps.hrl").
-include("yaws_debug.hrl").
-include_lib("kernel/include/file.hrl").
@@ -166,6 +167,7 @@
stringdate_to_datetime/1]).
start() ->
+ ok = start_app_deps(),
application:start(yaws, permanent).
stop() ->
@@ -185,8 +187,9 @@ start_embedded(DocRoot, SL, GL) when is_list(DocRoot),is_list(SL),is_list(GL) ->
start_embedded(DocRoot, SL, GL, "default").
start_embedded(DocRoot, SL, GL, Id)
when is_list(DocRoot), is_list(SL), is_list(GL) ->
+ ok = start_app_deps(),
{ok, SCList, GC, _} = yaws_api:embedded_start_conf(DocRoot, SL, GL, Id),
- ok = application:start(yaws),
+ ok = application:start(yaws, permanent),
yaws_config:add_yaws_soap_srv(GC),
yaws_api:setconf(GC, SCList),
ok.
@@ -209,7 +212,16 @@ create_sconf(DocRoot, SL) when is_list(DocRoot), is_list(SL) ->
SC = yaws_config:make_default_sconf(DocRoot, lkup(port, SL, undefined)),
setup_sconf(SL, SC).
-
+start_app_deps() ->
+ Deps = split_sep(?YAWS_APPDEPS, $,),
+ catch lists:foldl(fun(App0, Acc) ->
+ App = list_to_existing_atom(App0),
+ case application:start(App, permanent) of
+ ok -> Acc;
+ {error,{already_started,App}} -> Acc;
+ Else -> throw(Else)
+ end
+ end, ok, Deps).
%% Access functions for the GCONF and SCONF records.
gconf_yaws_dir (#gconf{yaws_dir = X}) -> X.
1  src/yaws_appdeps.hrl.in
View
@@ -0,0 +1 @@
+-define(YAWS_APPDEPS, "@APPDEPS@").
Please sign in to comment.
Something went wrong with that request. Please try again.