diff options
author | Philip Chimento <philip@endlessm.com> | 2013-04-10 12:17:07 +0100 |
---|---|---|
committer | P. F. Chimento <philip.chimento@gmail.com> | 2013-04-17 17:14:21 +0200 |
commit | 408f93ec2327a8647030139a2e6f295e8b2c8de1 (patch) | |
tree | c0a796adc7ca6981b8eb0b53e8c21b5101dd2962 /endless | |
parent | 5299f7acf85200a46679334a6bd230d4e2101b7f (diff) |
Skeleton build system to build a shared library
Builds a dummy shared library that exports one symbol for testing,
eos_hello_sample_function().
[#1]
Diffstat (limited to 'endless')
-rw-r--r-- | endless/Makefile.am | 27 | ||||
-rw-r--r-- | endless/apiversion.h | 12 | ||||
-rw-r--r-- | endless/endless.h | 25 | ||||
-rw-r--r-- | endless/enums.h | 12 | ||||
-rw-r--r-- | endless/hello.c | 69 | ||||
-rw-r--r-- | endless/macros.h | 12 | ||||
-rw-r--r-- | endless/types.h | 16 |
7 files changed, 173 insertions, 0 deletions
diff --git a/endless/Makefile.am b/endless/Makefile.am new file mode 100644 index 0000000..92c9ab3 --- /dev/null +++ b/endless/Makefile.am @@ -0,0 +1,27 @@ +# Copyright 2013 Endless Mobile, Inc. + +endless_public_installed_headers = endless/endless.h + +endless_private_installed_headers = \ + endless/apiversion.h \ + endless/enums.h \ + endless/macros.h \ + endless/types.h + +endless_library_sources = \ + endless/hello.c + +# Endless GUI library +lib_LTLIBRARIES = libendless-@EOS_SDK_API_VERSION@.la +libendless_@EOS_SDK_API_VERSION@_la_SOURCES = \ + $(endless_public_installed_headers) \ + $(endless_private_installed_headers) \ + $(endless_library_sources) +libendless_@EOS_SDK_API_VERSION@_la_CPPFLAGS = \ + @EOS_SDK_CFLAGS@ \ + -DCOMPILING_EOS_SDK +libendless_@EOS_SDK_API_VERSION@_la_CFLAGS = $(AM_CFLAGS) +libendless_@EOS_SDK_API_VERSION@_la_LIBADD = @EOS_SDK_LIBS@ +libendless_@EOS_SDK_API_VERSION@_la_LDFLAGS = \ + -version-info @EOS_SDK_LT_VERSION_INFO@ \ + -export-symbols-regex "^eos_" diff --git a/endless/apiversion.h b/endless/apiversion.h new file mode 100644 index 0000000..5b9b292 --- /dev/null +++ b/endless/apiversion.h @@ -0,0 +1,12 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#if !(defined(_EOS_SDK_INSIDE_ENDLESS_H) || defined(COMPILING_EOS_SDK)) +#error "Please do not include this header file directly." +#endif + +#ifndef API_VERSION_H +#define API_VERSION_H + +#define EOS_SDK_ALL_API_VERSIONS + +#endif /* API_VERSION_H */ diff --git a/endless/endless.h b/endless/endless.h new file mode 100644 index 0000000..84a33b0 --- /dev/null +++ b/endless/endless.h @@ -0,0 +1,25 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#ifndef ENDLESS_H +#define ENDLESS_H + +#include <glib.h> +#include <gio/gio.h> + +G_BEGIN_DECLS + +#define _EOS_SDK_INSIDE_ENDLESS_H + +/* Pull in other header files */ +#include "types.h" + +#undef _EOS_SDK_INSIDE_ENDLESS_H + +EOS_SDK_ALL_API_VERSIONS +gboolean eos_hello_sample_function (GFile *file, + GError **error); + +G_END_DECLS + +#endif + diff --git a/endless/enums.h b/endless/enums.h new file mode 100644 index 0000000..b85cde3 --- /dev/null +++ b/endless/enums.h @@ -0,0 +1,12 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#if !(defined(_EOS_SDK_INSIDE_ENDLESS_H) || defined(COMPILING_EOS_SDK)) +#error "Please do not include this header file directly." +#endif + +#ifndef EOS_ENUMS_H +#define EOS_ENUMS_H + +/* Shared typedefs for enumerations */ + +#endif /* EOS_ENUMS_H */ diff --git a/endless/hello.c b/endless/hello.c new file mode 100644 index 0000000..1db6f90 --- /dev/null +++ b/endless/hello.c @@ -0,0 +1,69 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#include <string.h> +#include <glib.h> +#include <gio/gio.h> + +#include <endless/endless.h> + +/** + * SECTION:hello + * @short_description: Sample skeleton function + * @title: Hello + * + * This is a sample skeleton function that says hello either to the terminal or + * a file. + */ + +/** + * eos_hello_sample_function: + * @file: (allow-none): #GFile to write to, or %NULL + * @error: (allow-none): Return location for a #GError, or %NULL to ignore. + * + * A sample API function to say hello with. Prints on the terminal if @file is + * %NULL, or else appends it to @file. + * + * Returns: %TRUE on success, %FALSE on error. + */ +gboolean +eos_hello_sample_function(GFile *file, + GError **error) +{ + char hello_string[] = "Hello, world!\n"; + GFileOutputStream *stream; + ssize_t write_count; + gboolean success; + + g_return_val_if_fail (G_IS_FILE (file) || file == NULL, FALSE); + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + + /* Print to terminal */ + if (file == NULL) + { + g_print ("%s", hello_string); + return TRUE; + } + + stream = g_file_append_to (file, + G_FILE_CREATE_NONE, + NULL, /* cancellable */ + error); + if(!stream) + return FALSE; + + write_count = g_output_stream_write (G_OUTPUT_STREAM (stream), + hello_string, + strlen (hello_string), + NULL, /* cancellable */ + error); + success = g_output_stream_close (G_OUTPUT_STREAM (stream), + NULL, /* cancellable */ + error); + g_object_unref (stream); + + if (write_count == -1 || !success) + return FALSE; + + return TRUE; +} + diff --git a/endless/macros.h b/endless/macros.h new file mode 100644 index 0000000..1a3fc44 --- /dev/null +++ b/endless/macros.h @@ -0,0 +1,12 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#if !(defined(_EOS_SDK_INSIDE_ENDLESS_H) || defined(COMPILING_EOS_SDK)) +#error "Please do not include this header file directly." +#endif + +#ifndef EOS_MACROS_H +#define EOS_MACROS_H + +/* Shared preprocessor macros */ + +#endif /* EOS_MACROS_H */ diff --git a/endless/types.h b/endless/types.h new file mode 100644 index 0000000..a572d7c --- /dev/null +++ b/endless/types.h @@ -0,0 +1,16 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#if !(defined(_EOS_SDK_INSIDE_ENDLESS_H) || defined(COMPILING_EOS_SDK)) +#error "Please do not include this header file directly." +#endif + +#ifndef EOS_TYPES_H +#define EOS_TYPES_H + +#include "enums.h" +#include "macros.h" +#include "apiversion.h" + +/* Shared typedefs for structures */ + +#endif /* EOS_TYPES_H */ |