0

Update docs/clion.md

- Replaced 'Building, Running, and Debugging' section
  - Previously, this section was incomplete and only described how to
build chromium.
  - Added instructions to run and visually debug as well.
  - Updated build instructions to support debugging.
- Simplified recommended CMakeLists.txt file
- Simplified instructions for creating a desktop entry
- Increased recommended VM option Xmx from 5g to 10g
- Marked optional steps as optional
- Punctuation fixes
- Added link to clion.md to docs/README.md

Change-Id: Id0514b1498517e0c10fafb1a9639aeda44717921
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1976280
Commit-Queue: manuk hovanesian <manukh@chromium.org>
Reviewed-by: Tommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726546}
This commit is contained in:
manukh
2019-12-19 22:06:19 +00:00
committed by Commit Bot
parent 1c5743cf0a
commit 080b47edee
4 changed files with 109 additions and 125 deletions

@ -68,14 +68,15 @@ used when committed.
### Integrated Development Environment (IDE) Set Up Guides
* [Android Studio](android_studio.md) - Android Studio for Android builds
* [Atom](atom.md) - Atom multi-platform code editor
* [CLion](clion.md) - CLion IDE, supports GUI debugging.
* [Eclipse for Android](eclipse.md) - Eclipse for Android
* [Eclipse for Linux](linux_eclipse_dev.md) - Eclipse for other platforms
(This guide was written for Linux, but is probably usable on Windows/MacOS
as well)
* [Qt Creator](qtcreator.md) - Using Qt Creator as an IDE or GUI debugger
* [Setting up Visual Studio Code](vscode.md) - Visual Studio Code
* [EMACS Notes](emacs.md) - EMACS commands/styles/tool integrations
* [Atom](atom.md) - Atom multi-platform code editor
* [Qt Creator](qtcreator.md) - Using Qt Creator as an IDE or GUI debugger
* [Visual Studio Code](vscode.md) - Visual Studio Code
### Git
* [Git Cookbook](git_cookbook.md) - A collection of git recipes for common

105
docs/clion.md Normal file

@ -0,0 +1,105 @@
# CLion Dev
CLion is an IDE
Prerequisite:
[Checking out and building the chromium code base](README.md#Checking-Out-and-Building)
[TOC]
## Setting up CLion
1. Install CLion
- Googlers only: See
[go/intellij-getting-started](https://goto.google.com/intellij-getting-started)
for installation and license authentication instructions
1. Run CLion
1. Increase CLion's memory allocation
This step will help performance with large projects
1. Option 1
1. At the startup dialogue, in the bottom right corner, click
`Configure`
1. Setup `Edit Custom VM Options`:
```
-Xss2m
-Xms1g
-Xmx10g
...
```
1. (Optional) Setup `Edit Custom Properties`:
```
idea.max.intellisense.filesize=12500
```
1. Option 2; 2017 and prior versions may not include the options to setup
your `VM Options` and `Properties` in the `configure` menu. Instead:
1. `Create New Project`
1. `Help` > `Edit Custom VM Options`
1. (Optional) `Help` > `Edit Custom Properties`
## Chromium in CLion
1. Import project
- At the startup dialog, select `Import Project` and select your `chromium`
directory; this should be the parent directory to `src`. Selecting `src`
instead would result in some CLion IDE files appearing in your repository.
1. (Optional) Modify the `CMakeLists.txt` file
1. Open the `CMakeLists.txt` file
1. Replace the `include_directories` with the following. This will help
with navigating between files.
```
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
```
1. (Optional) Replace the `add_executable` files to include a single file.
Doing this might improve CLion performance. Leaving at least 1 file is
required in order for CLion to provide code completion, navigation, etc.
The file should now look like:
```
cmake_minimum_required(VERSION 3.10)
project(chromium)
set(CMAKE_CXX_STANDARD 14)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
add_executable(chromium src/components/omnibox/browser/document_provider.cc)
```
## Building, Running, and Debugging within CLion
1. Edit the `custom build targets` settings
1. `ctrl+shift+a` > `custom build targets`
1. Click the `+` button to create a new target.
1. Click the `...` button next to the `Build` field
1. Click the `+` button in the new panel
1. Configure the fields:
```
Program: <absolute path to depot_tools/ninja>
Arguments: -C src/out/Default -j 1000 chrome
```
1. (Optional) Repeat for Debug or other build configurations.
1. Create a run configuration
1. `Run` > `Edit Configurations`
1. Click `+` in the top left and select `Custom Build Application`
1. Set the `Target` field to one of the targets configured in step 1
1. Click 'Select other` option for the `Executable` field and select the
chrome build e.g. `out/Default/chrome`
1. (Optional) Repeat for Debug or other build configurations. The built
targets and executables should match; i.e. don't build `out/Debug `but
execute `out/Default/chrome`.
1. `Run` > `Run` (`shift+f10`) or `Run` > `Debug` (`shift+f9`) (screenshot)
![debugging screenshot](images/clion_gui_debugging.png)
## Optional Steps
### Create terminal cli or desktop entry
To make it easier to startup CLion or open individual files:
1. Open the actions menu (`ctrl+shift+a`)
1. Type `create desktop entry` and press `enter`
1. Open the actions menu and enter `create command-line launcher`
### Mark directories as `Library Files`
To speed up CLion, optionally mark directories such as `src/third_party` as
`Library Files`
1. Open the `Project` navigation (`alt+1`)
1. Select and right click the directories > `Mark directory as` >
`Library Files`
1. See `https://blog.jetbrains.com/clion/2015/12/mark-dir-as/` for more details

@ -1,122 +0,0 @@
# CLion Dev
CLion is an IDE
Prerequisite:
[Checking out and building the chromium code base](README.md#Checking-Out-and-Building)
[TOC]
## Setting up CLion
1. Install CLion.
- Googlers only: See
[go/intellij-getting-started](https://goto.google.com/intellij-getting-started)
for installation and license authentication instructions.
1. Run CLion
1. Increase CLion's memory allocation
- This step will help performance with large projects
1. Option 1
1. At the startup dialogue, in the bottom right corner, click
`Configure`.
1. Setup `Edit Custom VM Options`:
```
-Xss2m
-Xms1g
-Xmx5g
```
1. Setup `Edit Custom Properties`:
```
idea.max.intellisense.filesize=12500
```
1. Option 2; 2017 and prior versions may not include the options to setup your `VM Options` and `Properties` in the `configure` menu. Instead:
1. `Create New Project`
1. `Help` > `Edit Custom VM Options`
1. `Help` > `Edit Custom Properties`
## Chromium in CLion
1. Import project
- At the startup dialog, select `Import Project` and select your `chromium`
directory; this should be the parent directory to `src`. Selecting `src`
instead would result in a bunch of CLion IDE files appearing in your
repository.
1. Modify the `CMakeLists.txt` file
1. Open the `CMakeLists.txt` file
1. Add the following to the top
```
set(CMAKE_BUILD_TYPE Debug)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
```
1. Remove any other `include_directories` the file contains. The beginning
of the file should now look like:
```
cmake_minimum_required(VERSION 3.10)
project(chromium)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_BUILD_TYPE Debug)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
add_executable(chromium
...)
```
## Building, Running, and Debugging within CLion
1. `Run` > `Edit Configurations`
1. Click `+` in the top left and select `Application`
1. Setup:
```
Target: All targets
Executable: src/out/Defaults/chrome
Program arguments (optional): --disable-seccomp-sandbox --single-process
Working directory: .../chromium/src/out/Default
```
1. Click `+` next to the `Before launch` section and select `Run External tool`
1. In the dialog that appears, click `+` and setup:
```
Program: .../depot_tools/ninja
Arguments: -C out/Default -j 1000 chrome
Working directory: .../chromium/src
```
1. Click `OK` to close all three dialogs
1. `Run` > `Run` or `Run` > `Debug`
## Note on installing CLion on Linux
For some reason, when installing 2018.1 through a package manager, it did not create a desktop entry when I tried it. If you experience this as well:
1. Option 1
1. `cd /usr/share/applications/`
1. `touch clion-2018-1.desktop`
1. open `clion-2018-1.desktop` and insert:
```
[Desktop Entry]
Name=CLion 2018.1
Exec=/opt/clion-2018.1/bin/clion.sh %u
Icon=/opt/clion-2018.1/bin/clion.svg
Terminal=false
Type=Application
Categories=Development;IDE;Java;
StartupWMClass=jetbrains-clion
X-Desktop-File-Install-Version=0.23
```
1. Option 2
1. Run CLion through the terminal `/opt/clion-2018.1/bin/clion.sh`
1. At the startup dialogue, in the bottom right corner, click `configure`
1. Click `Create Desktop Entry`
## Optional Performance Steps
### Mark directories as `Library Files`
To speed up CLion, you may optionally mark directories such as `src/third_party` as `Library Files`
1. Open the `Project` navigation (default `Alt 1`)
1. Right click the directory > `Mark directory as` > `Library Files`
1. See `https://blog.jetbrains.com/clion/2015/12/mark-dir-as/` for more details

Binary file not shown.

After

(image error) Size: 231 KiB