CMake: distinguish between file and dir copies by presence of '.' in src path

ANGLE's build requires a file copy. Nema's build requires a dir copy. CMake
uses a different command for each. gn does not distinguish which. We make
a guess that happens to work for these two use cases based on the whether
the base file name of the src contains a '.'


Change-Id: I3503fd9d632abda3f8f952d0eef964019d932bea
Reviewed-on: https://skia-review.googlesource.com/c/188626
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/docker/README.md b/docker/README.md
index 51616b9..24aa23a 100644
--- a/docker/README.md
+++ b/docker/README.md
@@ -58,8 +58,8 @@
 installed libraries. To push:
 
     docker build -t cmake-release ./cmake-release/
-    docker tag cmake-release gcr.io/skia-public/cmake-release:3.13.1_v1
-    docker push gcr.io/skia-public/cmake-release:3.13.1_v1
+    docker tag cmake-release gcr.io/skia-public/cmake-release:3.13.1_v2
+    docker push gcr.io/skia-public/cmake-release:3.13.1_v2
 
 For testing the image locally, the following flow can be helpful:
 
diff --git a/docker/cmake-release/Dockerfile b/docker/cmake-release/Dockerfile
index d58e987..40f8fa5 100644
--- a/docker/cmake-release/Dockerfile
+++ b/docker/cmake-release/Dockerfile
@@ -8,6 +8,7 @@
   libfontconfig-dev \
   libgl1-mesa-dev \
   libglu1-mesa-dev \
+  libxi-dev \
   && groupadd -g 2000 skia \
   && useradd -u 2000 -g 2000 skia
 
diff --git a/gn/gn_to_cmake.py b/gn/gn_to_cmake.py
index 7768064..50b021c 100644
--- a/gn/gn_to_cmake.py
+++ b/gn/gn_to_cmake.py
@@ -372,8 +372,15 @@
   out.write('\n')
 
   for src, dst in zip(inputs, outputs):
-    out.write('  COMMAND ${CMAKE_COMMAND} -E copy_directory "')
-    out.write(CMakeStringEscape(project.GetAbsolutePath(src)))
+    abs_src_path = CMakeStringEscape(project.GetAbsolutePath(src))
+    # CMake distinguishes between copying files and copying directories but
+    # gn does not. We assume if the src has a period in its name then it is
+    # a file and otherwise a directory.
+    if "." in os.path.basename(abs_src_path):
+      out.write('  COMMAND ${CMAKE_COMMAND} -E copy "')
+    else:
+      out.write('  COMMAND ${CMAKE_COMMAND} -E copy_directory "')
+    out.write(abs_src_path)
     out.write('" "')
     out.write(CMakeStringEscape(dst))
     out.write('"\n')
diff --git a/infra/bots/recipe_modules/build/cmake.py b/infra/bots/recipe_modules/build/cmake.py
index 923e243..c217f92 100644
--- a/infra/bots/recipe_modules/build/cmake.py
+++ b/infra/bots/recipe_modules/build/cmake.py
@@ -2,7 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-DOCKER_IMAGE = 'gcr.io/skia-public/cmake-release:3.13.1_v1'
+DOCKER_IMAGE = 'gcr.io/skia-public/cmake-release:3.13.1_v2'
 INNER_BUILD_SCRIPT = '/SRC/skia/infra/cmake/build_skia.sh'
 
 
diff --git a/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-Clang-x86_64-Release-CMake.json b/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-Clang-x86_64-Release-CMake.json
index 87bc4ca..49f8d48 100644
--- a/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-Clang-x86_64-Release-CMake.json
+++ b/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-Clang-x86_64-Release-CMake.json
@@ -23,7 +23,7 @@
       "[START_DIR]/cache/work:/SRC",
       "--volume",
       "[START_DIR]/cache/docker/cmake:/OUT",
-      "gcr.io/skia-public/cmake-release:3.13.1_v1",
+      "gcr.io/skia-public/cmake-release:3.13.1_v2",
       "/SRC/skia/infra/cmake/build_skia.sh"
     ],
     "env": {
diff --git a/infra/cmake/build_skia.sh b/infra/cmake/build_skia.sh
index 103d5ed..d1839d7 100755
--- a/infra/cmake/build_skia.sh
+++ b/infra/cmake/build_skia.sh
@@ -26,8 +26,8 @@
 gn gen out/CMAKE --args='is_debug=false' --ide=json --json-ide-script=../../gn/gn_to_cmake.py
 
 cd $SKIA_DIR/out/CMAKE
-cmake -G Ninja .
-cmake --build .
+cmake -G"CodeBlocks - Unix Makefiles" .
+cmake --build . --parallel 8
 
 # Copy build products, ignoring the warning
 # for not copying directories.