Strengthen is_official_build, update docs.

This makes is_official_build turn off all development targets and
features in Skia, including building third-party dependencies from
source.

This will intentionally break some external users, who will find
themselves no longer able to find third-party headers or link against
third-party libraries.  These users have been building with our testing
third-party dependencies unknowingly.  They'll need to either explicitly
turn back on building each dependency from source
(skia_use_system_foo=false) or disable that dependency entirely
(skia_use_foo=false).

is_skia_standalone is now basically !is_official_build, so I've
propagated that through, removing is_skia_standalone.  In a few places
we were using it as a stand-in for defined(ndk), so I've just written
defined(ndk) there.  Duh.

gn_to_bp:

    is_offical_build's new strength also makes gn_to_bp.py simpler to
    write.  In spirit, Android builds are official Skia builds that also
    build DM and nanobench.

    It seems that SkJumper (src/jumper/*) is (unintentionally) enabled
    on Android.  Switching to an is_official_build would have disabled
    that.  But as that accidental launch seems to have gone fine, I've
    kept it explicitly enabled.

    In the end, no changes to Android.bp or its SkUserConfig.h.

The -Mini builder no longer needs to explicitly disable tools.
CQ_INCLUDE_TRYBOTS=skia.primary:Build-Ubuntu-Clang-x86_64-Release-Mini

Change-Id: Id06e53268a5caf55c6046ada354a0863c3031c73
Reviewed-on: https://skia-review.googlesource.com/9190
Reviewed-by: Leon Scroggins <scroggo@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index b23277c..419b082 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -6,10 +6,6 @@
 import("gn/android_framework_defines.gni")
 import("gn/shared_sources.gni")
 
-if (!defined(is_skia_standalone)) {
-  is_skia_standalone = false
-}
-
 declare_args() {
   skia_use_angle = false
   skia_use_expat = true
@@ -29,11 +25,11 @@
   skia_enable_android_framework_defines = false
   skia_enable_discrete_gpu = true
   skia_enable_effects = true
-  skia_enable_jumper = is_skia_standalone
+  skia_enable_jumper = !is_official_build
   skia_enable_gpu = true
   skia_enable_pdf = true
-  skia_enable_tools = is_skia_standalone
-  skia_enable_vulkan_debug_layers = is_skia_standalone && is_debug
+  skia_enable_tools = !is_official_build
+  skia_enable_vulkan_debug_layers = !is_official_build && is_debug
   skia_vulkan_sdk = getenv("VULKAN_SDK")
 }
 declare_args() {
@@ -667,7 +663,7 @@
 
   if (is_android) {
     deps += [ "//third_party/expat" ]
-    if (is_skia_standalone && ndk != "") {
+    if (defined(ndk) && ndk != "") {
       deps += [ "//third_party/cpu-features" ]
     }
     sources += [ "src/ports/SkDebug_android.cpp" ]
@@ -1449,7 +1445,7 @@
     }
   }
 
-  if (is_android && is_skia_standalone && ndk != "") {
+  if (is_android && defined(ndk) && ndk != "") {
     copy("gdbserver") {
       sources = [
         "$ndk/$ndk_gdbserver",
diff --git a/gn/BUILDCONFIG.gn b/gn/BUILDCONFIG.gn
index a89931b..9582c46 100644
--- a/gn/BUILDCONFIG.gn
+++ b/gn/BUILDCONFIG.gn
@@ -3,8 +3,6 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-is_skia_standalone = true
-
 # It's best to keep the names and defaults of is_foo flags consistent with Chrome.
 
 declare_args() {
diff --git a/gn/gn_to_bp.py b/gn/gn_to_bp.py
index 94db28b..58a8dd5 100644
--- a/gn/gn_to_bp.py
+++ b/gn/gn_to_bp.py
@@ -188,14 +188,12 @@
 
 # We'll run GN to get the main source lists and include directories for Skia.
 gn_args = {
-  'skia_enable_vulkan_debug_layers': 'false',
-  'skia_use_system_expat':           'true',
-  'skia_use_system_jsoncpp':         'true',
-  'skia_use_system_libpng':          'true',
-  'skia_use_system_zlib':            'true',
-  'skia_use_vulkan':                 'true',
-  'target_cpu':                      '"none"',
-  'target_os':                       '"android"',
+  'is_official_build':  'true',
+  'skia_enable_jumper': 'true',
+  'skia_enable_tools':  'true',
+  'skia_use_vulkan':    'true',
+  'target_cpu':         '"none"',
+  'target_os':          '"android"',
 }
 gn_args = ' '.join(sorted('%s=%s' % (k,v) for (k,v) in gn_args.iteritems()))
 
@@ -243,6 +241,7 @@
 # Most defines go into SkUserConfig.h, where they're seen by Skia and its users.
 # Start with the defines :skia uses, minus a couple.  We'll add more in a bit.
 defines = [str(d) for d in js['targets']['//:skia']['defines']]
+defines.remove('NDEBUG')                 # Let the Android build control this.
 defines.remove('SKIA_IMPLEMENTATION=1')  # Only libskia should have this define.
 
 # For architecture specific files, it's easier to just read the same source
diff --git a/infra/bots/recipe_modules/compile/example.expected/Build-Ubuntu-Clang-x86_64-Release-Mini.json b/infra/bots/recipe_modules/compile/example.expected/Build-Ubuntu-Clang-x86_64-Release-Mini.json
index f975e13..9e3de4b 100644
--- a/infra/bots/recipe_modules/compile/example.expected/Build-Ubuntu-Clang-x86_64-Release-Mini.json
+++ b/infra/bots/recipe_modules/compile/example.expected/Build-Ubuntu-Clang-x86_64-Release-Mini.json
@@ -99,7 +99,7 @@
       "[CUSTOM_/_B_WORK]/skia/bin/gn",
       "gen",
       "[CUSTOM_/_B_WORK]/skia/out/Build-Ubuntu-Clang-x86_64-Release-Mini/Release",
-      "--args=cc=\"[START_DIR]/clang_linux/bin/clang\" cxx=\"[START_DIR]/clang_linux/bin/clang++\" extra_ldflags=[\"-fuse-ld=lld\"] is_component_build=true is_debug=false is_official_build=true skia_enable_effects=false skia_enable_gpu=false skia_enable_pdf=false skia_enable_tools=false skia_use_expat=false skia_use_libjpeg_turbo=false skia_use_libpng=false skia_use_libwebp=false skia_use_zlib=false target_cpu=\"x86_64\""
+      "--args=cc=\"[START_DIR]/clang_linux/bin/clang\" cxx=\"[START_DIR]/clang_linux/bin/clang++\" extra_ldflags=[\"-fuse-ld=lld\"] is_component_build=true is_debug=false is_official_build=true skia_enable_effects=false skia_enable_gpu=false skia_enable_pdf=false skia_use_expat=false skia_use_libjpeg_turbo=false skia_use_libpng=false skia_use_libwebp=false skia_use_zlib=false target_cpu=\"x86_64\""
     ],
     "cwd": "[CUSTOM_/_B_WORK]/skia",
     "env": {
diff --git a/infra/bots/recipe_modules/flavor/gn_flavor.py b/infra/bots/recipe_modules/flavor/gn_flavor.py
index af20893..bfff36e 100644
--- a/infra/bots/recipe_modules/flavor/gn_flavor.py
+++ b/infra/bots/recipe_modules/flavor/gn_flavor.py
@@ -80,11 +80,10 @@
     if extra_config == 'Mini':
       args.update({
         'is_component_build':     'true',   # Proves we can link a coherent .so.
-        'is_official_build':      'true',   # No debug symbols.
+        'is_official_build':      'true',   # No debug symbols, no tools.
         'skia_enable_effects':    'false',
         'skia_enable_gpu':        'false',
         'skia_enable_pdf':        'false',
-        'skia_enable_tools':      'false',  # Some tools need GPU or effects.
         'skia_use_expat':         'false',
         'skia_use_libjpeg_turbo': 'false',
         'skia_use_libpng':        'false',
diff --git a/site/user/build.md b/site/user/build.md
index 17f7857..36ef63c 100644
--- a/site/user/build.md
+++ b/site/user/build.md
@@ -7,6 +7,32 @@
 Skia uses [GN](https://chromium.googlesource.com/chromium/src/tools/gn/) to
 configure its builds.
 
+`is_official_build` and Third-party Dependencies
+------------------------------------------------
+
+Most users of Skia should set `is_official_build=true`, and most developers
+should leave it to its `false` default.
+
+This mode configures Skia in a way that's suitable to ship: an optimized build
+with no debug symbols, dynamically linked against its third-party dependencies
+using the ordinary library search path.
+
+In contrast, the developer-oriented default is an unoptimized build with full
+debug symbols and all third-party dependencies built from source and embedded
+into libskia.  This is how do all our manual and automated testing.
+
+Skia offers several features that make use of third-party libraries, like
+libpng, libwebp, or libjpeg-turbo to decode images, or ICU and sftnly to subset
+fonts.  All these third-party dependencies are optional and can be controlled
+by a GN argument that looks something like `skia_use_foo` for appropriate
+`foo`.
+
+If `skia_use_foo` is enabled, enabling `skia_use_system_foo` will build and
+link Skia against the headers and libaries found on the system paths.
+`is_official_build=true` enables all `skia_use_system_foo` by default.  You can
+use `extra_cflags` and `extra_ldflags` to add include or library paths if
+needed.
+
 Quickstart
 ----------
 
@@ -142,23 +168,3 @@
 project descriptions.  This is not meant for any purpose beyond development.
 
     bin/gn gen out/config --ide=json --json-ide-script=../../gn/gn_to_cmake.py
-
-Third-party Dependencies
-------------------------
-
-Skia offers several features that make use of third-party libraries, like
-libpng, libwebp, or libjpeg-turbo to decode images, or ICU and sftnly to subset
-fonts.  All these third-party dependencies are optional, and can be controlled
-by a GN argument that looks something like `skia_use_foo` for appropriate
-`foo`.
-
-Most of these third-party dependencies can also be satisfied by pre-built
-system libraries.  If `skia_use_foo` is enabled, turn on `skia_use_system_foo`
-to build and link Skia against the headers and libaries found on the system
-paths.  You can use `extra_cflags` and `extra_ldflags` to add include or
-library paths if needed.
-
-By default Skia will build and embed its own copies of these third-party
-libraries.  This configuration is for development only.  We do not recommend
-shipping Skia this way.  However, this is the only configuration of Skia that
-receives significant testing.
diff --git a/third_party/expat/BUILD.gn b/third_party/expat/BUILD.gn
index 3277389..d2a5d36 100644
--- a/third_party/expat/BUILD.gn
+++ b/third_party/expat/BUILD.gn
@@ -4,7 +4,7 @@
 # found in the LICENSE file.
 
 declare_args() {
-  skia_use_system_expat = false
+  skia_use_system_expat = is_official_build
 }
 
 import("../third_party.gni")
diff --git a/third_party/freetype2/BUILD.gn b/third_party/freetype2/BUILD.gn
index d543dac..7ccaa1d 100644
--- a/third_party/freetype2/BUILD.gn
+++ b/third_party/freetype2/BUILD.gn
@@ -4,8 +4,9 @@
 # found in the LICENSE file.
 
 declare_args() {
-  # TODO: false?  i.e. build from source all the time for testing?
-  skia_use_system_freetype2 = !(is_android || sanitize == "MSAN")
+  # TODO: build from source all the time for testing?
+  skia_use_system_freetype2 =
+      is_official_build || !(is_android || sanitize == "MSAN")
 }
 
 import("../third_party.gni")
diff --git a/third_party/icu/BUILD.gn b/third_party/icu/BUILD.gn
index e3815ee..1d54c46 100644
--- a/third_party/icu/BUILD.gn
+++ b/third_party/icu/BUILD.gn
@@ -4,7 +4,7 @@
 # found in the LICENSE file.
 
 declare_args() {
-  skia_use_system_icu = false
+  skia_use_system_icu = is_official_build
 }
 
 import("../third_party.gni")
diff --git a/third_party/jsoncpp/BUILD.gn b/third_party/jsoncpp/BUILD.gn
index 34150c0..ff8351f 100644
--- a/third_party/jsoncpp/BUILD.gn
+++ b/third_party/jsoncpp/BUILD.gn
@@ -4,7 +4,7 @@
 # found in the LICENSE file.
 
 declare_args() {
-  skia_use_system_jsoncpp = false
+  skia_use_system_jsoncpp = is_official_build
 }
 
 import("../third_party.gni")
diff --git a/third_party/libjpeg-turbo/BUILD.gn b/third_party/libjpeg-turbo/BUILD.gn
index 6254235..37b589d 100644
--- a/third_party/libjpeg-turbo/BUILD.gn
+++ b/third_party/libjpeg-turbo/BUILD.gn
@@ -4,7 +4,7 @@
 # found in the LICENSE file.
 
 declare_args() {
-  skia_use_system_libjpeg_turbo = false
+  skia_use_system_libjpeg_turbo = is_official_build
 }
 
 import("../third_party.gni")
diff --git a/third_party/libpng/BUILD.gn b/third_party/libpng/BUILD.gn
index 3e97f55..6a4c657 100644
--- a/third_party/libpng/BUILD.gn
+++ b/third_party/libpng/BUILD.gn
@@ -4,7 +4,7 @@
 # found in the LICENSE file.
 
 declare_args() {
-  skia_use_system_libpng = false
+  skia_use_system_libpng = is_official_build
 }
 
 import("../third_party.gni")
diff --git a/third_party/libwebp/BUILD.gn b/third_party/libwebp/BUILD.gn
index 1157e4b..3e9bd06 100644
--- a/third_party/libwebp/BUILD.gn
+++ b/third_party/libwebp/BUILD.gn
@@ -4,7 +4,7 @@
 # found in the LICENSE file.
 
 declare_args() {
-  skia_use_system_libwebp = false
+  skia_use_system_libwebp = is_official_build
 }
 
 import("../third_party.gni")
diff --git a/third_party/lua/BUILD.gn b/third_party/lua/BUILD.gn
index 9967dcd..14ce417 100644
--- a/third_party/lua/BUILD.gn
+++ b/third_party/lua/BUILD.gn
@@ -4,7 +4,7 @@
 # found in the LICENSE file.
 
 declare_args() {
-  skia_use_system_lua = false
+  skia_use_system_lua = is_official_build
 }
 
 import("../third_party.gni")
diff --git a/third_party/zlib/BUILD.gn b/third_party/zlib/BUILD.gn
index e7776f5..00eb327 100644
--- a/third_party/zlib/BUILD.gn
+++ b/third_party/zlib/BUILD.gn
@@ -4,7 +4,7 @@
 # found in the LICENSE file.
 
 declare_args() {
-  skia_use_system_zlib = false
+  skia_use_system_zlib = is_official_build
 }
 
 import("../third_party.gni")