blob: 7a4e6ca91fa3c198a7afb2d2bf779a13d581bf3c [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
Sam Maier9b5c0a72018-12-06 17:35:4667# On Mac, do the following:
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
Sam Maier9b5c0a72018-12-06 17:35:4673#On Linux, do the following:
74cmake -G Ninja -DCMAKE_BUILD_TYPE=Release \
75 -DLLVM_ENABLE_ASSERTIONS=NO -DLLVM_ENABLE_THREADS=NO \
76 -DCMAKE_C_COMPILER=$PWD/../chrome/src/third_party/llvm-build/Release+Asserts/bin/clang \
77 -DCMAKE_CXX_COMPILER=$PWD/../chrome/src/third_party/llvm-build/Release+Asserts/bin/clang++ \
78 -DCMAKE_ASM_COMPILER=$PWD/../chrome/src/third_party/llvm-build/Release+Asserts/bin/clang \
79 -DLLVM_ENABLE_TERMINFO=OFF -DCMAKE_CXX_STANDARD_LIBRARIES="-static-libgcc -static-libstdc++" ../llvm/
80ninja clang-format
81strip bin/clang-format
82
83
andybons3322f762015-08-24 21:37:0984```
nodir06cbaa02015-08-25 17:15:2485
andybons3322f762015-08-24 21:37:0986Platform specific notes:
andybons3322f762015-08-24 21:37:0987
nodir06cbaa02015-08-25 17:15:2488* Windows: Visual Studio 2013 only.
89* Linux: so far (as of January 2014) we've just included a 64-bit binary. It's
90 important to disable threading, else clang-format will depend on
91 libatomic.so.1 which doesn't exist on Precise.
92* Mac: Remember to set `MACOSX_DEPLOYMENT_TARGET` when building! If you get
93 configure warnings, you may need to install XCode 5 and avoid a goma
94 environment.
andybons3322f762015-08-24 21:37:0995
nodir06cbaa02015-08-25 17:15:2496## Upload each binary to google storage
andybons3322f762015-08-24 21:37:0997
nodir06cbaa02015-08-25 17:15:2498Copy the binaries into your chromium checkout (under
99`src/buildtools/(win|linux64|mac)/clang-format(.exe?)`). For each binary, you'll
100need to run upload_to_google_storage.py according to the instructions in
thakisb4016a52017-02-28 00:06:07101[README.txt](https://chromium.googlesource.com/chromium/buildtools/+/master/clang_format/README.txt).
102This will upload the binary into a publicly accessible google storage bucket,
103and update `.sha1` file in your Chrome checkout. You'll check in the `.sha1`
104file (but NOT the clang-format binary) into source control. In order to be able
105to upload, you'll need write permission to the bucket -- see the prerequisites.
andybons3322f762015-08-24 21:37:09106
nodir06cbaa02015-08-25 17:15:24107## Copy the helper scripts and update README.chromium
108
109There are some auxiliary scripts that ought to be kept updated in lockstep with
110the clang-format binary. These get copied into
111third_party/clang_format/scripts in your Chromium checkout.
andybons3322f762015-08-24 21:37:09112
113The `README.chromium` file ought to be updated with version and date info.
114
nodir06cbaa02015-08-25 17:15:24115## Upload a CL according to the following template
andybons3322f762015-08-24 21:37:09116
nodir06cbaa02015-08-25 17:15:24117 Update clang-format binaries and scripts for all platforms.
andybons3322f762015-08-24 21:37:09118
nodir06cbaa02015-08-25 17:15:24119 I followed these instructions:
120 https://chromium.googlesource.com/chromium/src/+/master/docs/updating_clang_format_binaries.md
andybons3322f762015-08-24 21:37:09121
nodir06cbaa02015-08-25 17:15:24122 The binaries were built at clang revision ####### on ####DATETIME####.
andybons3322f762015-08-24 21:37:09123
nodir06cbaa02015-08-25 17:15:24124 BUG=
andybons3322f762015-08-24 21:37:09125
nodir06cbaa02015-08-25 17:15:24126The change should **always** include new `.sha1` files for each platform (we
127want to keep these in lockstep), should **never** include `clang-format`
128binaries directly. The change should **always** update `README.chromium`
andybons3322f762015-08-24 21:37:09129
nodir06cbaa02015-08-25 17:15:24130clang-format binaries should weigh in at 1.5MB or less. Watch out for size
131regressions.