1 <!-- WARNING: This file is generated by fetch_docs.js using /home/boron/Documents/AGL/docs-webtemplate/site/_data/tocs/devguides/master/xds-docs-guides-devguides-book.yml -->
3 # Build Using the Command Line
5 One option for building your application using XDS is to use
6 the command line (i.e. `xds-cli`).
7 Building the application consists of declaring your project, identifying
8 some key ID values, and then using the command line to build it.
13 XDS tools, including `xds-cli`, are installed by default in
14 the `/opt/AGL/bin` directory.
15 During installation, this directory is automatically added to your
17 If, for some reason, the tool is not in your `PATH` directory,
18 you can manually add it using the `export PATH=${PATH}:/opt/AGL/bin`
20 <!-- end-section-note -->
25 Use the `projects add` command to declare your project:
28 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
31 When you declare the project, XDS creates the `xds-project.conf`
32 configuration file if one does not already exist.
33 You should examine this configuration file before you build the
34 project to be sure all configurations are correct for your project.
39 If the Server Part (i.e. `xds-agent`) is not running on the default
40 port, you can use the `--url=http://localhost:<port>` option with the
41 `xds-cli prj add` command to specify the port.
42 Just substitute the actual port for `<port>` with the option.
43 <!-- end-section-note -->
45 ## Determine the ID of Your Project
47 After declaring your project, you need to determine the
48 unique ID of your project.
50 From the command line, use the `prj ls` command, which is an abbreviation
51 for the `projects list` command:
56 f9904f70-d441-11e7-8c59-3c970e49ad9b Project_helloworld-service /home/seb/xds-workspace/helloworld-service
57 4021617e-ced0-11e7-acd2-3c970e49ad9b Project_helloworld-native-application /home/seb/xds-workspace/helloworld-native-application
60 Once you have the ID of the project, you can use the `--id` option
61 or the `XDS_PROJECT_ID` environment variable to refer to your project.
66 When using the project ID from the command line, you can use the "short"
67 notation by providing a non-ambiguous portion of the ID.
68 For example, to refer to the `Project_helloworld-native-application` project
69 shown in the previous example, you can use `-id 40` rather than
70 `--id 40 instead of --id 4021617e-ced0-11e7-acd2-3c970e49ad9b`.
71 <!-- end-section-note -->
73 ## Determine the ID of Your SDK
75 You also need to determine the ID of the SDK you want to use to cross-build
78 To list installed SDKs, use the following command:
82 List of installed SDKs:
84 7aa19224-b769-3463-98b1-4c029d721766 aarch64 (3.99.1+snapshot)
85 41a1efc4-8443-3fb0-afe5-8313e0c96efd corei7-64 (3.99.2+snapshot)
86 c226821b-b5c0-386d-94fe-19f807946d03 aarch64 (3.99.3)
89 SDK IDs are returned by architecture and version.
90 Be sure to identify the SDK you need.
92 ## Build the Application
94 You can now use XDS to cross-build your project.
95 Following is an example that builds a project that is based on CMake:
98 # First, export the target IP address, or it's DNS name
99 export TARGET_ADDRESS=<target_adress>
101 # Go into your project directory and create a build directory
106 Before using the command line to build the project, you should be
107 sure the project's configuration file is correct.
108 Examine the `xds-project.conf` configuration file and edit it
111 Generate the build system using CMake:
114 # You must set RSYNC_* variables so that you deploy and populate widgets on the target
115 xds-cli exec --id=4021617e --sdkid=c226821b -- "export RSYNC_TARGET=root@${TARGET_ADDRESS} ; export RSYNC_PREFIX=/opt ; cd build && cmake .."
118 Now you can build the project:
121 xds-cli exec --id=4021617e --sdkid=c226821b -- "cd build && make widget"
124 <!-- section-note -->
127 If you use `&&`, `||` or `;` statements in the executed command line,
128 you need to double quote the command (e.g. `"cd build && make"`).
129 <!-- end-section-note -->
131 To avoid having to set the project ID, SDK ID, and URL for each
132 command line, you can define these settings as environment variables
133 using an environment file.
134 Use the `--config` option or source file before executing
135 the `xds-cli` command.
137 To specify your configuration file with the command line,
138 use the `--config` option.
139 For example, the equivalent of the previous build command but
140 with a specified configuration file is as follows:
143 # MY_PROJECT_DIR=/home/seb/xds-workspace/helloworld-native-application
146 # Edit and potentially adapt xds-project.conf file that has been created
147 # automatically on project declaration using XDS Dashboard
149 # XDS project settings
150 export XDS_AGENT_URL=localhost:8800
151 export XDS_PROJECT_ID=4021617e-ced0-11e7-acd2-3c970e49ad9b
152 export XDS_SDK_ID=c226821b-b5c0-386d-94fe-19f807946d03
154 # Create build directory and invoke cmake and then build project
155 xds-cli exec --config=./xds-project.conf -- "mkdir -p build && cd build && cmake .."
156 cd build && xds-cli exec --config=../xds-project.conf -- "make all"
159 Alternatively, you could first source the configuration file to avoid using the
160 `--config` option as follows:
163 source xds-project.conf
164 xds-cli exec "mkdir -p build && cd build && cmake .."
165 cd build && xds-cli exec "make all"
168 <!-- section-note -->
171 All parameters after a double dash (`--`) are considered as the command
173 <!-- end-section-note -->