2014-04-27 10:31:08 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* NOTE: Respecting header order is important for portability.
|
|
|
|
* Always put system first, then EFL, then your public header,
|
|
|
|
* and finally your private one. */
|
|
|
|
|
|
|
|
#include <Ecore_Getopt.h>
|
|
|
|
#include <Eio.h>
|
|
|
|
|
|
|
|
#include "Edi.h"
|
|
|
|
|
|
|
|
#include "edi_private.h"
|
|
|
|
|
|
|
|
#define COPYRIGHT "Copyright © 2014 Andy Williams <andy@andyilliams.me> and various contributors (see AUTHORS)."
|
2017-02-09 16:13:55 -08:00
|
|
|
#define EXIT_NOACTION -2
|
2014-04-27 10:31:08 -07:00
|
|
|
|
2015-02-03 14:31:17 -08:00
|
|
|
static int _exit_code;
|
|
|
|
|
2014-04-27 10:31:08 -07:00
|
|
|
static Eina_Bool
|
2014-05-19 11:19:12 -07:00
|
|
|
_exe_data(void *d EINA_UNUSED, int t EINA_UNUSED, void *event_info)
|
2014-04-27 10:31:08 -07:00
|
|
|
{
|
2014-05-19 11:19:12 -07:00
|
|
|
Ecore_Exe_Event_Data *ev;
|
2014-04-27 10:31:08 -07:00
|
|
|
Ecore_Exe_Event_Data_Line *el;
|
|
|
|
|
2014-05-19 11:19:12 -07:00
|
|
|
ev = event_info;
|
2014-04-27 10:31:08 -07:00
|
|
|
for (el = ev->lines; el && el->line; el++)
|
|
|
|
fprintf(stdout, "%s\n", el->line);
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2014-05-19 11:19:12 -07:00
|
|
|
_exe_del(void *d EINA_UNUSED, int t EINA_UNUSED, void *event_info EINA_UNUSED)
|
2014-04-27 10:31:08 -07:00
|
|
|
{
|
|
|
|
ecore_main_loop_quit();
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const Ecore_Getopt optdesc = {
|
|
|
|
"edi_build",
|
2015-02-02 14:07:02 -08:00
|
|
|
"%prog [options] [build|clean|create|test]",
|
2014-04-27 10:31:08 -07:00
|
|
|
PACKAGE_VERSION,
|
|
|
|
COPYRIGHT,
|
|
|
|
"BSD with advertisement clause",
|
|
|
|
"The EFL IDE builder",
|
|
|
|
EINA_TRUE,
|
|
|
|
{
|
|
|
|
ECORE_GETOPT_LICENSE('L', "license"),
|
|
|
|
ECORE_GETOPT_COPYRIGHT('C', "copyright"),
|
|
|
|
ECORE_GETOPT_VERSION('V', "version"),
|
|
|
|
ECORE_GETOPT_HELP('h', "help"),
|
|
|
|
ECORE_GETOPT_SENTINEL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-02-03 14:31:17 -08:00
|
|
|
static void
|
|
|
|
_edi_build_create_done_cb(const char *path, Eina_Bool success)
|
|
|
|
{
|
|
|
|
if (success)
|
2017-09-11 13:06:22 -07:00
|
|
|
fprintf(stdout, _("Project created at path %s\n"), path);
|
2015-02-03 14:31:17 -08:00
|
|
|
else
|
|
|
|
{
|
2017-09-11 13:06:22 -07:00
|
|
|
fprintf(stderr, _("Unable to create project at path %s\n"), path);
|
2015-02-03 14:31:17 -08:00
|
|
|
_exit_code = EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ecore_main_loop_quit();
|
|
|
|
elm_shutdown();
|
|
|
|
}
|
|
|
|
|
2017-02-09 16:13:55 -08:00
|
|
|
static void
|
|
|
|
_edi_build_print_start(Edi_Build_Provider *provider, const char *action)
|
|
|
|
{
|
2017-09-11 13:06:22 -07:00
|
|
|
printf(_("Building \"%s\" target [%s] using [%s].\n"), edi_project_name_get(), action, provider->id);
|
2017-02-09 16:13:55 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_edi_build_print_noop(Edi_Build_Provider *provider, const char *action)
|
|
|
|
{
|
2017-09-11 13:06:22 -07:00
|
|
|
printf(_("Target [%s] not supported for builder [%s].\n"), action, provider->id);
|
2017-02-09 16:13:55 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_edi_build_action_try(Edi_Build_Provider *provider, void (*action)(void), const char *name, const char *request)
|
|
|
|
{
|
|
|
|
if (strncmp(name, request, strlen(name)))
|
|
|
|
return EXIT_NOACTION;
|
|
|
|
|
|
|
|
if (action)
|
|
|
|
{
|
|
|
|
_edi_build_print_start(provider, name);
|
|
|
|
action();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_edi_build_print_noop(provider, name);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2015-02-03 14:31:17 -08:00
|
|
|
static void
|
|
|
|
_edi_build_create_start(int argc, int arg0, char **argv)
|
|
|
|
{
|
|
|
|
elm_init(argc, argv);
|
2017-05-28 13:24:24 -07:00
|
|
|
edi_create_efl_project(argv[arg0 + 1], argv[arg0 + 2], argv[arg0 + 3],
|
|
|
|
argv[arg0 + 4], argv[arg0 + 5], argv[arg0 + 6],
|
2015-02-03 14:31:17 -08:00
|
|
|
_edi_build_create_done_cb);
|
|
|
|
}
|
|
|
|
|
2014-04-27 10:31:08 -07:00
|
|
|
EAPI_MAIN int
|
2015-02-03 14:31:17 -08:00
|
|
|
main(int argc, char **argv)
|
2014-04-27 10:31:08 -07:00
|
|
|
{
|
2017-02-09 16:13:55 -08:00
|
|
|
int args, ret;
|
2014-11-09 06:08:52 -08:00
|
|
|
char path[PATH_MAX], *build_type = NULL;
|
2014-04-27 10:31:08 -07:00
|
|
|
Eina_Bool quit_option = EINA_FALSE;
|
2017-02-09 16:13:55 -08:00
|
|
|
Edi_Build_Provider *provider;
|
2014-04-27 10:31:08 -07:00
|
|
|
|
|
|
|
Ecore_Getopt_Value values[] = {
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(quit_option),
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(quit_option),
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(quit_option),
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(quit_option),
|
2014-04-27 14:31:36 -07:00
|
|
|
ECORE_GETOPT_VALUE_NONE
|
2014-04-27 10:31:08 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#if ENABLE_NLS
|
|
|
|
setlocale(LC_ALL, "");
|
|
|
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
|
|
|
bind_textdomain_codeset(PACKAGE, "UTF-8");
|
|
|
|
textdomain(PACKAGE);
|
|
|
|
#endif
|
|
|
|
|
2015-02-03 14:31:17 -08:00
|
|
|
_exit_code = EXIT_SUCCESS;
|
2014-04-27 10:31:08 -07:00
|
|
|
if (!ecore_init())
|
|
|
|
goto exit;
|
|
|
|
edi_init();
|
|
|
|
|
|
|
|
args = ecore_getopt_parse(&optdesc, values, argc, argv);
|
|
|
|
if (args < 0)
|
|
|
|
{
|
|
|
|
EINA_LOG_CRIT("Could not parse arguments.");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
else if (quit_option)
|
|
|
|
{
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2017-06-25 00:54:30 -07:00
|
|
|
if (!getcwd(path, PATH_MAX))
|
|
|
|
goto end;
|
2014-04-27 10:31:08 -07:00
|
|
|
edi_project_set(path);
|
|
|
|
|
2014-11-09 06:08:52 -08:00
|
|
|
if (args < argc)
|
|
|
|
build_type = argv[args];
|
|
|
|
if (!build_type)
|
|
|
|
build_type = "build";
|
|
|
|
|
2015-02-03 14:31:17 -08:00
|
|
|
if (!strncmp("create", build_type, 6))
|
|
|
|
{
|
2017-05-28 13:24:24 -07:00
|
|
|
if (argc - args != 7)
|
2015-02-03 14:31:17 -08:00
|
|
|
{
|
2017-09-11 13:06:22 -07:00
|
|
|
fprintf(stderr, _("create requires 6 additional parameters:\n"));
|
2017-05-28 13:24:24 -07:00
|
|
|
fprintf(stderr, " skeleton, parent_path, project_name, "
|
|
|
|
"project_url, creator_name, creator_email\n");
|
2015-02-03 14:31:17 -08:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
_edi_build_create_start(argc, args, argv);
|
|
|
|
|
|
|
|
ecore_main_loop_begin();
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2017-05-28 11:09:35 -07:00
|
|
|
if (!edi_builder_can_build())
|
|
|
|
{
|
2017-09-11 13:06:22 -07:00
|
|
|
fprintf(stderr, _("Cowardly refusing to build unknown project type.\n"));
|
2017-05-28 11:09:35 -07:00
|
|
|
ecore_shutdown();
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2017-02-09 16:13:55 -08:00
|
|
|
provider = edi_build_provider_for_project_get();
|
|
|
|
|
2014-05-19 11:19:12 -07:00
|
|
|
ecore_event_handler_add(ECORE_EXE_EVENT_DATA, _exe_data, NULL);
|
|
|
|
ecore_event_handler_add(ECORE_EXE_EVENT_ERROR, _exe_data, NULL);
|
2017-02-09 16:13:55 -08:00
|
|
|
ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _exe_del, NULL);
|
|
|
|
|
|
|
|
if (
|
|
|
|
((ret = _edi_build_action_try(provider, provider->clean, "clean", build_type)) == EXIT_NOACTION) &&
|
|
|
|
((ret = _edi_build_action_try(provider, provider->test, "test", build_type)) == EXIT_NOACTION) &&
|
2017-09-04 12:52:34 -07:00
|
|
|
((ret = _edi_build_action_try(provider, (void *)provider->build, "build", build_type)) == EXIT_NOACTION))
|
2014-11-09 06:08:52 -08:00
|
|
|
{
|
2017-09-11 13:06:22 -07:00
|
|
|
fprintf(stderr, _("Unrecognized build type - try build, clean, create or test.\n"));
|
2014-11-09 06:08:52 -08:00
|
|
|
goto end;
|
|
|
|
}
|
2017-02-09 16:13:55 -08:00
|
|
|
if (ret != EXIT_SUCCESS)
|
|
|
|
return ret;
|
2014-04-27 10:31:08 -07:00
|
|
|
ecore_main_loop_begin();
|
|
|
|
|
|
|
|
end:
|
|
|
|
edi_shutdown();
|
|
|
|
ecore_shutdown();
|
2015-02-03 14:31:17 -08:00
|
|
|
return _exit_code;
|
2014-04-27 10:31:08 -07:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|