diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2018-01-18 09:44:34 +0100 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2018-01-18 09:44:34 +0100 |
commit | bd814eafac20a5264782bad69ce2df1599921c68 (patch) | |
tree | 7b2f14fec5457d1fdc1ed4a0d7236d6f09525dca /docs/part-1/4-2_build-first-app-cmd.md | |
parent | 2a297d08d6b686abe9ab8404a15aa892f4832e25 (diff) |
Split markdown files to have a detailed TOC/summary.
Change-Id: I7d578335ba0d1719030bc2efc6518da17a6150dc
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'docs/part-1/4-2_build-first-app-cmd.md')
-rw-r--r-- | docs/part-1/4-2_build-first-app-cmd.md | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/docs/part-1/4-2_build-first-app-cmd.md b/docs/part-1/4-2_build-first-app-cmd.md new file mode 100644 index 0000000..02de723 --- /dev/null +++ b/docs/part-1/4-2_build-first-app-cmd.md @@ -0,0 +1,117 @@ +# 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. + +<!-- 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 +<!-- endnote --> + +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 +# Go into your project directory and create a build directory +cd $MY_PROJECT_DIR +mkdir build + +# Generate build system using cmake +xds-cli exec --id=4021617e --sdkid=c226821b -- "cd build && cmake .." + +# Build the project +xds-cli exec --id=4021617e --sdkid=c226821b -- "cd build && make all" +``` + +<!-- note --> +**Note:** If you use `&&`, `||` or `;` statement in the executed command line, +you need to double quote the command, for example `"cd build && make`. +<!-- endnote --> + +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" +``` + +<!-- note --> +**Note:** all parameters after a double dash (--) are considered as the command +to execute. +<!-- endnote --> |