CLion is an IDE
Prerequisite: Checking out and building the chromium code base
[TOC]
-
Install CLion
- Googlers only: See go/intellij-getting-started for installation and license authentication instructions
-
Run CLion
-
Increase CLion's memory allocation
This step will help performance with large projects
- Option 1
- At the startup dialogue, in the bottom right corner, click
Configure - Setup
Edit Custom VM Options:-Xss2m -Xms1g -Xmx15g ... - (Optional) Setup
Edit Custom Properties:idea.max.intellisense.filesize=12500
- At the startup dialogue, in the bottom right corner, click
- Option 2; 2017 and prior versions may not include the options to setup
your
VM OptionsandPropertiesin theconfiguremenu. Instead:Create New ProjectHelp>Edit Custom VM Options- (Optional)
Help>Edit Custom Properties
- Option 1
- Import project
- At the startup dialog, select
Import Projectand select yourchromiumdirectory; this should be the parent directory tosrc. Selectingsrcinstead would result in some CLion IDE files appearing in your repository.
- At the startup dialog, select
- (Optional) Modify the
CMakeLists.txtfile- Open the
CMakeLists.txtfile. - Replace the
include_directorieswith the following. This will help with navigating between files.include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/out/Default/gen) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/protobuf/src) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/googletest/src/googletest/include) - (Optional) Replace the
add_executablefiles to include a single file; the file used is irrelevant. 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) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/out/Default/gen) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/googletest/src/googletest/include) add_executable(chromium src/components/omnibox/browser/document_provider.cc)
- Open the
- Edit the
custom build targetssettingsctrl+shift+a>custom build targets- Click the
+button to create a new target. - Click the
...button next to theBuildfield - Click the
+button in the new panel - Configure the fields:
Program: <absolute path to depot_tools/ninja> Arguments: -C src/out/Default -j 1000 chrome - (Optional) Repeat for Debug or other build configurations.
- Create a run configuration
Run>Edit Configurations- Click
+in the top left and selectCustom Build Application - Set the
Targetfield to one of the targets configured in step 1 - Click 'Select other
option for theExecutablefield and select the chrome build e.g.out/Default/chrome` - (Optional) Repeat for Debug or other build configurations. The built
targets and executables should match; i.e. don't build
out/Debugbut executeout/Default/chrome.
Run>Run(shift+f10) orRun>Debug(shift+f9) (screenshot)
To make it easier to startup CLion or open individual files:
- Open the actions menu (
ctrl+shift+a) - Type
create desktop entryand pressenter - Open the actions menu and enter
create command-line launcher
To speed up CLion, optionally mark directories such as src/third_party as
Library Files
- Open the
Projectnavigation (alt+1) - Select and right click the directories >
Mark directory as>Library Files - See
https://blog.jetbrains.com/clion/2015/12/mark-dir-as/for more details