build: Split make from cmake so we can specialise better

This commit is contained in:
Andy Williams 2017-02-18 22:19:17 +00:00
parent 7735a90cc0
commit b5c061bc4d
4 changed files with 85 additions and 13 deletions

View File

@ -22,6 +22,7 @@ includesdir = $(includedir)/edi-@VMAJ@
libedi_la_SOURCES = \
edi_private.h \
edi_build_provider_make.c \
edi_build_provider_cmake.c \
edi_build_provider_python.c \
edi_build_provider.c \
edi_builder.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_cmake;
extern Edi_Build_Provider _edi_build_provider_python;
EAPI Edi_Build_Provider *edi_build_provider_for_project_get()
@ -22,6 +23,8 @@ 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_cmake.path_supported_is(path))
return &_edi_build_provider_cmake;
if (_edi_build_provider_python.path_supported_is(path))
return &_edi_build_provider_python;
@ -33,6 +36,10 @@ EAPI Edi_Build_Provider *edi_build_provider_for_id_get(const char *id)
{
if (!strcmp("make", id))
return &_edi_build_provider_make;
if (!strcmp("cmake", id))
return &_edi_build_provider_cmake;
if (!strcmp("python", id))
return &_edi_build_provider_python;
return NULL;
}

View File

@ -0,0 +1,77 @@
#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
_cmake_project_supported(const char *path)
{
return _relative_path_exists(path, "CMakeLists.txt");
}
static Eina_Bool
_cmake_file_hidden_is(const char *file)
{
if (!file || strlen(file) == 0)
return EINA_FALSE;
if (eina_str_has_extension(file, ".o") || eina_str_has_extension(file, ".so") ||
eina_str_has_extension(file, ".lo"))
return EINA_TRUE;
if (eina_str_has_extension(file, ".a") || eina_str_has_extension(file, ".la"))
return EINA_TRUE;
return EINA_FALSE;
}
static void
_cmake_build(void)
{
chdir(edi_project_get());
ecore_exe_pipe_run("mkdir -p build && cd build && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .. && make && cd ..",
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);
}
static void
_cmake_test(void)
{
chdir(edi_project_get());
ecore_exe_pipe_run("env CK_VERBOSITY=verbose make check", 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);
}
static void
_cmake_clean(void)
{
chdir(edi_project_get());
ecore_exe_pipe_run("make clean", 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_cmake =
{"cmake", _cmake_project_supported, _cmake_file_hidden_is,
_cmake_build, _cmake_test, _cmake_clean};

View File

@ -28,7 +28,6 @@ _make_project_supported(const char *path)
{
return _relative_path_exists(path, "Makefile") ||
_relative_path_exists(path, "configure") ||
_relative_path_exists(path, "CMakeLists.txt") || // TODO move this one to a cmake file
_relative_path_exists(path, "autogen.sh");
}
@ -66,16 +65,6 @@ _make_build_configure(void)
ECORE_EXE_PIPE_WRITE | ECORE_EXE_USE_SH, NULL);
}
static void
_make_build_cmake(void)
{
chdir(edi_project_get());
ecore_exe_pipe_run("mkdir -p build && cd build && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .. && make && cd ..",
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);
}
static void
_make_build_autogen(void)
{
@ -93,8 +82,6 @@ _make_build(void)
_make_build_make();
else if (edi_project_file_exists("configure"))
_make_build_configure();
else if (edi_project_file_exists("CMakeLists.txt"))
_make_build_cmake();
else if (edi_project_file_exists("autogen.sh"))
_make_build_autogen();
}