IMLC.ME
/jvm/openjdk 开发环境搭建 (在macOS上使用CLion)/

openjdk 开发环境搭建 (在macOS上使用CLion)

本文记录了在 macOS 上,如果用 CLion 打开 openjdk 项目。

# 国内
git clone https://github.com/openjdk/jdk.git
# 国外
git clone https://github.com/openjdk/jdk.git

#  --disable-precompiled-headers 会避免后面生成的 compile_commands.json 文件错误配置 PCH 文件路径 
bash configure --with-debug-level=fastdebug --disable-precompiled-headers

# 基本不用担心系统缺少了什么工具,make 过程中会有很友好的工具缺失提示。甚至提供了安装命令。充分体现了 openjdk 厚重的历史沉淀。
make compile-commands

然后,在 CLion 中打开 build/macosx-x86_64-server-fastdebug/compile_commands.json 文件,并选择 Open as Project。

项目窗口打开后,在 Tools -> Compilation Database -> Change Project Root ,重新指定项目根目录为 ./jdk 目录(或者你clone的时候指定了其他文件名)。

剩下的就是等待 CLion 引索源代码了。

参考文献

IDE - openjdk

Tips & Tricks: Develop OpenJDK in CLion with Pleasure

Build OpenJDK on Windows (Christmas 2018 edition)