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