Skip to content

Commit

Permalink
Add meson build
Browse files Browse the repository at this point in the history
  • Loading branch information
vtorri committed Jun 2, 2017
1 parent d1edd1a commit bede0f1
Show file tree
Hide file tree
Showing 5 changed files with 233 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cross_i686_w64_mingw32.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[binaries]
c = 'i686-w64-mingw32-gcc.exe'
ar = 'ar.exe'
strip = 'strip.exe'
pkgconfig = "pkg-config.exe"

[properties]
c_args = ['-DDLL_EXPORT']

[host_machine]
system = 'windows'
cpu_family = 'x86'
cpu = 'i686'
endian = 'little'
5 changes: 5 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
project('echart', 'c')
srclib = ['src/lib/Echart.h', 'src/lib/echart_main.c']
einadep = dependency('eina')
evasdep = dependency('evas')
shared_library('libechart', srclib, c_args : '-DECHART_BUILD', dependencies : [einadep, evasdep])
55 changes: 55 additions & 0 deletions src/lib/Echart.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* Echart - Chart rendering library
* Copyright (C) 2017 Vincent Torri
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef ECHART_H
#define ECHART_H

#ifdef EAPI
# undef EAPI
#endif

#ifdef _WIN32
# ifdef ECHART_BUILD
# ifdef DLL_EXPORT
# define EAPI __declspec(dllexport)
# else
# define EAPI
# endif
# else
# define EAPI __declspec(dllimport)
# endif
#else
#warning UNIX
# ifdef __GNUC__
# if __GNUC__ >= 4
# define EAPI __attribute__ ((visibility("default")))
# else
# define EAPI
# endif
# else
# define EAPI
# endif
#endif

EAPI int echart_init(void);
EAPI int echart_shutdown(void);

#undef EAPI
#define EAPI

#endif
105 changes: 105 additions & 0 deletions src/lib/echart_main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/* Echart - Chart rendering library
* Copyright (C) 2017 Vincent Torri
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* If not, see <http://www.gnu.org/licenses/>.
*/

#include <stdio.h>

#include <Eina.h>
#include <Evas.h>

#include "Echart.h"
#include "echart_private.h"

/*============================================================================*
* Local *
*============================================================================*/

/**
* @cond LOCAL
*/

static int _echart_init_count = 0;

/**
* @endcond
*/

/*============================================================================*
* Global *
*============================================================================*/

int echart_log_dom_global = -1;

/*============================================================================*
* API *
*============================================================================*/

EAPI int
echart_init(void)
{
if (++_echart_init_count != 1)
return _echart_init_count;

if (!eina_init())
{
fprintf(stderr, "Echart: Could not initialize Eina.\n");
return --_echart_init_count;
}

echart_log_dom_global = eina_log_domain_register("echart",
ECHART_DEFAULT_LOG_COLOR);
if (echart_log_dom_global < 0)
{
EINA_LOG_ERR("Echart: Could not register log domain 'echart'.");
goto shutdown_eina;
}

if (!evas_init())
{
ERR("Could not initialize Evas.");
goto unregister_log_domain;
}

return _echart_init_count;

unregister_log_domain:
eina_log_domain_unregister(echart_log_dom_global);
echart_log_dom_global = -1;
shutdown_eina:
eina_shutdown();

return --_echart_init_count;
}

EAPI int
echart_shutdown(void)
{
if (_echart_init_count <= 0)
{
ERR("Init count not greater than 0 in shutdown.");
return 0;
}
if (--_echart_init_count != 0)
return _echart_init_count;

evas_shutdown();
eina_log_domain_unregister(echart_log_dom_global);
echart_log_dom_global = -1;
eina_shutdown();

return _echart_init_count;
}
54 changes: 54 additions & 0 deletions src/lib/echart_private.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* Echart - Chart rendering library
* Copyright (C) 2017 Vincent Torri
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef ECHART_MAIN_H
#define ECHART_MAIN_H

extern int echart_log_dom_global;

#ifdef ECHART_DEFAULT_LOG_COLOR
# undef ECHART_DEFAULT_LOG_COLOR
#endif
#define ECHART_DEFAULT_LOG_COLOR EINA_COLOR_CYAN

#ifdef ERR
# undef ERR
#endif
#define ERR(...) EINA_LOG_DOM_ERR(echart_log_dom_global, __VA_ARGS__)

#ifdef DBG
# undef DBG
#endif
#define DBG(...) EINA_LOG_DOM_DBG(echart_log_dom_global, __VA_ARGS__)

#ifdef INF
# undef INF
#endif
#define INF(...) EINA_LOG_DOM_INFO(echart_log_dom_global, __VA_ARGS__)

#ifdef WRN
# undef WRN
#endif
#define WRN(...) EINA_LOG_DOM_WARN(echart_log_dom_global, __VA_ARGS__)

#ifdef CRIT
# undef CRIT
#endif
#define CRIT(...) EINA_LOG_DOM_CRIT(echart_log_dom_global, __VA_ARGS__)

#endif

0 comments on commit bede0f1

Please sign in to comment.