summaryrefslogtreecommitdiffstats
path: root/docs/part-1/create-app-build-ide.md
blob: cbf39f65622cedee8d7e977f6af47fd95c72c98d (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
# Build using an IDE

One option for building your application using XDS is to use
an Integrated Development Environment
([IDE](https://en.wikipedia.org/wiki/Integrated_development_environment)).
Many IDEs exist (e.g. [NetBeans](https://netbeans.org/),
[Visual Studio Code](https://code.visualstudio.com/),
[Qt Creator](https://www.qt.io/),
[Eclipse](https://www.eclipse.org/), and so forth).

This section first develops an XDS configuration file
(i.e. `xds-project.conf`) and then provides two
examples, NetBeans and Visual Studio, that do the following.

- NetBeans: Creates two separate build configurations
  for a project, which makes it easy to switch back and forth
  between types of builds.

- Visual Studio: Creates tasks that allow you to build an example
  based on CMake templates.

## XDS Configuration File

This section shows how to create an XDS configuration file
(i.e. `xds-project.conf`) or how to re-use an existing file.
For example, the following commands set up the configuration
file for an `aarch64` SDK to cross-build the
application for a Renesas Gen3 board.

```bash
# create file at root directory of your project
# for example:
# MY_PROJECT_DIR=/home/seb/xds-workspace/helloworld-native-application
cat > $MY_PROJECT_DIR/xds-project.conf << EOF
 export XDS_AGENT_URL=localhost:8800
 export XDS_PROJECT_ID=4021617e-ced0-11e7-acd2-3c970e49ad9b
 export XDS_SDK_ID=c226821b-b5c0-386d-94fe-19f807946d03
EOF
```

## NetBeans

This section creates two configurations: one to compile the
project natively using native GNU gcc, and one to cross-compile
the project using XDS.

Having two configurations allows you to easily switch between them
using NetBean's **Run -> Set Project Configuration** menu.

### Native Configuration

Follow these steps to create the native configuration:

1. Open the **Tools** -> **Options** menu.

2. Open the **C/C++** tab.

3. Click on the **Add** button in the **Build Tools** sub-tab:

   ![Add new tool panel](./pictures/nb_newtool.png){:: style="width:90%; max-width:700px; margin:auto; display:flex"}

4. Fill the **Make Command** and **Debugger Command** fields to point to the XDS tools:

   ![Add new tool panel](./pictures/nb_xds_options.png){:: style="width:90%; max-width:700px; margin:auto; display:flex"}

5. Click **OK**.

6. Select the **File** -> **New Project** menu item to declare the
   project and create a native configuration.

7. Select **C/C++ Project with Existing Sources** and click on **Next**.

8. Specify your project directory and set **Select Configuration Mode** to
   "Custom".
   Be sure to keep **Tool Collection** set to "Default GNU" in order to create a
   *native configuration*, which is based on the native GNU GCC.

9. Click **Next**.

   ![Select Model panel](./pictures/nb_new-project-1.png){:: style="width:90%; max-width:700px; margin:auto; display:flex"}

10. Update the **Run in Folder** field to add the `build_native` suffix.
    Doing so results in the build files being located in the
    `build_native` sub-directory.
    Be sure to keep the defaults for all other settings and then click **Next**.

    ![Select Model panel](./pictures/nb_new-project-2.png){:: style="width:90%; max-width:700px; margin:auto; display:flex"}

11. Click through **Next** several times while always keeping the
    default settings until the **Finish** button appears.

12. Click **Finish** to complete the creation of the native configuration.

### Cross-Compilation Configuration

Follow these steps to create the configuration for cross-compilation
based on the XDS tools:

1. Edit project properties (using menu **File** -> **Project Properties**)
   to add a new configuration that will use XDS to cross-compile
   your application for example for a Renesas Gen3 board.

2. in the **Build** category, click on **Manage Configurations** button
   and then **New** button to add a new configuration named for example
   "Gen3 board".

   ![Select Build category](./pictures/nb_new-project-3.png){:: style="width:90%; max-width:700px; margin:auto; display:flex"}

3. Click the **Set Active** button.

4. Select the **Pre-Build** sub-category, and set the following:

   - Working Directory: `build_gen3`
   - Command Line: `xds-cli exec -c ../xds-project.conf -- cmake -DRSYNC_TARGET=root@renesas-gen3 -DRSYNC_PREFIX=/opt ..`
   - Pre-build First: `ticked`<br/><br/>

5. Select the **Make** sub-category, and set the following:

   - Working Directory: `build_gen3`
   - Build Command: `xds-cli exec -c ../xds-project.conf -- make remote-target-populate`
   - Clean Command: `xds-cli exec -c ../xds-project.conf -- make clean`<br/><br/>

   ![Select Make sub-category](./pictures/nb_new-project-4.png){:: style="width:90%; max-width:700px; margin:auto; display:flex"}

6. Select the **Run** sub-category, and set the following:

   - Run Command: `target/start-on-root@renesas-gen3.sh`
   - Run Directory: `build-gen3`<br/><br/>

   ![Select Run  sub-category](./pictures/nb_new-project-5.png){:: style="width:90%; max-width:700px; margin:auto; display:flex"}

7. Click **OK** to save settings.

By changing the configuration from **Default** to **Gen3 board**, you can
compile your helloworld application natively, which is the default configuration.
Or, you can cross-compile your application using XDS for the Renesas Gen3 board,
which is the Gen3 board configuration.

## Visual Studio Code

This section presents a Visual Studio example that creates tasks
that allow you to build an example that is based on CMake templates.

Follow these steps:

1. Start Visual Studio Code and open your project using the
   following commands:

   ```bash
   cd $MY_PROJECT_DIR
   code . &
   ```

2. Add new tasks by entering the `Ctrl+Shift+P` key combination and selecting
   the `Tasks: Configure Task` command.
   A list of task runner templates appears.

3. Define your own tasks.
   Following is an example that builds the
   [helloworld-native-application](https://github.com/iotbzh/helloworld-native-application)
   that is based on CMake templates.

   ```json
   {
       "version": "2.0.0",
       "type": "shell",
       "presentation": {
           "reveal": "always"
       },
       "tasks": [
           {
               "label": "clean",
               "type": "shell",
               "command": "/bin/rm -rf ${workspaceFolder}/build/* && mkdir -p build && echo Cleanup done.",
               "problemMatcher": []
           },
           {
               "label": "pre-build",
               "type": "shell",
               "group": "build",
               "command": "/opt/AGL/bin/xds-cli exec --rpath build --config xds-project.conf -- cmake -DRSYNC_TARGET=root@renesas-gen3 -DRSYNC_PREFIX=/opt ../",
               "problemMatcher": [
                   "$gcc"
               ]
           },
           {
               "label": "build",
               "type": "shell",
               "group": "build",
               "command": "/opt/AGL/bin/xds-cli exec --rpath build --config xds-project.conf -- make widget",
               "problemMatcher": [
                   "$gcc"
               ]
           },
           {
               "label": "populate",
               "type": "shell",
               "command": "/opt/AGL/bin/xds-cli exec --rpath build --config xds-project.conf -- make widget-target-install",
               "problemMatcher": []
           }
       ]
   }
   ```

4. Run a task by entering the `Ctrl+Shift+P` key combination and
   selecting `Tasks: Run task` and then selecting the specific task.
   For example, select `pre-build` to trigger pre-build task.

5. Optionally add keybindings that trigger tasks.
   Following is an 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"
   },
   ```

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

   - You can find more details about Visual Source Code keybindings
     [here](https://code.visualstudio.com/docs/editor/tasks#_binding-keyboard-shortcuts-to-tasks).

   - You can find more details about Visual Source Code tasks
     [here](https://code.visualstudio.com/docs/editor/tasks).
   <!-- end-section-note -->