%-*-Mode:erlang;coding:utf-8;tab-width:4;c-basic-offset:4;indent-tabs-mode:()-*-
% ex: set ft=erlang fenc=utf-8 sts=4 ts=4 sw=4 et nomod:

{sys,
 [
  % typical defaults
  {profile, embedded},
  {incl_cond, derived},
  {mod_cond, all},
  {app_file, keep},
  {excl_sys_filters, ["^bin/.*",
                      "^erts.*/bin/(dialyzer|typer)",
                      "^erts.*/(doc|info|include|lib|man|src)"]},

  % keep beam files exposed for module loading of internal services
  {excl_archive_filters, [".*"]},

  % not including scope script temporary directories
  {incl_app_filters, ["^(ebin|include|priv)/"]},

  % Erlang dependencies
  {erts,
   [{incl_cond, derived}, {mod_cond, all}, {app_file, keep}]},
  {app, hipe,
   [{incl_cond, exclude}]},
  % sometimes services need the debug_info within OTP applications
  {debug_info, keep},
  %{app, debugger,
  % [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},

  {boot_rel, "cloudi"},
  % CloudI source code, including dependencies
  {app, cloudi_core,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_x_msgpack,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},

  % CloudI services, not automatically started
  % (i.e., started by the internal service configuration entries)
  {app, cloudi_service_api_batch,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_api_requests,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_cron,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_db_mysql,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_db_pgsql,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_filesystem,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_funnel,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_http_client,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_http_cowboy,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_http_cowboy1,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_http_elli,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_http_rest,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_map_reduce,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_monitoring,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_null,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_oauth1,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_queue,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_quorum,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_request_rate,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_router,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_send,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_shell,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_tcp,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_udp,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},
  {app, cloudi_service_validate,
   [{incl_cond, include}, {mod_cond, all}, {app_file, keep}]},

  % application directories
  {lib_dirs,
   [
    "lib",
    "external"
   ]},
  % application startup for release generation
  {rel, "cloudi", "@CLOUDI_CORE_RELEASE_VERSION@",
   [
    % CloudI
    cloudi_core,
    cloudi_x_msgpack
   ]
   @CLOUDI_CORE_RELEASE_OPTIONS@},
  {rel, "start_clean", "",
   [
    kernel,
    stdlib
   ]}
 ]}.

{target_dir, "rel/cloudi"}.

{overlay,
 [
  {mkdir, "etc"},
  {copy,
   "@builddir@/rel/files/vm.args",
   "etc/vm.args"},
  {copy,
   "@builddir@/rel/files/@CLOUDI_NODE_ARGS@",
   "etc/@CLOUDI_NODE_NAME@.args"},
  {copy,
   "@builddir@/rel/files/vm.config",
   "etc/vm.config"},
  {copy,
   "@builddir@/@CLOUDI_CONF@",
   "etc/cloudi.conf"},
  {mkdir, "bin"},
  {copy,
   "@builddir@/rel/files/erl",
   "{{erts_vsn}}/bin/erl"},
  {copy,
   "@builddir@/rel/files/nodetool",
   "bin/nodetool"},
  {copy,
   "@builddir@/rel/files/cloudi",
   "bin/cloudi"}
 ]}.
