build: add trivial python project support

This commit is contained in:
Andy Williams 2017-02-07 00:05:06 +00:00
parent 011746c6cf
commit a053bb9757
3 changed files with 60 additions and 0 deletions

View File

@ -21,6 +21,7 @@ includesdir = $(includedir)/edi-@VMAJ@
libedi_la_SOURCES = \
edi_private.h \
edi_build_provider_make.c \
edi_build_provider_python.c \
edi_build_provider.c \
edi_builder.c \
edi_create.c \

View File

@ -8,6 +8,7 @@
#include "edi_private.h"
extern Edi_Build_Provider _edi_build_provider_make;
extern Edi_Build_Provider _edi_build_provider_python;
EAPI Edi_Build_Provider *edi_build_provider_for_project_get()
{
@ -22,6 +23,9 @@ EAPI Edi_Build_Provider *edi_build_provider_for_project_path_get(const char *pat
if (_edi_build_provider_make.path_supported_is(path))
return &_edi_build_provider_make;
if (_edi_build_provider_python.path_supported_is(path))
return &_edi_build_provider_python;
return NULL;
}

View File

@ -0,0 +1,55 @@
#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
_relative_path_exists(const char *base, const char *relative)
{
char *path;
Eina_Bool ret;
path = edi_path_append(base, relative);
ret = ecore_file_exists(path);
free(path);
return ret;
}
static Eina_Bool
_python_project_supported(const char *path)
{
return _relative_path_exists(path, "requirements.txt");
}
static Eina_Bool
_python_file_hidden_is(const char *file)
{
if (!file || strlen(file) == 0)
return EINA_FALSE;
if (eina_str_has_extension(file, ".pyc") || eina_str_has_extension(file, ".pyo"))
return EINA_TRUE;
return EINA_FALSE;
}
static void
_python_test(void)
{
chdir(edi_project_get());
ecore_exe_pipe_run("python -m unittest", 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);
}
Edi_Build_Provider _edi_build_provider_python =
{"python", _python_project_supported, _python_file_hidden_is,
NULL, _python_test, NULL};