GN: build Lua tools when skia_use_lua.

When we opt into Lua, this builds SampleLua into SampleApp, and the lua_app and lua_pictures tools.

I've tested this builds with and without skia_use_system_lua on my Mac laptop and Linux desktop.

I've made lua_pictures.cpp's flags static to avoid conflicts with flags in SkCommonFlags.cpp.

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4699

DOCS_PREVIEW= https://skia.org/?cl=4699

Change-Id: I8176fd51d8a38746e7d730cfcce66da42b9a015a
Reviewed-on: https://skia-review.googlesource.com/4699
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index 4ffbb01..e3954d7 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -20,6 +20,7 @@
   skia_use_libjpeg_turbo = true
   skia_use_libpng = true
   skia_use_libwebp = !is_fuchsia
+  skia_use_lua = false
   skia_use_mesa = false
   skia_use_piex = !is_win
   skia_use_zlib = true
@@ -960,6 +961,45 @@
     }
   }
 
+  if (skia_use_lua) {
+    test_lib("lua") {
+      public_include_dirs = []
+      sources = [
+        "src/utils/SkLua.cpp",
+        "src/utils/SkLuaCanvas.cpp",
+      ]
+      deps = [
+        "//third_party/lua",
+      ]
+    }
+
+    executable("lua_app") {
+      sources = [
+        "tools/lua/lua_app.cpp",
+      ]
+      deps = [
+        ":lua",
+        ":skia",
+        "//third_party/lua",
+      ]
+      testonly = true
+    }
+
+    executable("lua_pictures") {
+      sources = [
+        "tools/lua/lua_pictures.cpp",
+      ]
+      deps = [
+        ":flags",
+        ":lua",
+        ":skia",
+        ":tool_utils",
+        "//third_party/lua",
+      ]
+      testonly = true
+    }
+  }
+
   import("gn/samples.gni")
   test_lib("samples") {
     public_include_dirs = [ "samplecode" ]
@@ -977,6 +1017,14 @@
       ":views",
       ":xml",
     ]
+
+    if (skia_use_lua) {
+      sources += [ "samplecode/SampleLua.cpp" ]
+      deps += [
+        ":lua",
+        "//third_party/lua",
+      ]
+    }
   }
 
   executable("dm") {