summaryrefslogtreecommitdiffstats
path: root/docs/part-2/3_xds-exec.md
blob: 7899ba9ad1b2bde3639a79651803a641a92b1c85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# xds-exec: wrapper on exec for XDS

`xds-exec` is a wrapper on exec linux command for X(cross) Development System.

As well as `xds-exec` is a wrapper on exec command and can be use to execute any
command on a remote `xds-server`.

This tool can be used in lieu of "standard" `exec` command to execute any
command on a remote `xds-server`. For example you can trig your project build by
executing : `xds-exec --config conf.env -- make build`

> **SEE ALSO**:
>  - [xds-agent](https://github.com/iotbzh/xds-agent), an agent that should run
on your local host in order to use XDS.
>  - [xds-server](https://github.com/iotbzh/xds-server), a web server
used to remotely cross build applications.

## Getting Started

You must have a running `xds-server` (locally or on the Cloud), see
[README of xds-server](https://github.com/iotbzh/xds-server/blob/master/README.md)
for more details.

Connect your favorite Web browser to the XDS dashboard (default url
http://localhost:8000) and follow instructions to start local `xds-agent` on
your local host. Please refer to instructions provided by XDS dashboard or see
`README of xds-agent`.

Then create your project you XDS dashboard.

### Installing xds-exec

#### Install package for debian distro type

```bash
export DISTRO="Debian_8.0"
wget -O - http://download.opensuse.org/repositories/isv:/LinuxAutomotive:/app-Development/${DISTRO}/Release.key | sudo apt-key add -
sudo bash -c "cat >> /etc/apt/sources.list.d/AGL.list <<EOF
deb http://download.opensuse.org/repositories/isv:/LinuxAutomotive:/app-Development/${DISTRO}/ ./
EOF
"
sudo apt-get update
sudo apt-get install agl-xds-exec
```

The value 'DISTRO' can be set to {Debian_8.0, Debian_9.0, xUbuntu_16.04, xUbuntu_16.10, xUbuntu_17.04}

Update the package

```bash
sudo apt-get update
sudo apt-get upgrade agl-xds-exec
```

The files are install here:

```bash
/opt/AGL/agl-xds-exec
```

#### Install package for rpm distro type

##### openSUSE

```bash
export DISTRO="openSUSE_Leap_42.2"
sudo zypper ar http://download.opensuse.org/repositories/isv:/LinuxAutomotive:/app-Development/${DISTRO}/isv:LinuxAutomotive:app-Development.repo
sudo zypper ref
sudo zypper install agl-xds-exec
```

The value 'DISTRO' can be set to {openSUSE_Leap_42.2, openSUSE_Leap_42.3, openSUSE_Tumbleweed}

Update the package

```bash
sudo zypper ref
sudo zypper install --force agl-xds-exec
```

The files are install here:

```bash
/opt/AGL/agl-xds-exec
```

### Using xds-exec from command line

You need to determine which is the unique id of your project. You can find
this ID in project page of XDS dashboard or you can get it from command line
using the `--list` option. This option lists all existing projects ID:

```bash
./bin/xds-exec --list

List of existing projects:
  CKI7R47-UWNDQC3_myProject
  CKI7R47-UWNDQC3_test2
  CKI7R47-UWNDQC3_test3
```

Now to refer your project, just use --id option or use `XDS_PROJECT_ID`
environment variable.

You are now ready to use XDS to for example cross build your project.
Here is an example to build a project based on CMakefile:

```bash
# Add xds-exec in the PATH
export PATH=${PATH}:/opt/AGL/agl-xds-exec

# Go into your project directory
cd $MY_PROJECT_DIR

# Create a build directory
xds-exec --id=CKI7R47-UWNDQC3_myProject --sdkid=poky-agl_aarch64_4.0.1 --url=http://localhost:8000 -- mkdir build

# Generate build system using cmake
xds-exec --id=CKI7R47-UWNDQC3_myProject --sdkid=poky-agl_aarch64_4.0.1 --url=http://localhost:8000 -- cd build && cmake ..

# Build the project
xds-exec --id=CKI7R47-UWNDQC3_myProject --sdkid=poky-agl_aarch64_4.0.1 --url=http://localhost:8000 -- cd build && make all
```

To avoid to set project id, xds server url, ... at each command line, you can
define these settings as environment variable within an env file and just set
`--config` option or source file before executing xds-exec.

For example, the equivalence of above command is:

```bash
cat > config.env << EOF
 export XDS_SERVER_URL=localhost:8000
 export XDS_PROJECT_ID=CKI7R47-UWNDQC3_myProject
 export XDS_SDK_ID=poky-agl_aarch64_4.0.1
EOF

xds-exec --config config.env -- mkdir build

# Or sourcing env file
source config.env
xds-exec -- cd build && cmake ..
xds-exec -- cd build && make all
```

### Using xds-exec within an IDE

#### Visual Studio Code

Open your project in VSC

```bash
cd $MY_PROJECT_DIR
code . &
```
Add new tasks : press `Ctrl+Shift+P` and select the `Tasks: Configure Task Runner` command and you will see a list of task runner templates.

And define your own tasks, here is an example to build [unicens2-binding](https://github.com/iotbzh/unicens2-binding) AGL binding based on cmake (_options value of args array must be updated regarding your settings_):

```json
{
    "version": "0.1.0",
    "linux": {
        "command": "/opt/AGL/agl-xds-exec/xds-exec"
    },
    "isShellCommand": true,
    "args": [
        "-url", "localhost:8010",
        "-id", "W2EAQBA-HQI75XA_unicens2-binding",
        "-sdkid", "poky-agl_aarch64_4.0.1",
        "--"
    ],
    "showOutput": "always",
    "tasks": [{
            "taskName": "clean",
            "suppressTaskName": true,
            "args": [
                "rm -rf build/* && echo Cleanup done."
            ]
        },
        {
            "taskName": "pre-build",
            "isBuildCommand": true,
            "suppressTaskName": true,
            "args": [
                "mkdir -p build && cd build && cmake -DRSYNC_TARGET=root@192.168.168.11 -DRSYNC_PREFIX=./opt"
            ]
        },
        {
            "taskName": "build",
            "isBuildCommand": true,
            "suppressTaskName": true,
            "args": [
                "cd build && make widget"
            ],
            "problemMatcher": {
                "owner": "cpp",
                "fileLocation": ["absolute"],
                "pattern": {
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            }
        },
        {
            "taskName": "populate",
            "suppressTaskName": true,
            "args" : [
                "cd build && make widget-target-install"
            ]
        }
    ]
}
```

> **NOTE** You can also add your own keybindings to trig above tasks, for example:
> ```json
> // Build
> {
>   "key": "alt+f9",
>   "command": "workbench.action.tasks.runTask",
>   "args": "clean"
> },
> {
>   "key": "alt+f10",
>   "command": "workbench.action.tasks.runTask",
>   "args": "pre-build"
> },
> {
>   "key": "alt+f11",
>   "command": "workbench.action.tasks.runTask",
>   "args": "build"
> },
> {
>   "key": "alt+f12",
>   "command": "workbench.action.tasks.runTask",
>   "args": "populate"
> },
> ```
>
> More details about VSC keybindings [here](https://code.visualstudio.com/docs/editor/tasks#_binding-keyboard-shortcuts-to-tasks)
>
> More details about VSC tasks [here](https://code.visualstudio.com/docs/editor/tasks)

#### Qt Creator
Please refer to [agl-hello-qml](https://github.com/radiosound-com/agl-hello-qml#clone--build-project) project.
Thanks to Dennis for providing this useful example.

#### Others IDE
*Coming soon...*


## How to build

### Prerequisites
 You must install and setup [Go](https://golang.org/doc/install) version 1.7 or
 higher to compile this tool.

### Building
Clone this repo into your `$GOPATH/src/github.com/iotbzh` and use delivered Makefile:
```bash
 export GOPATH=$(realpath ~/workspace_go)
 mkdir -p $GOPATH/src/github.com/iotbzh
 cd $GOPATH/src/github.com/iotbzh
 git clone https://github.com/iotbzh/xds-exec.git
 cd xds-exec
 make
```

## Debug

Visual Studio Code launcher settings can be found into `.vscode/launch.json`.

>**Tricks:** To debug both `xds-exec` (client part) and `xds-server` (server part),
it may be useful use the same local sources.
So you should replace `xds-server` in `vendor` directory by a symlink.
So clone first `xds-server` sources next to `xds-exec` directory.
You should have the following tree:
```
> tree -L 3 src
src
|-- github.com
    |-- iotbzh
       |-- xds-exec
       |-- xds-server
```
Then invoke `vendor/debug` Makefile rule to create a symlink inside vendor
directory :
```bash
cd src/github.com/iotbzh/xds-exec
make vendor/debug
```