blob: 95ef812f8a0fbba0f0995d9a98145d57034a0759 [file] [log] [blame] [view]
nodir06cbaa02015-08-25 17:15:241# Updating Clang format binaries
andybons3322f762015-08-24 21:37:092
nodir06cbaa02015-08-25 17:15:243Instructions on how to update the [clang-format binaries](clang_format.md) that
4come with a checkout of Chromium.
andybons3322f762015-08-24 21:37:095
nodir06cbaa02015-08-25 17:15:246## Prerequisites
andybons3322f762015-08-24 21:37:097
nodir06cbaa02015-08-25 17:15:248You'll need a Windows machine, a Linux machine, and a Mac; all capable of
9building clang-format. You'll also need permissions to upload to the appropriate
10google storage bucket. Chromium infrastructure team members have this, and
11others can be granted the permission based on need. Talk to ncarter or hinoka
12about getting access.
andybons3322f762015-08-24 21:37:0913
nodir06cbaa02015-08-25 17:15:2414## Pick a head svn revision
andybons3322f762015-08-24 21:37:0915
nodir06cbaa02015-08-25 17:15:2416Consult http://llvm.org/svn/llvm-project/ for the current head revision. This
17will be the CLANG_REV you'll use later to check out each platform to a
18consistent state.
andybons3322f762015-08-24 21:37:0919
nodir06cbaa02015-08-25 17:15:2420## Build a release-mode clang-format on each platform
21
qyearsleyc0dc6f42016-12-02 22:13:3922Follow the official instructions here:
nodir06cbaa02015-08-25 17:15:2423http://clang.llvm.org/get_started.html.
andybons3322f762015-08-24 21:37:0924
25Windows step-by-step:
nodir06cbaa02015-08-25 17:15:2426
27```shell
28# [double check you have the tools you need]
andybons3322f762015-08-24 21:37:0929where cmake.exe # You need to install this.
30where svn.exe # Maybe fix with: set PATH=%PATH%;D:\src\depot_tools\svn_bin
dbeamb71beb82017-01-26 05:52:4031"c:\Program Files (x86)\Microsoft Visual Studio 14.0\vc\vcvarsall.bat" amd64_x86
andybons3322f762015-08-24 21:37:0932
andybons3322f762015-08-24 21:37:0933set CLANG_REV=198831 # You must change this value (see above)
34
35[from a clean directory, check out and build]
36rmdir /S /Q llvm
37rmdir /S /Q llvm-build
38mkdir llvm
39mkdir llvm-build
40svn co http://llvm.org/svn/llvm-project/llvm/trunk@%CLANG_REV% llvm
41cd llvm\tools
42svn co http://llvm.org/svn/llvm-project/cfe/trunk@%CLANG_REV% clang
43cd ..\..\llvm-build
44set CC=cl
45set CXX=cl
dbeamb71beb82017-01-26 05:52:4046cmake -G Ninja ..\llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_CRT_RELEASE=MT ^
47 -DLLVM_ENABLE_ASSERTIONS=NO -DLLVM_ENABLE_THREADS=NO ^
nodir06cbaa02015-08-25 17:15:2448 -DPYTHON_EXECUTABLE=d:\src\depot_tools\python276_bin\python.exe
andybons3322f762015-08-24 21:37:0949ninja clang-format
50bin\clang-format.exe --version
51```
52
53Mac & Linux step-by-step:
nodir06cbaa02015-08-25 17:15:2454
55```shell
andybons3322f762015-08-24 21:37:0956# Check out.
57export CLANG_REV=198831 # You must change this value (see above)
58rm -rf llvm
59rm -rf llvm-build
60mkdir llvm
61mkdir llvm-build
62svn co http://llvm.org/svn/llvm-project/llvm/trunk@$CLANG_REV llvm
63cd llvm/tools
64svn co http://llvm.org/svn/llvm-project/cfe/trunk@$CLANG_REV clang
65cd ../../llvm-build
66
67# Option 1: with cmake
dbeamb71beb82017-01-26 05:52:4068MACOSX_DEPLOYMENT_TARGET=10.9 cmake -G Ninja -DCMAKE_BUILD_TYPE=Release \
nodir06cbaa02015-08-25 17:15:2469 -DLLVM_ENABLE_ASSERTIONS=NO -DLLVM_ENABLE_THREADS=NO ../llvm/
70time caffeinate ninja clang-format
71strip bin/clang-format
andybons3322f762015-08-24 21:37:0972
nodir06cbaa02015-08-25 17:15:2473# (On Linux, to build with clang, which produces smaller binaries, add this to
74# your cmake invocation.
75# On Mac, the system compiler is already clang so it's not needed there.)
76-DCMAKE_C_COMPILER=$PWD/../chrome/src/third_party/llvm-build/Release+Asserts/bin/clang -DCMAKE_CXX_COMPILER=$PWD/../chrome/src/third_party/llvm-build/Release+Asserts/bin/clang++
andybons3322f762015-08-24 21:37:0977```
nodir06cbaa02015-08-25 17:15:2478
andybons3322f762015-08-24 21:37:0979Platform specific notes:
andybons3322f762015-08-24 21:37:0980
nodir06cbaa02015-08-25 17:15:2481* Windows: Visual Studio 2013 only.
82* Linux: so far (as of January 2014) we've just included a 64-bit binary. It's
83 important to disable threading, else clang-format will depend on
84 libatomic.so.1 which doesn't exist on Precise.
85* Mac: Remember to set `MACOSX_DEPLOYMENT_TARGET` when building! If you get
86 configure warnings, you may need to install XCode 5 and avoid a goma
87 environment.
andybons3322f762015-08-24 21:37:0988
nodir06cbaa02015-08-25 17:15:2489## Upload each binary to google storage
andybons3322f762015-08-24 21:37:0990
nodir06cbaa02015-08-25 17:15:2491Copy the binaries into your chromium checkout (under
92`src/buildtools/(win|linux64|mac)/clang-format(.exe?)`). For each binary, you'll
93need to run upload_to_google_storage.py according to the instructions in
thakisb4016a52017-02-28 00:06:0794[README.txt](https://chromium.googlesource.com/chromium/buildtools/+/master/clang_format/README.txt).
95This will upload the binary into a publicly accessible google storage bucket,
96and update `.sha1` file in your Chrome checkout. You'll check in the `.sha1`
97file (but NOT the clang-format binary) into source control. In order to be able
98to upload, you'll need write permission to the bucket -- see the prerequisites.
andybons3322f762015-08-24 21:37:0999
nodir06cbaa02015-08-25 17:15:24100## Copy the helper scripts and update README.chromium
101
102There are some auxiliary scripts that ought to be kept updated in lockstep with
103the clang-format binary. These get copied into
104third_party/clang_format/scripts in your Chromium checkout.
andybons3322f762015-08-24 21:37:09105
106The `README.chromium` file ought to be updated with version and date info.
107
nodir06cbaa02015-08-25 17:15:24108## Upload a CL according to the following template
andybons3322f762015-08-24 21:37:09109
nodir06cbaa02015-08-25 17:15:24110 Update clang-format binaries and scripts for all platforms.
andybons3322f762015-08-24 21:37:09111
nodir06cbaa02015-08-25 17:15:24112 I followed these instructions:
113 https://chromium.googlesource.com/chromium/src/+/master/docs/updating_clang_format_binaries.md
andybons3322f762015-08-24 21:37:09114
nodir06cbaa02015-08-25 17:15:24115 The binaries were built at clang revision ####### on ####DATETIME####.
andybons3322f762015-08-24 21:37:09116
nodir06cbaa02015-08-25 17:15:24117 BUG=
andybons3322f762015-08-24 21:37:09118
nodir06cbaa02015-08-25 17:15:24119The change should **always** include new `.sha1` files for each platform (we
120want to keep these in lockstep), should **never** include `clang-format`
121binaries directly. The change should **always** update `README.chromium`
andybons3322f762015-08-24 21:37:09122
nodir06cbaa02015-08-25 17:15:24123clang-format binaries should weigh in at 1.5MB or less. Watch out for size
124regressions.