forked from enlightenment/edi
build: Add support for Go building
This commit is contained in:
parent
e20fa8bff9
commit
5e318be09c
1
NEWS
1
NEWS
|
@ -8,6 +8,7 @@ Features:
|
|||
* Added split-view option for editors.
|
||||
* Updated project wizard and added new project templates.
|
||||
* Include EFL examples in project wizard.
|
||||
* Add support for Go projects.
|
||||
* Improved debugging support.
|
||||
* Added edi_scm helper command.
|
||||
* Replace all in project.
|
||||
|
|
|
@ -12,6 +12,7 @@ extern Edi_Build_Provider _edi_build_provider_cmake;
|
|||
extern Edi_Build_Provider _edi_build_provider_cargo;
|
||||
extern Edi_Build_Provider _edi_build_provider_python;
|
||||
extern Edi_Build_Provider _edi_build_provider_meson;
|
||||
extern Edi_Build_Provider _edi_build_provider_go;
|
||||
|
||||
EAPI Edi_Build_Provider *edi_build_provider_for_project_get()
|
||||
{
|
||||
|
@ -31,6 +32,8 @@ EAPI Edi_Build_Provider *edi_build_provider_for_project_path_get(const char *pat
|
|||
return &_edi_build_provider_python;
|
||||
if (_edi_build_provider_meson.path_supported_is(path))
|
||||
return &_edi_build_provider_meson;
|
||||
if (_edi_build_provider_go.path_supported_is(path))
|
||||
return &_edi_build_provider_go;
|
||||
if (_edi_build_provider_make.path_supported_is(path))
|
||||
return &_edi_build_provider_make;
|
||||
|
||||
|
@ -49,6 +52,8 @@ EAPI Edi_Build_Provider *edi_build_provider_for_id_get(const char *id)
|
|||
return &_edi_build_provider_python;
|
||||
if (!strcmp("meson", id))
|
||||
return &_edi_build_provider_meson;
|
||||
if (!strcmp("go", id))
|
||||
return &_edi_build_provider_go;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
#ifdef HAVE_CONFIG
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
#include <Ecore.h>
|
||||
#include <Ecore_File.h>
|
||||
|
||||
#include "Edi.h"
|
||||
|
||||
#include "edi_private.h"
|
||||
|
||||
static Eina_Bool
|
||||
_go_project_supported(const char *path)
|
||||
{
|
||||
Eina_List *files, *l;
|
||||
const char *name;
|
||||
|
||||
files = ecore_file_ls(path);
|
||||
|
||||
EINA_LIST_FOREACH(files, l, name)
|
||||
{
|
||||
if (strlen(name) < 4)
|
||||
continue;
|
||||
|
||||
if (strstr(name, ".go"))
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_go_file_hidden_is(const char *file)
|
||||
{
|
||||
if (!file || strlen(file) == 0)
|
||||
return EINA_FALSE;
|
||||
|
||||
if (!strcmp(ecore_file_file_get(file), "_obj") || !strcmp(ecore_file_file_get(file), "target") ||
|
||||
eina_str_has_extension(file, ".so"))
|
||||
return EINA_TRUE;
|
||||
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_go_project_runnable_is(const char *path EINA_UNUSED)
|
||||
{
|
||||
if (!path || !path[0])
|
||||
return EINA_FALSE;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
_go_build(void)
|
||||
{
|
||||
if (chdir(edi_project_get()) == 0)
|
||||
edi_exe_notify("edi_build", "go build");
|
||||
}
|
||||
|
||||
static void
|
||||
_go_test(void)
|
||||
{
|
||||
if (chdir(edi_project_get()) == 0)
|
||||
edi_exe_notify("edi_test", "go test -v ./...");
|
||||
}
|
||||
|
||||
static void
|
||||
_go_run(const char *path EINA_UNUSED, const char *args EINA_UNUSED)
|
||||
{
|
||||
char *full_cmd;
|
||||
int full_len;
|
||||
|
||||
if (!path) return;
|
||||
if (chdir(edi_project_get()) !=0)
|
||||
ERR("Could not chdir");
|
||||
|
||||
full_len = strlen(path) + 8;
|
||||
if (args)
|
||||
full_len += strlen(args);
|
||||
full_cmd = malloc(sizeof(char) * (full_len + 1));
|
||||
snprintf(full_cmd, full_len + 1, "go run %s %s", path, args?args:"");
|
||||
|
||||
ecore_exe_pipe_run(full_cmd, ECORE_EXE_PIPE_READ_LINE_BUFFERED | ECORE_EXE_PIPE_READ |
|
||||
ECORE_EXE_PIPE_ERROR_LINE_BUFFERED | ECORE_EXE_PIPE_ERROR |
|
||||
ECORE_EXE_PIPE_WRITE | ECORE_EXE_USE_SH, NULL);
|
||||
|
||||
free(full_cmd);
|
||||
}
|
||||
|
||||
static void
|
||||
_go_clean(void)
|
||||
{
|
||||
if (chdir(edi_project_get()) == 0)
|
||||
edi_exe_notify("edi_clean", "go clean");
|
||||
}
|
||||
|
||||
Edi_Build_Provider _edi_build_provider_go =
|
||||
{
|
||||
"go",
|
||||
_go_project_supported,
|
||||
_go_file_hidden_is,
|
||||
_go_project_runnable_is,
|
||||
_go_build,
|
||||
_go_test,
|
||||
_go_run,
|
||||
_go_clean
|
||||
};
|
|
@ -8,6 +8,7 @@ src = files([
|
|||
'edi_build_provider_make.c',
|
||||
'edi_build_provider_meson.c',
|
||||
'edi_build_provider_python.c',
|
||||
'edi_build_provider_go.c',
|
||||
'edi_builder.c',
|
||||
'edi_builder.h',
|
||||
'edi_create.c',
|
||||
|
|
Loading…
Reference in New Issue