From 91d0ab71ef330d8f1f0f40962791ab8f97f96a72 Mon Sep 17 00:00:00 2001 From: Karl Wiberg Date: Thu, 7 Sep 2017 17:05:31 +0200 Subject: [PATCH] Style guide: Link to Chromium's GN style guide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BUG=none NOTRY=true Change-Id: I26f2588ef4bfecb39ab0f491508fd21797a8be5c Reviewed-on: https://chromium-review.googlesource.com/652607 Reviewed-by: Henrik Kjellander Reviewed-by: Danil Chapovalov Reviewed-by: Niels Möller Commit-Queue: Karl Wiberg Cr-Commit-Position: refs/heads/master@{#19740} --- style-guide.md | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/style-guide.md b/style-guide.md index b39ab35fe1..bb2524a73a 100644 --- a/style-guide.md +++ b/style-guide.md @@ -7,7 +7,7 @@ style guides. In cases where they conflict, the Chromium style guide trumps the Google style guide, and the rules in this file trump them both. -[chr-style]: https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md +[chr-style]: https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/c++.md [goog-style]: https://google.github.io/styleguide/cppguide.html Some older parts of the code violate the style guide in various ways. @@ -48,10 +48,34 @@ pre-dates the use of the current C++ style guide for this code base. ## Build files +The WebRTC build files are written in [GN][gn], and we follow +the [Chromium GN style guide][chr-gn-style]. Additionally, there are +some WebRTC-specific rules below; in case of conflict, they trump the +Chromium style guide. + +[gn]: https://chromium.googlesource.com/chromium/src/tools/gn/ +[chr-gn-style]: https://chromium.googlesource.com/chromium/src/tools/gn/+/HEAD/docs/style_guide.md + +### WebRTC-specific GN templates + +Use the following [GN templates][gn-templ] to ensure that all +our [targets][gn-target] are built with the same configuration: + +instead of | use +-----------------|--------------------- +`executable` | `rtc_executable` +`shared_library` | `rtc_shared_library` +`source_set` | `rtc_source_set` +`static_library` | `rtc_static_library` +`test` | `rtc_test` + +[gn-templ]: https://chromium.googlesource.com/chromium/src/tools/gn/+/HEAD/docs/language.md#Templates +[gn-target]: https://chromium.googlesource.com/chromium/src/tools/gn/+/HEAD/docs/language.md#Targets + ### Conditional compilation with the C preprocessor Avoid using the C preprocessor to conditionally enable or disable -pieces of code. But if you can’t avoid it, introduce a gn variable, +pieces of code. But if you can’t avoid it, introduce a GN variable, and then set a preprocessor constant to either 0 or 1 in the build targets that need it: