877f14c544d213108a0741e5031f4c6e74c1cefd
[apps/agl-service-unicens.git] / README.md
1 ------------------------------------------------------------------------
2 AGL-UNICENS binding expose UNICENS-V2 APIs through AGL framework
3 ------------------------------------------------------------------------
4
5 Cloning Audio-Binding from Git
6 -------------------------------------------------------
7
8 ```
9 git clone https://github.com/iotbzh/unicens2-binding
10 cd  unicens2-binding
11 git submodule update --recursive --init
12 ```
13
14 AFB_daemon dependency on Standard Linux Distributions
15 -------------------------------------------------------
16     # handle dependencies > (OpenSuse-42.2, Fedora-25, Ubuntu 16.04.2LTS)
17     gcc > 4.8
18     systemd-devel (libsystemd-dev>=222)
19     libuuid-devel
20     file-devel(OpenSuSe) or libmagic-dev(Ubuntu)
21     libjson-c-devel
22     alsa-devel
23     ElectricFence (BUG should not be mandatory)
24     libopenssl-devel libgcrypt-devel libgnutls-devel (optional but requested by libmicrohttpd for https)
25
26     OpenSuse >=42.2
27       zypper in gcc5 gdb gcc5-c++ git cmake make ElectricFence systemd-devel libopenssl-devel  libuuid-devel alsa-devel libgcrypt-devel libgnutls-devel libjson-c-devel file-devel mxml-devel
28
29     Ubuntu >= 16.4 libuuid-devel
30       apt-get install cmake git electric-fence libsystemd-dev libssl-dev uuid-dev libasound2-dev libgcrypt20-dev libgnutls-dev libgnutls-dev libjson-c-dev libmagic-dev  libmxml-dev
31
32     libmicrohttpd>=0.9.55 (as today OpenSuse-42.2 or Ubuntu-.16.4 ship older versions)
33     afb-daemon from AGL Gerrit git clone https://gerrit.automotivelinux.org/gerrit/src/app-framework-binder
34
35 ```
36     # Might want to add following variables into ~/.bashrc
37     echo "#----------  AGL options Start ---------" >>~/.bashrc
38     echo "# Object: AGL cmake option for  binder/bindings" >>~/.bashrc
39     echo "# Date: `date`" >>~/.bashrc
40     echo 'export CC=gcc-5; export CXX=g++-5' >>~/.bashrc   # if using gcc5
41     echo 'export INSTALL_PREFIX=$HOME/opt' >>~/.bashrc
42     echo 'export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib64:$INSTALL_PREFIX/lib' >>~/.bashrc
43     echo 'export LIBRARY_PATH=$INSTALL_PREFIX/lib64:$INSTALL_PREFIX/lib' >>~/.bashrc
44     echo 'export PKG_CONFIG_PATH=$INSTALL_PREFIX/lib64/pkgconfig:$INSTALL_PREFIX/lib/pkgconfig' >>~/.bashrc
45     echo 'export PATH=$INSTALL_PREFIX/bin:$PATH' >>~/.bashrc
46     echo 'export RSYNC_TARGET=MY_TARGET_HOSTNAME' >>~/.bashrc
47     echo 'export RSYNC_PREFIX=./opt' >>~/.bashrc
48
49     echo "#----------  AGL options End ---------" >>~/.bashrc
50     source ~/.bashrc
51
52     # install LibMicroHttpd
53     LIB_MH_VERSION=0.9.55
54     wget https://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-${LIB_MH_VERSION}.tar.gz
55     tar -xzf libmicrohttpd-${LIB_MH_VERSION}.tar.gz
56     cd libmicrohttpd-${LIB_MH_VERSION}
57     ./configure --prefix=${INSTALL_PREFIX}
58     make
59     sudo make install-strip
60
61     # retrieve last AFB_daemon from AGL
62     git clone https://gerrit.automotivelinux.org/gerrit/src/app-framework-binder
63
64     # Warning: previous GCC options should be set before initial cmake (clean Build/*)
65     cd app-framework-binder; mkdir -p build; cd build
66     cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX ..
67     make
68     make install
69 ```
70
71
72 # Compile binding
73
74 ```
75     source ~/.bashrc  # or any other file where your have place your compilation preferences
76     mkdir -p build
77     cd build
78     cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX ..
79     make
80
81     afb-daemon --workdir=.. --ldpaths=build --port=1234  --roothttp=./htdocs --token="" --verbose
82
83     speaker-test -twav -D hw:ep01 -c 2
84     firefox http://localhost:1234
85 ```
86
87 # Archive
88
89 ```
90 VERSION=0.1
91 GIT_TAG=master
92 PKG_NAME=UNICENS-agent
93 git archive --format=tar.gz --prefix=${PKG_NAME}-${VERSION}/ ${GIT_TAG} -o ${PKG_NAME}_${VERSION}.orig.tar.gz
94 ```
95
96 # Local Source Debug with GDB
97
98 Warning: technically AGL bindings are shared libraries loaded thought 'dlopen'. GDB supports source debug of dynamically
99 loaded libraries, but user should be warn that the actual path to sharelib symbols is directly inherited from DLOPEN.
100 As a result if you change your directory after binder start with --workdir=xxx then GDB will not find symbols anymore
101
102
103 ```
104     Examples:
105
106     # WORK when running in direct
107     afb-daemon --workdir=.. --ldpaths=build --port=1234 --roothttp=./htdocs
108
109     # FAIL when using GDB with warning: Could not load shared library ....
110     gdb -args afb-daemon --workdir=.. --ldpaths=build --port=1234 --roothttp=./htdocs
111     ...
112     warning: Could not load shared library symbols for ./build/ucs2-afb/afb-ucs2.so.
113     Do you need "set solib-search-path" or "set sysroot"?
114     ...
115 ```
116
117 To debug sharelib symbol path: start your binder under GDB. Then break your session after the binder has
118 loaded its bindings. Finally use "info sharedlibrary" and check 'SymsRead'. If equal to 'No' then either you start GDB
119 from the wrong relative directory, either you have to use 'set solib-search-path' to force the path.
120
121 ```
122     gdb -args afb-daemon --workdir=.. --ldpaths=build --port=1234 --roothttp=./htdocs
123     run
124         ...
125         NOTICE: API UNICENS added
126         NOTICE: Waiting port=1234 rootdir=.
127         NOTICE: Browser URL= http://localhost:1234
128     (hit Ctrl-C to break the execution)
129     info sharedlibrary afb-*
130 ```
131
132
133 # Running an debugging on a target
134
135 ```
136 export RSYNC_TARGET=root@xx.xx.xx.xx
137 export RSYNC_PREFIX=/opt    # WARNING: installation directory should exist
138
139 mkdir $RSYNC_TARGET
140 cd    $RSYNC_TARGET
141
142 cmake -DRSYNC_TARGET=$RSYNC_TARGET -DRSYNC_PREFIX=$RSYNC_PREFIX ..
143 make remote-target-populate
144
145     ./build/target/start-${RSYNC_TARGET}.sh
146     firefox http://localhost:1234    # WARNING: do not forget firewall if any
147
148     ssh -tt ${RSYNC_TARGET} speaker-test -twav -D hw:ep01 -c 2
149 ```
150
151 Note: remote-target-populate will
152  - create a script to remotely start the binder on the target in ./build/target/start-on-target-name.sh
153  - create a gdbinit file to transparently debug remotely in source code with gdb -x ./build/target/gdb-on-target-name.ini
154  - to run and debug directly from your IDE just configure the run and debug properties with the corresponding filename
155
156 Note that Netbeans impose to set debug directory to ./build/pkgout or it won't find binding symbols for source debugging
157
158