summaryrefslogtreecommitdiffstats
path: root/template.d
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-08-10 18:25:48 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-08-16 18:40:34 +0200
commite1ef035594fc80baaf5cd571ab4d04023309a906 (patch)
treed72dd196318c583d28e6a8a3755251c79ba16bf3 /template.d
parent20c82ee40b442e5b64079155e2eafaf22440d1fb (diff)
Extending pluggable arch for templates
Idea is to be able to use custom templates from home dir and system dir Change-Id: I74b48458f3dcc26b49f8144e042c213691028167 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'template.d')
-rwxr-xr-xtemplate.d/autobuild/agl/autobuild.in60
-rwxr-xr-xtemplate.d/autobuild/linux/autobuild.in62
-rw-r--r--template.d/config.xml.in9
-rw-r--r--template.d/deb-config.dsc.in15
-rw-r--r--template.d/deb-config.install.in2
-rw-r--r--template.d/debian.changelog.in5
-rw-r--r--template.d/debian.compat.in1
-rw-r--r--template.d/debian.control.in16
-rw-r--r--template.d/debian.rules.in87
-rw-r--r--template.d/gdb-native-target.ini.in35
-rwxr-xr-xtemplate.d/install-wgt-on-target.sh.in19
-rw-r--r--template.d/rpm-config.spec.in62
-rwxr-xr-xtemplate.d/start-on-target.sh.in25
13 files changed, 398 insertions, 0 deletions
diff --git a/template.d/autobuild/agl/autobuild.in b/template.d/autobuild/agl/autobuild.in
new file mode 100755
index 0000000..759f6be
--- /dev/null
+++ b/template.d/autobuild/agl/autobuild.in
@@ -0,0 +1,60 @@
+#!/usr/bin/make -f
+# Copyright (C) 2015, 2016 "IoT.bzh"
+# Author "Romain Forlot" <romain.forlot@iot.bzh>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+THISFILE := $(lastword $(MAKEFILE_LIST))
+BUILD_DIR := $(abspath $(dir $(THISFILE)/../../../../..)/build)
+DEST := ${BUILD_DIR}/target
+
+.PHONY: all clean distclean configure build package help
+
+all: help
+
+help:
+ @echo "List of targets available:"
+ @echo ""
+ @echo "- all"
+ @echo "- clean"
+ @echo "- distclean"
+ @echo "- configure"
+ @echo "- build"
+ @echo "- package"
+ @echo ""
+ @echo "Usage: ./conf.d/autobuild/agl/autobuild package DEST=${HOME}/opt"
+ @echo "Don't use your build dir as DEST as wgt file is generated at this location"
+
+clean:
+ @([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} clean) || echo Nothing to clean
+
+distclean:
+ @rm -rf ${BUILD_DIR}
+
+configure: ${BUILD_DIR}/Makefile
+
+build: configure
+ @cmake --build ${BUILD_DIR} ${BUILD_ARGS} --target all
+
+package: build
+ @mkdir -p ${BUILD_DIR}/$@/bin
+ @mkdir -p ${BUILD_DIR}/$@/etc
+ @mkdir -p ${BUILD_DIR}/$@/lib
+ @mkdir -p ${BUILD_DIR}/$@/htdocs
+ @mkdir -p ${BUILD_DIR}/$@/data
+ @cmake --build ${BUILD_DIR} --target widget
+ @mkdir -p ${DEST} && cp ${BUILD_DIR}/*wgt ${DEST}
+
+${BUILD_DIR}/Makefile:
+ @[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR}
+ @[ -f ${BUILD_DIR}/Makefile ] || (cd ${BUILD_DIR} && cmake ${CONFIGURE_ARGS} ..)
diff --git a/template.d/autobuild/linux/autobuild.in b/template.d/autobuild/linux/autobuild.in
new file mode 100755
index 0000000..ed39429
--- /dev/null
+++ b/template.d/autobuild/linux/autobuild.in
@@ -0,0 +1,62 @@
+#!/usr/bin/make -f
+# Copyright (C) 2015, 2016 "IoT.bzh"
+# Author "Romain Forlot" <romain.forlot@iot.bzh>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+THISFILE := $(lastword $(MAKEFILE_LIST))
+BUILD_DIR := $(abspath $(dir $(THISFILE)/../../../../..)/build)
+DEST := ${BUILD_DIR}/target
+
+.PHONY: all clean distclean configure build package help
+
+all: help
+
+help:
+ @echo "List of targets available:"
+ @echo ""
+ @echo "- all"
+ @echo "- clean"
+ @echo "- distclean"
+ @echo "- configure"
+ @echo "- build"
+ @echo "- package"
+ @echo ""
+ @echo "Usage: ./conf.d/autobuild/agl/autobuild package DEST=${HOME}/opt"
+ @echo "Don't use your build dir as DEST as wgt file is generated at this location"
+
+clean:
+ @([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} clean) || echo Nothing to clean
+
+distclean:
+ @rm -rf ${BUILD_DIR}
+
+configure: ${BUILD_DIR}/Makefile
+
+build: configure
+ @cmake --build ${BUILD_DIR} ${BUILD_ARGS} --target all
+
+package: build
+ @mkdir -p ${BUILD_DIR}/$@/bin
+ @mkdir -p ${BUILD_DIR}/$@/etc
+ @mkdir -p ${BUILD_DIR}/$@/lib
+ @mkdir -p ${BUILD_DIR}/$@/htdocs
+ @mkdir -p ${BUILD_DIR}/$@/data
+ @cmake --build ${BUILD_DIR} --target packaging
+ @cmake --build ${BUILD_DIR} --target widget
+ @mkdir -p ${DEST} && cp ${BUILD_DIR}/*wgt ${DEST}
+
+
+${BUILD_DIR}/Makefile:
+ @[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR}
+ @[ -f ${BUILD_DIR}/Makefile ] || (cd ${BUILD_DIR} && cmake ${CONFIGURE_ARGS} ..)
diff --git a/template.d/config.xml.in b/template.d/config.xml.in
new file mode 100644
index 0000000..35d20b8
--- /dev/null
+++ b/template.d/config.xml.in
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<widget xmlns="http://www.w3.org/ns/widgets" id="@PROJECT_NAME@" version="@PROJECT_VERSION@">
+ <name>@PROJECT_NAME@</name>
+ <icon src="@PROJECT_ICON@"/>
+ <content src="@WIDGET_ENTRY_POINT@" type="@WIDGET_TYPE@"/>
+ <description>@PROJECT_DESCRIPTION@</description>
+ <author>@PROJECT_AUTHOR@ &lt;@PROJECT_AUTHOR_MAIL@&gt;</author>
+ <license>@PROJECT_LICENSE@</license>
+</widget>
diff --git a/template.d/deb-config.dsc.in b/template.d/deb-config.dsc.in
new file mode 100644
index 0000000..28a4835
--- /dev/null
+++ b/template.d/deb-config.dsc.in
@@ -0,0 +1,15 @@
+Format: @PROJECT_VERSION@
+Source: @NPKG_PROJECT_NAME@
+Binary: @NPKG_PROJECT_NAME@-bin
+Architecture: any
+Version: 2.0-0
+Maintainer: @PROJECT_AUTHOR@ <@PROJECT_AUTHOR_MAIL@>
+Standards-Version: 3.8.2
+Homepage: @PROJECT_URL@
+Build-Depends: debhelper (>= 5),
+ pkg-config,
+ cmake,
+ gcc,
+ g++,
+@DEB_PKG_DEPS@
+Debtransform-Tar: @NPKG_PROJECT_NAME@_@PROJECT_VERSION@.orig.tar.gz
diff --git a/template.d/deb-config.install.in b/template.d/deb-config.install.in
new file mode 100644
index 0000000..5858efd
--- /dev/null
+++ b/template.d/deb-config.install.in
@@ -0,0 +1,2 @@
+/opt/AGL/*
+/etc/profile.d/*
diff --git a/template.d/debian.changelog.in b/template.d/debian.changelog.in
new file mode 100644
index 0000000..f72c717
--- /dev/null
+++ b/template.d/debian.changelog.in
@@ -0,0 +1,5 @@
+@NPKG_PROJECT_NAME@ (@PROJECT_VERSION@-0) UNRELEASED; urgency=low
+
+ * init build
+
+ -- @PROJECT_AUTHOR@ <@PROJECT_AUTHOR_MAIL@> Mon, 25 Dec 2007 10:50:38 +0100
diff --git a/template.d/debian.compat.in b/template.d/debian.compat.in
new file mode 100644
index 0000000..45a4fb7
--- /dev/null
+++ b/template.d/debian.compat.in
@@ -0,0 +1 @@
+8
diff --git a/template.d/debian.control.in b/template.d/debian.control.in
new file mode 100644
index 0000000..ea4ad8a
--- /dev/null
+++ b/template.d/debian.control.in
@@ -0,0 +1,16 @@
+Priority: optional
+Maintainer: @PROJECT_AUTHOR@ <@PROJECT_AUTHOR_MAIL@>
+Source: @NPKG_PROJECT_NAME@
+Build-Depends: debhelper (>= 5),
+ pkg-config,
+ cmake,
+ gcc,
+ g++,
+@DEB_PKG_DEPS@
+Standards-Version: 3.8.2
+Homepage: @PROJECT_URL@
+
+Package: @NPKG_PROJECT_NAME@
+Section: libs
+Architecture: any
+Description: @PROJECT_DESCRIPTION@
diff --git a/template.d/debian.rules.in b/template.d/debian.rules.in
new file mode 100644
index 0000000..6bb2825
--- /dev/null
+++ b/template.d/debian.rules.in
@@ -0,0 +1,87 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Uncomment this to turn on verbose mode.
+export DH_VERBOSE=1
+
+# These are used for cross-compiling and for saving the configure script
+# from having to guess our platform (since we know it already)
+DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+
+
+CFLAGS = -Wall -g
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+else
+ CFLAGS += -O2
+endif
+ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
+ INSTALL_PROGRAM += -s
+endif
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+ #
+ touch configure-stamp
+
+build: build-stamp
+build-stamp: configure-stamp
+ dh_testdir
+ mkdir -p build
+ cd build;cmake ../ -DCMAKE_INSTALL_PREFIX:PATH=/opt/AGL/@PROJECT_NAME@ -DCMAKE_INSTALL_LIBDIR:PATH=lib/$(DEB_HOST_MULTIARCH);$(MAKE)
+ #
+ touch build-stamp
+
+clean:
+ #dh_testdir
+ dh_testroot
+ rm -f configure-stamp build-stamp
+ [ ! -f Makefile ] || $(MAKE) distclean
+ #dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_prep
+ dh_installdirs
+ # Add here commands to install the package into debian/tmp
+ mkdir -p debian/tmp/opt/AGL/@PROJECT_NAME@;cd build;make populate;cp -r package/* ../debian/tmp/opt/AGL/@PROJECT_NAME@/
+ mkdir -p debian/tmp/etc/profile.d
+ echo '#---------- AGL @PROJECT_NAME@ options Start ---------" ' > debian/tmp/etc/profile.d/AGL_@PROJECT_NAME@.sh
+ echo '# Object: AGL cmake option for binder/bindings' >> debian/tmp/etc/profile.d/AGL_@PROJECT_NAME@.sh
+ echo 'export LD_LIBRARY_PATH=/opt/AGL/@PROJECT_NAME@/lib/$(DEB_HOST_MULTIARCH):$$LD_LIBRARY_PATH' >> debian/tmp/etc/profile.d/AGL_@PROJECT_NAME@.sh
+ echo 'export LIBRARY_PATH=/opt/AGL/@PROJECT_NAME@/lib/$(DEB_HOST_MULTIARCH):$$LIBRARY_PATH' >> debian/tmp/etc/profile.d/AGL_@PROJECT_NAME@.sh
+ echo 'export PATH=/opt/AGL/@PROJECT_NAME@/bin:$$PATH' >> debian/tmp/etc/profile.d/AGL_@PROJECT_NAME@.sh
+ echo '#---------- AGL options End ---------' >> debian/tmp/etc/profile.d/AGL_@PROJECT_NAME@.sh
+ # Move all files in their corresponding package
+ dh_install --list-missing -s --sourcedir=debian/tmp
+ # empty dependency_libs in .la files
+ #sed -i "/dependency_libs/ s/'.*'/''/" `find debian/ -name '*.la'`
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installchangelogs
+ dh_installdocs
+ dh_installexamples
+ dh_installman
+ dh_link
+ dh_strip
+ dh_compress
+ dh_fixperms
+ dh_makeshlibs -V
+ dh_installdeb
+ dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
diff --git a/template.d/gdb-native-target.ini.in b/template.d/gdb-native-target.ini.in
new file mode 100644
index 0000000..1ba6bdb
--- /dev/null
+++ b/template.d/gdb-native-target.ini.in
@@ -0,0 +1,35 @@
+# gdb-remote.init file for IDE
+# Object: allow to use standard gdb to remote debug a target
+# Usage: remote-target-populate update script under ./build directory
+# Author: Fulup Ar Foll (IoT.bzh)
+# Reference: https://blog.flameeyes.eu/2010/02/remote-debugging-with-gdb-part-2-gdb/
+#
+# Warning: In remote native mode netbeans impose debug-command to point on a local instance of afb-daemon binary
+
+# Fulup Hoops: --ldpath should be absolute as solib-search-path refuse to work as documented
+
+# Start gdbserver on target and connect through SSH link WARNING:
+target remote | ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null @RSYNC_TARGET@ gdbserver - afb-daemon --port=@AFB_REMPORT@ --workdir=$HOME/@RSYNC_PREFIX@/@PROJECT_NAME@ --roothttp=htdocs --ldpaths=$HOME/@RSYNC_PREFIX@/@PROJECT_NAME@/lib --verbose --token=@AFB_TOKEN@
+
+# Disable auto answer no on questions and to set breakpoint
+set confirm off
+
+# Disable auto load of libraries to improved perf
+set auto-solib-add off
+
+# Define path for project libraries
+set solib-search-path ${PROJECT_PKG_BUILD_DIR}
+
+# Replace run by continue (gdb use 'run' when gdbserver wants 'continue')
+define run
+continue
+end
+
+# Manually load project libraries when loaded by afb-daemon
+tbreak @GDB_INITIAL_BREAK@
+commands
+sharedlibrary @RSYNC_PREFIX@/@PROJECT_NAME@
+continue
+end
+
+
diff --git a/template.d/install-wgt-on-target.sh.in b/template.d/install-wgt-on-target.sh.in
new file mode 100755
index 0000000..39a69d5
--- /dev/null
+++ b/template.d/install-wgt-on-target.sh.in
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# File: install-wgt-on-target.sh
+# Author: Sebastien Douheret @ IoT.bzh
+# Object: install widget on target
+# Created on 24-May-2017, 09:23:37
+# Usage:
+
+# Do not change manually use 'make remote-target-populate'
+export RSYNC_TARGET=@RSYNC_TARGET@
+export WGT_FILE_L=@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.wgt
+export WGT_FILE_T=/tmp/@PROJECT_NAME@.wgt
+
+scp $WGT_FILE_L $RSYNC_TARGET:$WGT_FILE_T \
+ && ssh -o "StrictHostKeyChecking no" -tt $RSYNC_TARGET -- \
+ afm-util install $WGT_FILE_T
+
+# && rm -f $WGT_FILE_T
+
diff --git a/template.d/rpm-config.spec.in b/template.d/rpm-config.spec.in
new file mode 100644
index 0000000..8b3d442
--- /dev/null
+++ b/template.d/rpm-config.spec.in
@@ -0,0 +1,62 @@
+###########################################################################
+# Copyright 2015, 2016, 2017 IoT.bzh
+#
+# author: @PROJECT_AUTHOR@ <@PROJECT_AUTHOR_MAIL@>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###########################################################################
+
+
+Name: @NPKG_PROJECT_NAME@
+Version: @PROJECT_VERSION@
+Release: 1
+Group: AGL
+License: @PROJECT_LICENSE@
+Summary: @PROJECT_DESCRIPTION@
+Url: @PROJECT_URL@
+Source0: %{name}_%{version}.orig.tar.gz
+
+BuildRequires: cmake
+BuildRequires: gcc gcc-c++
+@RPM_PKG_DEPS@
+
+BuildRoot: %{_tmppath}/%{name}-%{version}-build
+
+%define _prefix /opt/AGL/@PROJECT_NAME@
+%define __cmake cmake
+
+%description
+@PROJECT_DESCRIPTION@
+
+%prep
+%setup -q
+
+%build
+%cmake -DBINDINGS_INSTALL_PREFIX:PATH=%{_libdir}
+make %{?_smp_mflags}
+
+%install
+CURDIR=$(pwd)
+[ -d build ] && cd build
+make populate
+mkdir -p %{?buildroot}%{_prefix}
+cp -r package/* %{?buildroot}%{_prefix}
+
+cd $CURDIR
+find %{?buildroot}%{_prefix} -type d -exec echo "%dir {}" \;>> pkg_file
+find %{?buildroot}%{_prefix} -type f -exec echo "{}" \;>> pkg_file
+sed -i 's@%{?buildroot}@@g' pkg_file
+
+
+%files -f pkg_file
+%defattr(-,root,root)
diff --git a/template.d/start-on-target.sh.in b/template.d/start-on-target.sh.in
new file mode 100755
index 0000000..9e3a60d
--- /dev/null
+++ b/template.d/start-on-target.sh.in
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# File: start-on-target.sh
+# Author: Fulup Ar Foll @ IoT.bzh
+# Object: Forward signal (SIGTERM) to remote process
+# Created on 24-May-2017, 09:23:37
+# Usage: remote-target-populate update script under ./build directory
+
+# Do not change manually use 'make remote-target-populate'
+export RSYNC_TARGET=@RSYNC_TARGET@
+export PROJECT_NAME=@PROJECT_NAME@
+export RSYNC_PREFIX=@RSYNC_PREFIX@/@PROJECT_NAME@
+export AFB_REMPORT=@AFB_REMPORT@
+export AFB_TOKEN=@AFB_TOKEN@
+
+exec ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -tt $RSYNC_TARGET << EOF
+ afb-daemon --workdir=$RSYNC_PREFIX --port=$AFB_REMPORT --roothttp=./htdocs --ldpath=./lib --verbose --token=$AFB_TOKEN &
+ PID_DAEMON=\$!
+
+ trap "echo REMOTE-SIGNAL TRAP; kill -15 \$PID_DAEMON" INT QUIT TERM EXIT
+
+ # wait for daemon to finish
+ wait \$PID_DAEMON
+ exit
+EOF