CLion is an IDE
Prerequisite: Checking out and building the chromium code base
[TOC]
Install CLion
Run CLion
Increase CLion’s memory allocation
This step will help performance with large projects
Configure
Setup Edit Custom VM Options
:
-Xss2m
-Xms1g
-Xmx15g
...
(Optional) Setup Edit Custom Properties
:
idea.max.intellisense.filesize=12500
VM Options
and Properties
in the configure
menu. Instead:
Create New Project
Help
> Edit Custom VM Options
Help
> Edit Custom Properties
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.(Optional) Modify the CMakeLists.txt
file
CMakeLists.txt
file.Replace the include_directories
with 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)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/googletest/src/googlemock/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/abseil-cpp)
(Optional) Replace the add_executable
files 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/protobuf/src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/googletest/src/googletest/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/googletest/src/googlemock/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/abseil-cpp)
add_executable(chromium src/components/omnibox/browser/document_provider.cc)
Edit the custom build targets
settings
ctrl+shift+a
> custom build targets
+
button to create a new target....
button next to the Build
field+
button in the new panelConfigure 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
+
in the top left and select Custom Build Application
Target
field to one of the targets configured in step 1option for the
Executablefield and select the
chrome build e.g.
out/Default/chrome`out/Debug
but
execute out/Default/chrome
.Run
> Run
(shift+f10
) or Run
> Debug
(shift+f9
) (screenshot)
To make it easier to startup CLion or open individual files:
ctrl+shift+a
)create desktop entry
and press enter
create command-line launcher
Library Files
To speed up CLion, optionally mark directories such as src/third_party
as
Library Files
Project
navigation (alt+1
)Mark directory as
>
Library Files
https://blog.jetbrains.com/clion/2015/12/mark-dir-as/
for more details