aboutsummaryrefslogtreecommitdiffstats
path: root/docs/part-1/4-2_build-first-app-cmd.md
blob: c878d0879563683f6d8cfa6941c656c2d57b55b2 (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
# Build using command line tool

## Declare project

Use XDS command line tool named [xds-cli](../part-2/3_xds-cli/0_abstract.html) to declare your
project from command line and more precisely the `projects add` command
(short option: `prj add`).

```bash
xds-cli prj add --label="Project_helloworld-native-application" --type=pm --path=/home/seb/xds-workspace/helloworld-native-application --server-path=/home/devel/xds-workspace/helloworld-native-application
```

> **Note:** option `--url=http://localhost:1234` may be added to `xds-cli` in
> order to set url of `xds-agent` in case of agent is not running on default
> port (for example here, 1234)

## Build 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 `xds-cli` tool and `projects list` command (short: `prj ls`):

```bash
xds-cli prj ls
ID                                       Label                                   LocalPath
f9904f70-d441-11e7-8c59-3c970e49ad9b     Project_helloworld-service              /home/seb/xds-workspace/helloworld-service
4021617e-ced0-11e7-acd2-3c970e49ad9b     Project_helloworld-native-application   /home/seb/xds-workspace/helloworld-native-application
```

XDS tools, including `xds-cli` are installed by default in `/opt/AGL/bin`
directory and this path has been added into your PATH variable.

If it is not the case, just add it manually using `export PATH=${PATH}:/opt/AGL/bin` command line.

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

<!-- section-note -->
**Note:**

Short id notation is also supported as soon as given id value is non ambiguous.

For example, to refer to Project_helloworld-native-application project listed
in above command, you can simply use --id 40 instead of --id 4021617e-ced0-11e7-acd2-3c970e49ad9b
<!-- end-section-note -->

You also need to determine the ID of the cross SDK you want to use to cross build
you application.

To list installed SDK, use the following command:

```bash
xds-cli sdks ls
List of installed SDKs:
  ID                                    NAME
  7aa19224-b769-3463-98b1-4c029d721766  aarch64  (3.99.1+snapshot)
  41a1efc4-8443-3fb0-afe5-8313e0c96efd  corei7-64  (3.99.2+snapshot)
  c226821b-b5c0-386d-94fe-19f807946d03  aarch64  (3.99.3)
```

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
# First, grab your target IP address, or it's DNS name
export TARGET_ADDRESS=<target_adress>

# Go into your project directory and create a build directory
cd $MY_PROJECT_DIR
mkdir build

# Generate build system using cmake
# RSYNC_* variables must be set to allow deployment/populate widgets on target (see app-template doc for more info)
xds-cli exec --id=4021617e --sdkid=c226821b -- "export RSYNC_TARGET=root@${TARGET_ADDRESS} ; export RSYNC_PREFIX=/opt ; cd build && cmake .."

# Build the project
xds-cli exec --id=4021617e --sdkid=c226821b -- "cd build && make widget"
```

<!-- section-note -->
**Note:** If you use `&&`, `||` or `;` statement in the executed command line,
you need to double quote the command, for example `"cd build && make`.
<!-- end-section-note -->

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

Note that XDS creates a file named `xds-project.conf` (only if not already exists)
when you declare a new project using XDS Dashboard (or using `xds-cli prj add...`).
Edit this file if needed and then refer it with `--config` option.

For example, the equivalence of above command is:

```bash
# MY_PROJECT_DIR=/home/seb/xds-workspace/helloworld-native-application
cd $MY_PROJECT_DIR

# Edit and potentially adapt xds-project.conf file that has been created
# automatically on project declaration using XDS Dashboard
cat xds-project.conf
  # XDS project settings
  export XDS_AGENT_URL=localhost:8800
  export XDS_PROJECT_ID=4021617e-ced0-11e7-acd2-3c970e49ad9b
  export XDS_SDK_ID=c226821b-b5c0-386d-94fe-19f807946d03

# Create build directory and invoke cmake and then build project
xds-cli exec --config=./xds-project.conf -- "mkdir -p build && cd build && cmake .."
cd build && xds-cli exec --config=../xds-project.conf -- "make all"

# Or equivalent by first sourcing conf file (avoid to set --config option)
source xds-project.conf
xds-cli exec "mkdir -p build && cd build && cmake .."
cd build && xds-cli exec "make all"
```

<!-- section-note -->
**Note:** all parameters after a double dash (--) are considered as the command
to execute.
<!-- end-section-note -->