blob: 5e47b32dab4fdfc0e6b7b644e6fee851b00c5ce7 [file] [log] [blame] [view]
manukh080b47e2019-12-19 22:06:191# CLion Dev
2
3CLion is an IDE
4
5Prerequisite:
6[Checking out and building the chromium code base](README.md#Checking-Out-and-Building)
7
8[TOC]
9
10## Setting up CLion
111. Install CLion
12 - Googlers only: See
13 [go/intellij-getting-started](https://goto.google.com/intellij-getting-started)
14 for installation and license authentication instructions
15
161. Run CLion
171. Increase CLion's memory allocation
18
19 This step will help performance with large projects
20 1. Option 1
21 1. At the startup dialogue, in the bottom right corner, click
22 `Configure`
23 1. Setup `Edit Custom VM Options`:
24 ```
25 -Xss2m
26 -Xms1g
manuk hovanesianb2953e42021-03-20 00:14:0427 -Xmx15g
manukh080b47e2019-12-19 22:06:1928 ...
29 ```
30 1. (Optional) Setup `Edit Custom Properties`:
31 ```
32 idea.max.intellisense.filesize=12500
33 ```
34 1. Option 2; 2017 and prior versions may not include the options to setup
35 your `VM Options` and `Properties` in the `configure` menu. Instead:
36 1. `Create New Project`
37 1. `Help` > `Edit Custom VM Options`
38 1. (Optional) `Help` > `Edit Custom Properties`
39
40## Chromium in CLion
411. Import project
42 - At the startup dialog, select `Import Project` and select your `chromium`
43 directory; this should be the parent directory to `src`. Selecting `src`
44 instead would result in some CLion IDE files appearing in your repository.
451. (Optional) Modify the `CMakeLists.txt` file
manuk hovanesianb2953e42021-03-20 00:14:0446 1. Open the `CMakeLists.txt` file.
manukh080b47e2019-12-19 22:06:1947 1. Replace the `include_directories` with the following. This will help
48 with navigating between files.
49 ```
50 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
manuk hovanesianb2953e42021-03-20 00:14:0451 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/out/Default/gen)
manuk hovanesianb3279552021-04-29 16:52:2552 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf/src)
manuk hovanesianb2953e42021-03-20 00:14:0453 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/googletest/src/googletest/include)
manukh38a8b742022-08-03 22:25:5254 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/googletest/src/googlemock/include)
55 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/abseil-cpp)
manukh080b47e2019-12-19 22:06:1956 ```
manuk hovanesianb2953e42021-03-20 00:14:0457 1. (Optional) Replace the `add_executable` files to include a single file;
58 the file used is irrelevant. Doing this might improve CLion performance.
59 Leaving at least 1 file is required in order for CLion to provide code
60 completion, navigation, etc. The file should now look like:
manukh080b47e2019-12-19 22:06:1961 ```
62 cmake_minimum_required(VERSION 3.10)
63 project(chromium)
64
65 set(CMAKE_CXX_STANDARD 14)
66
67 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
manuk hovanesianb2953e42021-03-20 00:14:0468 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/out/Default/gen)
manukh38a8b742022-08-03 22:25:5269 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf/src)
manuk hovanesianb2953e42021-03-20 00:14:0470 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/googletest/src/googletest/include)
manukh38a8b742022-08-03 22:25:5271 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/googletest/src/googlemock/include)
72 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/abseil-cpp)
73
manukh080b47e2019-12-19 22:06:1974 add_executable(chromium src/components/omnibox/browser/document_provider.cc)
75 ```
76
77## Building, Running, and Debugging within CLion
781. Edit the `custom build targets` settings
79 1. `ctrl+shift+a` > `custom build targets`
80 1. Click the `+` button to create a new target.
81 1. Click the `...` button next to the `Build` field
82 1. Click the `+` button in the new panel
83 1. Configure the fields:
84 ```
85 Program: <absolute path to depot_tools/ninja>
86 Arguments: -C src/out/Default -j 1000 chrome
87 ```
88 1. (Optional) Repeat for Debug or other build configurations.
891. Create a run configuration
90 1. `Run` > `Edit Configurations`
91 1. Click `+` in the top left and select `Custom Build Application`
92 1. Set the `Target` field to one of the targets configured in step 1
93 1. Click 'Select other` option for the `Executable` field and select the
94 chrome build e.g. `out/Default/chrome`
95 1. (Optional) Repeat for Debug or other build configurations. The built
96 targets and executables should match; i.e. don't build `out/Debug `but
97 execute `out/Default/chrome`.
981. `Run` > `Run` (`shift+f10`) or `Run` > `Debug` (`shift+f9`) (screenshot)
99 ![debugging screenshot](images/clion_gui_debugging.png)
100
101## Optional Steps
102
103### Create terminal cli or desktop entry
104To make it easier to startup CLion or open individual files:
1051. Open the actions menu (`ctrl+shift+a`)
1061. Type `create desktop entry` and press `enter`
1071. Open the actions menu and enter `create command-line launcher`
108
109### Mark directories as `Library Files`
110To speed up CLion, optionally mark directories such as `src/third_party` as
111`Library Files`
1121. Open the `Project` navigation (`alt+1`)
1131. Select and right click the directories > `Mark directory as` >
114 `Library Files`
1151. See `https://blog.jetbrains.com/clion/2015/12/mark-dir-as/` for more details