diff options
author | P. F. Chimento <philip.chimento@gmail.com> | 2013-04-17 08:24:55 -0700 |
---|---|---|
committer | P. F. Chimento <philip.chimento@gmail.com> | 2013-04-17 08:24:55 -0700 |
commit | 5fd320085624acecbacb29e86f8f32b8702cc3e6 (patch) | |
tree | cc88c29eb7b77f06734fc383912fde0f575894b3 | |
parent | 5299f7acf85200a46679334a6bd230d4e2101b7f (diff) | |
parent | 7fc4090461ad888612491814e5a44aaf7e52d7ff (diff) |
Merge pull request #3 from ptomato/issues/1-build-system
Build system
34 files changed, 1145 insertions, 2 deletions
@@ -1,7 +1,89 @@ +# Build products +endless-0.pc +test/run-tests +test/smoke-tests/hello +Endless-0.gir +Endless-0.typelib + *.py[cod] # C extensions +*.o *.so +*.la +*.lo + +# Autotools droppings +.deps +.libs +stamp* +*.stamp +/Makefile +/Makefile.in +/aclocal.m4 +/autom4te.cache +/config.* +/configure +/depcomp +/install-sh +/libtool +/ltmain.sh +/missing +/m4/libtool.m4 +/m4/lt~obsolete.m4 +/m4/ltoptions.m4 +/m4/ltsugar.m4 +/m4/ltversion.m4 +.dirstamp + +# Gettext droppings +/ABOUT-NLS +/po/Makefile* +/po/POTFILES +/po/Rules-quot +/po/boldquot.sed +/po/en@boldquot.header +/po/en@quot.header +/po/eos-sdk.pot +/po/insert-header.sin +/po/quot.sed +/po/remove-potcdate.sed +/po/remove-potcdate.sin +/m4/codeset.m4 +/m4/fcntl-o.m4 +/m4/gettext.m4 +/m4/glibc21.m4 +/m4/glibc2.m4 +/m4/iconv.m4 +/m4/intdiv0.m4 +/m4/intldir.m4 +/m4/intl.m4 +/m4/intlmacosx.m4 +/m4/intmax.m4 +/m4/inttypes_h.m4 +/m4/inttypes-pri.m4 +/m4/lcmessage.m4 +/m4/lib-ld.m4 +/m4/lib-link.m4 +/m4/lib-prefix.m4 +/m4/lock.m4 +/m4/longlong.m4 +/m4/nls.m4 +/m4/po.m4 +/m4/printf-posix.m4 +/m4/progtest.m4 +/m4/size_max.m4 +/m4/stdint_h.m4 +/m4/threadlib.m4 +/m4/uintmax_t.m4 +/m4/visibility.m4 +/m4/wchar_t.m4 +/m4/wint_t.m4 +/m4/xsize.m4 + +# Gtk-doc +/gtk-doc.make +/m4/gtk-doc.m4 # Packages *.egg @@ -25,9 +107,11 @@ pip-log.txt .coverage .tox nosetests.xml +test-results.xml # Translations *.mo +*.gmo # Mr Developer .mr.developer.cfg diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..e483381 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,90 @@ +## Process this file with automake to produce Makefile.in + +# Copyright 2013 Endless Mobile, Inc. + +## ----------- +## Makefile.am +## ----------- +## Please keep this file well-commented. + +# Subdirectories where we also want to run make +SUBDIRS = po docs/reference/endless + +# Our Autoconf macros are kept in the m4/ directory +ACLOCAL_AMFLAGS = -I m4 + +# Extra files to distribute in the tarball +EXTRA_DIST = @EOS_SDK_API_NAME@.pc.in + +# Compiler flags +DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ +AM_CFLAGS = @STRICT_CFLAGS@ + +# Make sure to run Gtk-doc tests and build the introspection files when doing +# 'make distcheck' +DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --enable-introspection + +# Generated files that 'make clean' should erase +CLEANFILES = +DISTCLEANFILES = + +# # # LIBRARY # # # + +# Main Open Endless SDK library +include $(top_srcdir)/endless/Makefile.am + +# Public header files +endlessincludedir = $(includedir)/@EOS_SDK_API_NAME@ +nobase_endlessinclude_HEADERS = \ + $(endless_public_installed_headers) \ + $(endless_private_installed_headers) + +# Pkg-config file +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = @EOS_SDK_API_NAME@.pc +DISTCLEANFILES += @EOS_SDK_API_NAME@.pc + +# # # INTROSPECTION FILES # # # + +-include $(INTROSPECTION_MAKEFILE) +INTROSPECTION_GIRS = +INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) +INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir) + +if HAVE_INTROSPECTION +introspection_sources = \ + $(filter-out %-private.h, $(endless_library_sources)) \ + $(endless_public_installed_headers) \ + $(endless_private_installed_headers) + +Endless-@EOS_SDK_API_VERSION@.gir: libendless-@EOS_SDK_API_VERSION@.la +Endless_@EOS_SDK_API_VERSION@_gir_INCLUDES = \ + GObject-2.0 GLib-2.0 Gio-2.0 Gtk-3.0 +Endless_@EOS_SDK_API_VERSION@_gir_SCANNERFLAGS = \ + --identifier-prefix=Eos \ + --symbol-prefix=eos \ + -DCOMPILING_EOS_SDK +# Endless_@EOS_SDK_API_VERSION@_gir_CFLAGS = $(INCLUDES) +Endless_@EOS_SDK_API_VERSION@_gir_LIBS = libendless-@EOS_SDK_API_VERSION@.la +Endless_@EOS_SDK_API_VERSION@_gir_FILES = $(introspection_sources) +Endless_@EOS_SDK_API_VERSION@_gir_EXPORT_PACKAGES = @EOS_SDK_API_NAME@ +INTROSPECTION_GIRS += Endless-@EOS_SDK_API_VERSION@.gir + +girdir = $(datadir)/gir-1.0 +gir_DATA = $(INTROSPECTION_GIRS) + +typelibdir = $(libdir)/girepository-1.0 +typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) + +CLEANFILES += $(gir_DATA) $(typelib_DATA) +endif + +# # # TESTS # # # + +include $(top_srcdir)/test/Makefile.am + +# Run tests when running 'make check' +TESTS_ENVIRONMENT = gtester -k -o test-results.xml +TESTS = test/run-tests + +CLEANFILES += test-results.xml @@ -1,2 +1,63 @@ -eos-sdk -=======
\ No newline at end of file +Open Endless SDK +================ + +Libraries and development tools for building Endless applications. + +Coding style +------------ + +We follow the GTK coding style: +https://git.gnome.org/browse/gtk+/plain/docs/CODING-STYLE + +Build instructions +------------------ + +Run `make` anytime you change a file. + +Preparing the source +-------------------- + +From a fresh source checkout, run: + + ./autogen.sh + ./configure + +This prepares the source tree for building. The `configure` script takes several options, common ones being: + + - `--prefix=/usr`: install in `/usr` instead of `/usr/local` (you probably want this) + - `--enable-gtk-doc`: generate the documentation whenever you build; this makes your build slower, but the documentation will always be up to date + - `--enable-strict-flags`: use strict compiler flags to catch extra warnings + - If you're doing a debug build, then `CFLAGS="-g -O0" ./configure` will make sure that `make` always builds with debugging symbols and optimization off. + +Then, run `make` to rebuild, and `sudo make install` to copy the SDK into the system. + +By default, the compiler invocations with all the flags are not shown. +If you want to see them, run `make V=1`. +If you want make to try and run several jobs in parallel, run `make -j2` for 2 jobs, for example. + +Testing +------- + +To run the automated tests, run `make check`. + +Packaging +--------- + +Before packaging, run `make distcheck`. +This runs the tests as above, but from a clean source tree in a temporary location. +It also installs all the files in a temporary location and uninstalls them again, in order to make sure that nothing is forgotten. + +Fixing breakage +--------------- + +If at any time the state of your build tree gets wedged, then try the following: + + make clean + make + +If that doesn't work, + + make maintainer-clean + ./autogen.sh + ./configure + make diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..b462eec --- /dev/null +++ b/autogen.sh @@ -0,0 +1,35 @@ +# Bootstrap script for Open Endless SDK +# Run this script on a clean source checkout to get ready for building. + +FILE_MUST_EXIST=endless/endless.h +POT_FILE=po/eos-sdk.pot + +test -n "$srcdir" || srcdir=`dirname "$0"` +test -n "$srcdir" || srcdir=. +olddir=`pwd` + +cd $srcdir +test -f $FILE_MUST_EXIST || { + echo "You must run this script in the top-level checkout directory" + exit 1 +} + +# GNU gettext automake support doesn't get along with git +# https://bugzilla.gnome.org/show_bug.cgi?id=661128 +touch -t 200001010000 $POT_FILE + +# NOCONFIGURE is used by gnome-common +if test -z "$NOCONFIGURE"; then + echo "This script will run ./configure automatically. If you wish to pass " + echo "any arguments to it, please specify them on the $0 " + echo "command line. To disable this behavior, have NOCONFIGURE=1 in your " + echo "environment." +fi + +# Run the actual tools to prepare the clean checkout +gtkdocize || exit $? +autoreconf -fi || exit $? +rm -f po/Makevars.template + +cd "$olddir" +test -n "$NOCONFIGURE" || "./configure" "$@" diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..08f32f1 --- /dev/null +++ b/configure.ac @@ -0,0 +1,163 @@ +dnl Process this file with autoconf to produce configure + +# Copyright 2013 Endless Mobile, Inc. + +dnl ------------ +dnl configure.ac +dnl ------------ +dnl Please keep this file well-commented. Autotools involve a lot of magical +dnl incantations, and it is easy to mess things up if you don't know what you +dnl are doing. + +# Version numbers +# --------------- +# API name and version for pkg-config; increment when breaking API/ABI. +# This version number is also the major version number. +m4_define([_EOS_SDK_API_VERSION_MACRO], [0]) + +# Minor and micro versions: increment micro version when making a release. Minor +# version is even for a stable release and odd for a development release. +# When making any release, if the API changes, set the interface age to 0. +m4_define([_EOS_SDK_MINOR_VERSION_MACRO], [0]) +m4_define([_EOS_SDK_MICRO_VERSION_MACRO], [0]) +m4_define([_EOS_SDK_INTERFACE_AGE_MACRO], [0]) + +# Full version, for use in AC_INIT +m4_define([_EOS_SDK_VERSION_MACRO], + [_EOS_SDK_API_VERSION_MACRO._EOS_SDK_MINOR_VERSION_MACRO._EOS_SDK_MICRO_VERSION_MACRO]) + +# Initialization +# -------------- +# Initialize Autoconf: package name, version, bug report address, tarball name, +# website +AC_INIT([Open Endless SDK], [_EOS_SDK_VERSION_MACRO], + [], [eos-sdk], [http://endlessm.com]) +# Verify that the source directory can be found +dnl AC_CONFIG_SRCDIR([src/hello.c]) +# Initialize Automake: enable all warnings and do not insist on GNU standards +# Automake >= 1.11 required for silent rules +AM_INIT_AUTOMAKE([-Wall foreign 1.11]) +# Avoid spewing garbage over the terminal ('make V=1' to see the garbage) +AM_SILENT_RULES([yes]) +# Initialize Libtool; don't build static libraries +LT_INIT([disable-static]) +# Keep Autotools macros local to this source tree +AC_CONFIG_MACRO_DIR([m4]) + +# Variables to define +# ------------------- +# Version numbers and macros +EOS_SDK_API_VERSION=_EOS_SDK_API_VERSION_MACRO +AC_SUBST(EOS_SDK_API_VERSION) +AC_DEFINE([EOS_SDK_MAJOR_VERSION], [_EOS_SDK_API_VERSION_MACRO], [Major (API) version]) +EOS_SDK_API_NAME="endless-$EOS_SDK_API_VERSION" +AC_SUBST(EOS_SDK_API_NAME) +EOS_SDK_MINOR_VERSION=_EOS_SDK_MINOR_VERSION_MACRO +EOS_SDK_MICRO_VERSION=_EOS_SDK_MICRO_VERSION_MACRO +EOS_SDK_INTERFACE_AGE=_EOS_SDK_INTERFACE_AGE_MACRO +AC_DEFINE([EOS_SDK_MINOR_VERSION], [_EOS_SDK_MINOR_VERSION_MACRO], [Minor version]) +AC_DEFINE([EOS_SDK_MICRO_VERSION], [_EOS_SDK_MICRO_VERSION_MACRO], [Micro version]) +AC_DEFINE([EOS_SDK_VERSION], [_EOS_SDK_VERSION_MACRO], [Full version number]) + +# Shared library versioning; calculated automatically. +# See http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html +EOS_SDK_LT_CURRENT=m4_eval(100 * _EOS_SDK_MINOR_VERSION_MACRO + _EOS_SDK_MICRO_VERSION_MACRO - _EOS_SDK_INTERFACE_AGE_MACRO) +EOS_SDK_LT_REVISION=$EOS_SDK_INTERFACE_AGE +EOS_SDK_LT_AGE=$EOS_SDK_LT_CURRENT +EOS_SDK_LT_VERSION_INFO="$EOS_SDK_LT_CURRENT:$EOS_SDK_LT_REVISION:$EOS_SDK_LT_AGE" +AC_SUBST(EOS_SDK_LT_VERSION_INFO) + +# Required versions of libraries +# Update these whenever you use a function that requires a certain API version +GLIB_REQUIREMENT="glib-2.0 >= 2.20" +GOBJECT_REQUIREMENT="gobject-2.0" +GIO_REQUIREMENT="gio-2.0" +GTK_REQUIREMENT="gtk+-3.0 >= 3.0" +# These go into the pkg-config file as Requires: and Requires.private: +# (Generally, use Requires.private: instead of Requires:) +EOS_REQUIRED_MODULES= +EOS_REQUIRED_MODULES_PRIVATE="$GLIB_REQUIREMENT $GOBJECT_REQUIREMENT $GIO_REQUIREMENT $GTK_REQUIREMENT" +AC_SUBST(EOS_REQUIRED_MODULES) +AC_SUBST(EOS_REQUIRED_MODULES_PRIVATE) + +# Gettext package name +GETTEXT_PACKAGE=$PACKAGE +AC_SUBST(GETTEXT_PACKAGE) +AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, ["$GETTEXT_PACKAGE"], + [Package name for Gettext]) +# Detect which languages are available +AS_ALL_LINGUAS + +# Configure options +# ----------------- +# --enable-strict-flags: Compile with strict compiler flags. Done automatically +# during 'make distcheck'. +AC_ARG_ENABLE([strict-flags], + [AS_HELP_STRING([--enable-strict-flags=@<:@no/yes/error@:>@], + [Use strict compiler flags @<:@default=no@:>@])], + [], + [enable_strict_flags=no]) +# Emmanuele's list of flags +STRICT_COMPILER_FLAGS="$STRICT_COMPILER_FLAGS + -Wall + -Wcast-align + -Wuninitialized + -Wno-strict-aliasing + -Werror=pointer-arith + -Werror=missing-declarations + -Werror=redundant-decls + -Werror=empty-body + -Werror=format + -Werror=format-security + -Werror=format-nonliteral + -Werror=init-self + -Werror=declaration-after-statement + -Werror=vla" +AS_CASE([$enable_strict_flags], + [yes], + [AS_COMPILER_FLAGS([STRICT_CFLAGS], [$STRICT_COMPILER_FLAGS])], + [no], + [], + [error], + [ + STRICT_COMPILER_FLAGS="$STRICT_COMPILER_FLAGS -Werror" + AS_COMPILER_FLAGS([STRICT_CFLAGS], [$STRICT_COMPILER_FLAGS]) + ], + [AC_MSG_ERROR([Invalid option for --enable-strict-flags])]) +STRICT_CFLAGS=${STRICT_CFLAGS#* } dnl Strip spaces +AC_SUBST(STRICT_CFLAGS) + +# Required build tools +# -------------------- +# C compiler +AC_PROG_CC +# Library configuration tool +PKG_PROG_PKG_CONFIG +# Gettext +AM_GNU_GETTEXT([external]) +AM_GNU_GETTEXT_VERSION([0.18.1]) +# Gtk-doc; 0.18 required for Markdown parsing +GTK_DOC_CHECK([1.18], [--flavour no-tmpl]) +# GObject Introspection +GOBJECT_INTROSPECTION_REQUIRE([1.30]) + +# Required libraries +# ------------------ +PKG_CHECK_MODULES([EOS_SDK], [ + $EOS_REQUIRED_MODULES + $EOS_REQUIRED_MODULES_PRIVATE]) + +# Output +# ------ +# List files here that the configure script should output +AC_CONFIG_FILES([ + Makefile + po/Makefile.in + docs/reference/endless/Makefile + docs/reference/endless/version.xml + $EOS_SDK_API_NAME.pc +]) +AC_CONFIG_HEADERS([config.h]) dnl Header with system-dependent #defines +# Do the output +AC_OUTPUT + diff --git a/docs/reference/endless/.gitignore b/docs/reference/endless/.gitignore new file mode 100644 index 0000000..2df75cd --- /dev/null +++ b/docs/reference/endless/.gitignore @@ -0,0 +1,19 @@ +/Makefile +/Makefile.in +/endless-decl-list.txt +/endless-decl.txt +/endless-undeclared.txt +/endless-undocumented.txt +/endless-unused.txt +/endless.args +/endless.hierarchy +/endless.interfaces +/endless.prerequisites +/endless.signals +/endless.types +/html +/so_locations +/tags +/version.xml +/xml +/*.bak
\ No newline at end of file diff --git a/docs/reference/endless/Makefile.am b/docs/reference/endless/Makefile.am new file mode 100644 index 0000000..a207921 --- /dev/null +++ b/docs/reference/endless/Makefile.am @@ -0,0 +1,92 @@ +## Process this file with automake to produce Makefile.in + +# The name of the module, e.g. 'glib'. +DOC_MODULE=endless + +# Uncomment for versioned docs and specify the version of the module, e.g. '2'. +DOC_MODULE_VERSION=@EOS_SDK_API_VERSION@ + +# The top-level SGML file. You can change this if you want to. +DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.xml + +# Directories containing the source code. +# gtk-doc will search all .c and .h files beneath these paths +# for inline comments documenting functions and macros. +# e.g. DOC_SOURCE_DIR=$(top_srcdir)/gtk $(top_srcdir)/gdk +DOC_SOURCE_DIR=$(top_srcdir)/endless + +# Extra options to pass to gtkdoc-scangobj. Not normally needed. +SCANGOBJ_OPTIONS= + +# Extra options to supply to gtkdoc-scan. +# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED" +SCAN_OPTIONS=--rebuild-types + +# Extra options to supply to gtkdoc-mkdb. +# e.g. MKDB_OPTIONS=--xml-mode --output-format=xml +MKDB_OPTIONS=--xml-mode --output-format=xml + +# Extra options to supply to gtkdoc-mktmpl +# e.g. MKTMPL_OPTIONS=--only-section-tmpl +MKTMPL_OPTIONS= + +# Extra options to supply to gtkdoc-mkhtml +MKHTML_OPTIONS= + +# Extra options to supply to gtkdoc-fixxref. Not normally needed. +# e.g. FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html +FIXXREF_OPTIONS= + +# Used for dependencies. The docs will be rebuilt if any of these change. +BUILT_HFILES= +HFILE_GLOB=$(top_srcdir)/endless/*.h +CFILE_GLOB=$(top_srcdir)/endless/*.c + +# Extra header to include when scanning, which are not under DOC_SOURCE_DIR +# e.g. EXTRA_HFILES=$(top_srcdir)/contrib/extra.h +EXTRA_HFILES= + +# Header files or dirs to ignore when scanning. Use base file/dir names +# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h private_code +IGNORE_HFILES=$(top_srcdir)/endless/init-private.h + +# Images to copy into HTML directory. +# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png +HTML_IMAGES= + +# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE). +# e.g. content_files=running.sgml building.sgml changes-2.0.sgml +content_files= + +# SGML files where gtk-doc abbrevations (#GtkWidget) are expanded +# These files must be listed here *and* in content_files +# e.g. expand_content_files=running.sgml +expand_content_files= + +# CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library. +# Only needed if you are using gtkdoc-scangobj to dynamically query widget +# signals and properties. +GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_builddir) @EOS_SDK_CFLAGS@ +GTKDOC_LIBS=$(top_builddir)/libendless-@EOS_SDK_API_VERSION@.la + +# This includes the standard gtk-doc make rules, copied by gtkdocize. +include $(top_srcdir)/gtk-doc.make + +# Other files to distribute +# e.g. EXTRA_DIST += version.xml.in +EXTRA_DIST += + +# Files not to distribute +# for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types +# for --rebuild-sections in $(SCAN_OPTIONS) e.g. $(DOC_MODULE)-sections.txt +#DISTCLEANFILES += + +# Comment this out if you want 'make check' to test you doc status +# and run some sanity checks +if ENABLE_GTK_DOC +TESTS_ENVIRONMENT = cd $(srcdir) && \ + DOC_MODULE=$(DOC_MODULE) DOC_MAIN_SGML_FILE=$(DOC_MAIN_SGML_FILE) \ + SRCDIR=$(abs_srcdir) BUILDDIR=$(abs_builddir) +TESTS = $(GTKDOC_CHECK) +endif + diff --git a/docs/reference/endless/endless-docs.xml b/docs/reference/endless/endless-docs.xml new file mode 100644 index 0000000..d4004aa --- /dev/null +++ b/docs/reference/endless/endless-docs.xml @@ -0,0 +1,39 @@ +<?xml version="1.0"?> +<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" + "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" +[ + <!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'"> + <!ENTITY version SYSTEM "version.xml"> +]> +<book id="index"> + <bookinfo> + <title>Open Endless SDK reference (C API)</title> + <releaseinfo> + <para>Version: &version;</para> + <!--The latest version of this documentation can be found on-line at + <ulink role="online-location" url="http://[SERVER]/endless/index.html">http://[SERVER]/endless/</ulink>.--> + </releaseinfo> + </bookinfo> + + <chapter> + <title>Open Endless SDK reference (C API)</title> + <xi:include href="xml/hello.xml"/> + </chapter> + + <chapter id="object-tree"> + <title>Object Hierarchy</title> + <xi:include href="xml/tree_index.sgml"/> + </chapter> + + <index id="api-index-full"> + <title>API Index</title> + <xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include> + </index> + + <index id="deprecated-api-index" role="deprecated"> + <title>Index of deprecated API</title> + <xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include> + </index> + + <xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include> +</book> diff --git a/docs/reference/endless/endless-overrides.txt b/docs/reference/endless/endless-overrides.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/docs/reference/endless/endless-overrides.txt diff --git a/docs/reference/endless/endless-sections.txt b/docs/reference/endless/endless-sections.txt new file mode 100644 index 0000000..4782fbb --- /dev/null +++ b/docs/reference/endless/endless-sections.txt @@ -0,0 +1,6 @@ +<SECTION> +<FILE>hello</FILE> +eos_hello_sample_function +<SUBSECTION Private> +EOS_SDK_ALL_API_VERSIONS +</SECTION> diff --git a/docs/reference/endless/version.xml.in b/docs/reference/endless/version.xml.in new file mode 100644 index 0000000..27323da --- /dev/null +++ b/docs/reference/endless/version.xml.in @@ -0,0 +1 @@ +@VERSION@
\ No newline at end of file diff --git a/endless-0.pc.in b/endless-0.pc.in new file mode 100644 index 0000000..083f995 --- /dev/null +++ b/endless-0.pc.in @@ -0,0 +1,15 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: @PACKAGE_NAME@ +Version: @PACKAGE_VERSION@ +Description: Software development kit for applications for the developing world +URL: @PACKAGE_URL@ + +Requires: @EOS_REQUIRED_MODULES@ +Requires.private: @EOS_REQUIRED_MODULES_PRIVATE@ +Cflags: -I${includedir}/@EOS_SDK_API_NAME@ +Libs: -L${libdir} -l@EOS_SDK_API_NAME@ + diff --git a/endless/Makefile.am b/endless/Makefile.am new file mode 100644 index 0000000..e653097 --- /dev/null +++ b/endless/Makefile.am @@ -0,0 +1,28 @@ +# 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/init.c endless/init-private.h + +# 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..83be05a --- /dev/null +++ b/endless/hello.c @@ -0,0 +1,70 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#include <config.h> +#include <string.h> +#include <glib.h> +#include <glib/gi18n-lib.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/init-private.h b/endless/init-private.h new file mode 100644 index 0000000..d242d5e --- /dev/null +++ b/endless/init-private.h @@ -0,0 +1,14 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#ifndef EOS_INIT_PRIVATE_H +#define EOS_INIT_PRIVATE_H + +#include <glib.h> + +G_BEGIN_DECLS + +gboolean eos_is_inited (void); + +G_END_DECLS + +#endif /* EOS_INIT_PRIVATE_H */ diff --git a/endless/init.c b/endless/init.c new file mode 100644 index 0000000..cf1cdeb --- /dev/null +++ b/endless/init.c @@ -0,0 +1,53 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#include <config.h> +#include <glib.h> +#include <glib/gi18n-lib.h> + +#include "init-private.h" + +/* Constructors supported since GCC 2.7; I have this on GLib's authority. This +should also work on Clang. */ +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) + +#define _EOS_CONSTRUCTOR(func) static void __attribute__((constructor)) func (void); +#define _EOS_DESTRUCTOR(func) static void __atrribute__((destructor)) func (void); + +#else + +#error "We do not currently support constructors for your compiler." + +#endif /* compiler version */ + +static gboolean _eos_initialized = FALSE; + +/* + * _eos_init: + * + * This function initializes the library. It is called automatically when the + * library is loaded. + */ +_EOS_CONSTRUCTOR(_eos_init); +static void +_eos_init (void) +{ + if (G_UNLIKELY (!_eos_initialized)) + { + /* Initialize Gettext */ + bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + + _eos_initialized = TRUE; + } +} + +/* + * eos_is_inited: + * + * For testing purposes. + */ +gboolean +eos_is_inited (void) +{ + return _eos_initialized; +} 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 */ diff --git a/m4/as-compiler-flag.m4 b/m4/as-compiler-flag.m4 new file mode 100644 index 0000000..0f660cf --- /dev/null +++ b/m4/as-compiler-flag.m4 @@ -0,0 +1,62 @@ +dnl as-compiler-flag.m4 0.1.0 + +dnl autostars m4 macro for detection of compiler flags + +dnl David Schleef <ds@schleef.org> + +dnl $Id: as-compiler-flag.m4,v 1.1 2005/12/15 23:35:19 ds Exp $ + +dnl AS_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED]) +dnl Tries to compile with the given CFLAGS. +dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags, +dnl and ACTION-IF-NOT-ACCEPTED otherwise. + +AC_DEFUN([AS_COMPILER_FLAG], +[ + AC_MSG_CHECKING([to see if compiler understands $1]) + + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $1" + + AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no]) + CFLAGS="$save_CFLAGS" + + if test "X$flag_ok" = Xyes ; then + m4_ifvaln([$2],[$2]) + true + else + m4_ifvaln([$3],[$3]) + true + fi + AC_MSG_RESULT([$flag_ok]) +]) + +dnl AS_COMPILER_FLAGS(VAR, FLAGS) +dnl Tries to compile with the given CFLAGS. + +AC_DEFUN([AS_COMPILER_FLAGS], +[ + list=$2 + flags_supported="" + flags_unsupported="" + AC_MSG_CHECKING([for supported compiler flags]) + for each in $list + do + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $each" + AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no]) + CFLAGS="$save_CFLAGS" + + if test "X$flag_ok" = Xyes ; then + flags_supported="$flags_supported $each" + else + flags_unsupported="$flags_unsupported $each" + fi + done + AC_MSG_RESULT([$flags_supported]) + if test "X$flags_unsupported" != X ; then + AC_MSG_WARN([unsupported compiler flags: $flags_unsupported]) + fi + $1="$$1 $flags_supported" +]) + diff --git a/m4/as-linguas.m4 b/m4/as-linguas.m4 new file mode 100644 index 0000000..8b4e07f --- /dev/null +++ b/m4/as-linguas.m4 @@ -0,0 +1,26 @@ +# Set ALL_LINGUAS based on the .po files present. Optional argument is the +# name of the po directory. $podir/LINGUAS.ignore can be used to ignore a +# subset of the po files. + +# Public domain, according to Emmanuele + +AC_DEFUN([AS_ALL_LINGUAS], +[ + AC_MSG_CHECKING([for linguas]) + podir="m4_default([$1],[$srcdir/po])" + linguas=`cd $podir && ls *.po 2>/dev/null | awk 'BEGIN { FS="."; ORS=" " } { print $[]1 }'` + if test -f "$podir/LINGUAS.ignore"; then + ALL_LINGUAS=""; + ignore_linguas=`sed -n -e 's/^\s\+\|\s\+$//g' -e '/^#/b' -e '/\S/!b' \ + -e 's/\s\+/\n/g' -e p "$podir/LINGUAS.ignore"`; + for lang in $linguas; do + if ! echo "$ignore_linguas" | grep -q "^${lang}$"; then + ALL_LINGUAS="$ALL_LINGUAS $lang"; + fi; + done; + else + ALL_LINGUAS="$linguas"; + fi; + AC_SUBST([ALL_LINGUAS]) + AC_MSG_RESULT($ALL_LINGUAS) +]) diff --git a/po/Makevars b/po/Makevars new file mode 100644 index 0000000..03b5cc3 --- /dev/null +++ b/po/Makevars @@ -0,0 +1,41 @@ +# Makefile variables for PO directory in any package using GNU gettext. + +# The domain is the same as the package name defined in configure.ac. +DOMAIN = $(PACKAGE) + +# These two variables depend on the location of this directory. +subdir = po +top_builddir = .. + +# These options get passed to xgettext. +XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ + +# This is the copyright holder that gets inserted into the header of the +# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding +# package. (Note that the msgstr strings, extracted from the package's +# sources, belong to the copyright holder of the package.) Translators are +# expected to transfer the copyright for their translations to this person +# or entity, or to disclaim their copyright. The empty string stands for +# the public domain; in this case the translators are expected to disclaim +# their copyright. +COPYRIGHT_HOLDER = Endless Mobile, Inc. + +# This is the email address or URL to which the translators shall report +# bugs in the untranslated strings: +# - Strings which are not entire sentences, see the maintainer guidelines +# in the GNU gettext documentation, section 'Preparing Strings'. +# - Strings which use unclear terms or require additional context to be +# understood. +# - Strings which make invalid assumptions about notation of date, time or +# money. +# - Pluralisation problems. +# - Incorrect English spelling. +# - Incorrect formatting. +# It can be your email address, or a mailing list address where translators +# can write to without being subscribed, or the URL of a web page through +# which the translators can contact you. +MSGID_BUGS_ADDRESS = philip@endlessm.com + +# This is the list of locale categories, beyond LC_MESSAGES, for which the +# message catalogs shall be used. It is usually empty. +EXTRA_LOCALE_CATEGORIES = diff --git a/po/POTFILES.in b/po/POTFILES.in new file mode 100644 index 0000000..bc44e28 --- /dev/null +++ b/po/POTFILES.in @@ -0,0 +1,2 @@ +# List of source files which contain translatable strings. +endless/hello.c diff --git a/po/pt_BR.po b/po/pt_BR.po new file mode 100644 index 0000000..68e2b87 --- /dev/null +++ b/po/pt_BR.po @@ -0,0 +1,22 @@ +# Portuguese translations for open-endless-sdk package. +# Copyright (C) 2013 Endless Mobile, Inc. +# This file is distributed under the same license as the open-endless-sdk package. +# Philip Chimento <l10n@endlessm.com>, 2013. +# +msgid "" +msgstr "" +"Project-Id-Version: open-endless-sdk 0.0\n" +"Report-Msgid-Bugs-To: philip@endlessm.com\n" +"POT-Creation-Date: 2013-04-12 15:56+0100\n" +"PO-Revision-Date: 2013-04-07 03:03+0200\n" +"Last-Translator: Philip Chimento <l10n@endlessm.com>\n" +"Language-Team: Brazilian Portuguese\n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-1\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#: endless/hello.c:35 +msgid "Hello, world!\n" +msgstr "Bom dia, mundo!\n" diff --git a/test/Makefile.am b/test/Makefile.am new file mode 100644 index 0000000..85c0fe7 --- /dev/null +++ b/test/Makefile.am @@ -0,0 +1,19 @@ +# Copyright 2013 Endless Mobile, Inc. + +noinst_PROGRAMS = \ + test/run-tests \ + test/smoke-tests/hello + +TEST_FLAGS = @EOS_SDK_CFLAGS@ -I$(top_srcdir) +TEST_LIBS = @EOS_SDK_LIBS@ $(top_builddir)/libendless-@EOS_SDK_API_VERSION@.la + +test_run_tests_SOURCES = \ + test/run-tests.c \ + test/test-init.c \ + test/test-hello.c +test_run_tests_CPPFLAGS = $(TEST_FLAGS) +test_run_tests_LDADD = $(TEST_LIBS) + +test_smoke_tests_hello_SOURCES = test/smoke-tests/hello.c +test_smoke_tests_hello_CPPFLAGS = $(TEST_FLAGS) +test_smoke_tests_hello_LDADD = $(TEST_LIBS) diff --git a/test/run-tests.c b/test/run-tests.c new file mode 100644 index 0000000..ba016bc --- /dev/null +++ b/test/run-tests.c @@ -0,0 +1,18 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#include <glib-object.h> +#include <glib.h> + +#include "run-tests.h" + +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + + add_init_tests (); + add_hello_tests (); + + return g_test_run (); +} diff --git a/test/run-tests.h b/test/run-tests.h new file mode 100644 index 0000000..3efac9e --- /dev/null +++ b/test/run-tests.h @@ -0,0 +1,9 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#ifndef RUN_TESTS_H +#define RUN_TESTS_H + +void add_init_tests (void); +void add_hello_tests (void); + +#endif /* RUN_TESTS_H */ diff --git a/test/smoke-tests/hello.c b/test/smoke-tests/hello.c new file mode 100644 index 0000000..4538835 --- /dev/null +++ b/test/smoke-tests/hello.c @@ -0,0 +1,11 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#include <endless/endless.h> + +int +main (int argc, + char **argv) +{ + eos_hello_sample_function (NULL, NULL); + return 0; +} diff --git a/test/smoke-tests/introspection.js b/test/smoke-tests/introspection.js new file mode 100644 index 0000000..8197fe7 --- /dev/null +++ b/test/smoke-tests/introspection.js @@ -0,0 +1,4 @@ +// Copyright 2013 Endless Mobile, Inc. + +const Endless = imports.gi.Endless; +Endless.hello_sample_function(null); diff --git a/test/smoke-tests/introspection.py b/test/smoke-tests/introspection.py new file mode 100644 index 0000000..7870bc1 --- /dev/null +++ b/test/smoke-tests/introspection.py @@ -0,0 +1,4 @@ +# Copyright 2013 Endless Mobile, Inc. + +from gi.repository import Endless +Endless.hello_sample_function(None) diff --git a/test/test-hello.c b/test/test-hello.c new file mode 100644 index 0000000..687f14d --- /dev/null +++ b/test/test-hello.c @@ -0,0 +1,59 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#include <stdlib.h> +#include <glib.h> +#include <endless/endless.h> + +#include "run-tests.h" + +#define EXPECTED_HELLO_STRING "Hello, world!\n" + +static void +test_hello_stdout (void) +{ + GError *error = NULL; + + /* Unix-only test */ + if (g_test_trap_fork(0 /* timeout */, G_TEST_TRAP_SILENCE_STDOUT)) + { + gboolean success = eos_hello_sample_function (NULL, &error); + g_assert (success); + g_assert_no_error (error); + exit (0); + } + + g_test_trap_assert_passed (); + g_test_trap_assert_stdout (EXPECTED_HELLO_STRING); +} + +static void +test_hello_gfile (void) +{ + GError *error = NULL; + GFileIOStream *stream; + GFile *file = g_file_new_tmp ("sdktestXXXXXX", &stream, &error); + gboolean success; + char *file_contents; + + g_assert_no_error (error); + g_io_stream_close (G_IO_STREAM (stream), NULL, &error); + g_assert_no_error (error); + + success = eos_hello_sample_function (file, &error); + g_assert (success); + g_assert_no_error (error); + + g_file_load_contents (file, NULL, &file_contents, NULL, NULL, &error); + g_assert_no_error (error); + g_assert_cmpstr (file_contents, ==, EXPECTED_HELLO_STRING); + + g_free (file_contents); + g_object_unref (file); +} + +void +add_hello_tests (void) +{ + g_test_add_func ("/hello/stdout", test_hello_stdout); + g_test_add_func ("/hello/gfile", test_hello_gfile); +} diff --git a/test/test-init.c b/test/test-init.c new file mode 100644 index 0000000..1fd856e --- /dev/null +++ b/test/test-init.c @@ -0,0 +1,19 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#include <glib.h> +#include <endless/endless.h> +#include "endless/init-private.h" + +#include "run-tests.h" + +static void +test_constructor_called (void) +{ + g_assert (eos_is_inited ()); +} + +void +add_init_tests (void) +{ + g_test_add_func ("/init/constructor-called", test_constructor_called); +} |