Add recipe to build for Asus Flip Chromebook
authorKevin Lubick <kjlubick@google.com>
Wed, 5 Apr 2017 11:32:45 +0000 (07:32 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Wed, 5 Apr 2017 11:39:04 +0000 (11:39 +0000)
This build includes the GPU-specific code (EGL, GLES)

The armhf_sysroot should be generic enough to support
other ARM targets, like the Raspberry Pi.

I split out the EGL dependencies into their own CIPD package
(chromebook_c100p_lib) to facilitate the modularity of the approach.

When we add another ARM chromebook, maybe one that has different libraries,
we should be able to re-use armhf_sysroot and then a newly created CIPD asset for
that specific GPU (if needed).

Maybe this also can be used to build for the chromecasts (thus the TODO)

Bug: skia:
NOTRY=true

Change-Id: Icc131025932dc8d41da5be39f3c5cad0aa95d848
Reviewed-on: https://skia-review.googlesource.com/11064
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Eric Boren <borenet@google.com>
22 files changed:
infra/bots/assets/armhf_sysroot/README.md [new file with mode: 0644]
infra/bots/assets/armhf_sysroot/VERSION [new file with mode: 0644]
infra/bots/assets/armhf_sysroot/common.py [new file with mode: 0755]
infra/bots/assets/armhf_sysroot/create.py [new file with mode: 0755]
infra/bots/assets/armhf_sysroot/create_and_upload.py [new file with mode: 0755]
infra/bots/assets/armhf_sysroot/download.py [new file with mode: 0755]
infra/bots/assets/armhf_sysroot/upload.py [new file with mode: 0755]
infra/bots/assets/chromebook_c100p_lib/README.md [new file with mode: 0644]
infra/bots/assets/chromebook_c100p_lib/VERSION [new file with mode: 0644]
infra/bots/assets/chromebook_c100p_lib/common.py [new file with mode: 0755]
infra/bots/assets/chromebook_c100p_lib/create.py [new file with mode: 0755]
infra/bots/assets/chromebook_c100p_lib/create_and_upload.py [new file with mode: 0755]
infra/bots/assets/chromebook_c100p_lib/download.py [new file with mode: 0755]
infra/bots/assets/chromebook_c100p_lib/upload.py [new file with mode: 0755]
infra/bots/gen_tasks.go
infra/bots/jobs.json
infra/bots/recipe_modules/compile/example.expected/Build-Ubuntu-Clang-arm-Release-Chromebook_C100p.json [new file with mode: 0644]
infra/bots/recipe_modules/compile/example.py
infra/bots/recipe_modules/flavor/api.py
infra/bots/recipe_modules/flavor/gn_chromebook_flavor.py [new file with mode: 0644]
infra/bots/recipe_modules/flavor/gn_chromecast_flavor.py
infra/bots/tasks.json

diff --git a/infra/bots/assets/armhf_sysroot/README.md b/infra/bots/assets/armhf_sysroot/README.md
new file mode 100644 (file)
index 0000000..257acd7
--- /dev/null
@@ -0,0 +1,9 @@
+ARM (hard float) sysroot for cross-compiling c++ code on a x86_64 Linux bot.
+
+Run create_and_upload which installs the following debian packages and turns them
+into a toolchain:
+
+    libstdc++-4.8-dev-armhf-cross libgcc-4.8-dev-armhf-cross binutils-arm-linux-gnueabihf
+
+Take a peak at `/usr/arm-linux-gnueabihf/include/c++/4.8.X` - you may need to update the
+include paths if that number changed from the previous release (currently 4.8.4).
\ No newline at end of file
diff --git a/infra/bots/assets/armhf_sysroot/VERSION b/infra/bots/assets/armhf_sysroot/VERSION
new file mode 100644 (file)
index 0000000..e440e5c
--- /dev/null
@@ -0,0 +1 @@
+3
\ No newline at end of file
diff --git a/infra/bots/assets/armhf_sysroot/common.py b/infra/bots/assets/armhf_sysroot/common.py
new file mode 100755 (executable)
index 0000000..4920c9b
--- /dev/null
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+#
+# Copyright 2016 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+"""Common vars used by scripts in this directory."""
+
+
+import os
+import sys
+
+FILE_DIR = os.path.dirname(os.path.abspath(__file__))
+INFRA_BOTS_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir, os.pardir))
+
+sys.path.insert(0, INFRA_BOTS_DIR)
+from assets import assets
+
+ASSET_NAME = os.path.basename(FILE_DIR)
+
+
+def run(cmd):
+  """Run a command, eg. "upload" or "download". """
+  assets.main([cmd, ASSET_NAME] + sys.argv[1:])
diff --git a/infra/bots/assets/armhf_sysroot/create.py b/infra/bots/assets/armhf_sysroot/create.py
new file mode 100755 (executable)
index 0000000..7be59fb
--- /dev/null
@@ -0,0 +1,78 @@
+#!/usr/bin/env python
+#
+# Copyright 2016 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+"""Create the asset."""
+
+
+import argparse
+import fileinput
+import os
+import shutil
+import subprocess
+import sys
+
+from distutils import dir_util
+
+
+def create_asset(target_dir):
+  """Create the asset."""
+
+  print "Installing some cross-compiling packages. Hit enter to continue."
+  raw_input()
+  subprocess.check_call([
+    "sudo","apt-get","install",
+    "libstdc++-4.8-dev-armhf-cross",
+    "libgcc-4.8-dev-armhf-cross",
+    "binutils-arm-linux-gnueabihf"
+  ])
+
+
+  shutil.copytree('/usr/arm-linux-gnueabihf', target_dir)
+  shutil.copytree('/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8.4',
+    os.path.join(target_dir, 'gcc-cross'))
+  # copy_tree allows copying into a dir that exists
+  # We need to augment the toolchain with some lib*.so that help ld
+  # do its magic as well as some includes that may be useful.
+  dir_util.copy_tree('/usr/x86_64-linux-gnu/arm-linux-gnueabihf/lib',
+                     os.path.join(target_dir, 'lib'))
+  dir_util.copy_tree('/usr/x86_64-linux-gnu/arm-linux-gnueabihf/include',
+                     os.path.join(target_dir, 'include'))
+
+  # The file paths in libpthread.so and libc.so start off as absolute file
+  # paths (e.g. /usr/arm-linux-gnueabihf/lib/libpthread.so.0), which won't
+  # work on the bots. We use fileinput to replace just those lines (which
+  # start with GROUP). fileinput redirects stdout, so printing here actually
+  # writes to the file.
+  bad_libpthread = os.path.join(target_dir, "lib", "libpthread.so")
+  for line in fileinput.input(bad_libpthread, inplace=True):
+    if line.startswith("GROUP"):
+      print "GROUP ( libpthread.so.0 libpthread_nonshared.a )"
+    else:
+      print line
+
+  bad_libc = os.path.join(target_dir, "lib", "libc.so")
+  for line in fileinput.input(bad_libc, inplace=True):
+    if line.startswith("GROUP"):
+      print ("GROUP ( libc.so.6 libc_nonshared.a "
+             "AS_NEEDED ( ld-linux-armhf.so.3 ) )")
+    else:
+      print line
+
+
+def main():
+  if 'linux' not in sys.platform:
+    print >> sys.stderr, 'This script only runs on Linux.'
+    sys.exit(1)
+  parser = argparse.ArgumentParser()
+  parser.add_argument('--target_dir', '-t', required=True)
+  args = parser.parse_args()
+  create_asset(args.target_dir)
+
+
+if __name__ == '__main__':
+  main()
diff --git a/infra/bots/assets/armhf_sysroot/create_and_upload.py b/infra/bots/assets/armhf_sysroot/create_and_upload.py
new file mode 100755 (executable)
index 0000000..b9e6d6f
--- /dev/null
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+#
+# Copyright 2016 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+"""Create the asset and upload it."""
+
+
+import argparse
+import common
+import os
+import subprocess
+import sys
+import utils
+
+
+def main():
+  if 'linux' not in sys.platform:
+    print >> sys.stderr, 'This script only runs on Linux.'
+    sys.exit(1)
+  parser = argparse.ArgumentParser()
+  parser.add_argument('--gsutil')
+  args = parser.parse_args()
+
+  with utils.tmp_dir():
+    cwd = os.getcwd()
+    create_script = os.path.join(common.FILE_DIR, 'create.py')
+    upload_script = os.path.join(common.FILE_DIR, 'upload.py')
+
+    try:
+      cwd = os.path.join(cwd, 'sysroot')
+      subprocess.check_call(['python', create_script, '-t', cwd])
+      cmd = ['python', upload_script, '-t', cwd]
+      if args.gsutil:
+        cmd.extend(['--gsutil', args.gsutil])
+      subprocess.check_call(cmd)
+    except subprocess.CalledProcessError:
+      # Trap exceptions to avoid printing two stacktraces.
+      sys.exit(1)
+
+
+if __name__ == '__main__':
+  main()
diff --git a/infra/bots/assets/armhf_sysroot/download.py b/infra/bots/assets/armhf_sysroot/download.py
new file mode 100755 (executable)
index 0000000..96cc87d
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+#
+# Copyright 2016 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+"""Download the current version of the asset."""
+
+
+import common
+
+
+if __name__ == '__main__':
+  common.run('download')
diff --git a/infra/bots/assets/armhf_sysroot/upload.py b/infra/bots/assets/armhf_sysroot/upload.py
new file mode 100755 (executable)
index 0000000..ba7fc8b
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+#
+# Copyright 2016 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+"""Upload a new version of the asset."""
+
+
+import common
+
+
+if __name__ == '__main__':
+  common.run('upload')
diff --git a/infra/bots/assets/chromebook_c100p_lib/README.md b/infra/bots/assets/chromebook_c100p_lib/README.md
new file mode 100644 (file)
index 0000000..dfa9fcb
--- /dev/null
@@ -0,0 +1,13 @@
+This asset is the necessary includes and libs to compile/link the gpu code
+for the ASUS Flip c100p chromebook. The mali gpu supports EGL and GLES.
+
+Zip up the /usr/lib folder on the Asus C100p Chromebook. Extract it somewhere
+on the dev machine and use that folder as the input to create_and_upload:
+
+    ./infra/bots/assets/chromebook_c100p_lib/create_and_upload.py --lib_path [dir]
+
+This script installs the following GL packages and then bundles them with the
+unzipped libs:
+
+    libgles2-mesa-dev libegl1-mesa-dev
+
diff --git a/infra/bots/assets/chromebook_c100p_lib/VERSION b/infra/bots/assets/chromebook_c100p_lib/VERSION
new file mode 100644 (file)
index 0000000..d8263ee
--- /dev/null
@@ -0,0 +1 @@
+2
\ No newline at end of file
diff --git a/infra/bots/assets/chromebook_c100p_lib/common.py b/infra/bots/assets/chromebook_c100p_lib/common.py
new file mode 100755 (executable)
index 0000000..4920c9b
--- /dev/null
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+#
+# Copyright 2016 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+"""Common vars used by scripts in this directory."""
+
+
+import os
+import sys
+
+FILE_DIR = os.path.dirname(os.path.abspath(__file__))
+INFRA_BOTS_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir, os.pardir))
+
+sys.path.insert(0, INFRA_BOTS_DIR)
+from assets import assets
+
+ASSET_NAME = os.path.basename(FILE_DIR)
+
+
+def run(cmd):
+  """Run a command, eg. "upload" or "download". """
+  assets.main([cmd, ASSET_NAME] + sys.argv[1:])
diff --git a/infra/bots/assets/chromebook_c100p_lib/create.py b/infra/bots/assets/chromebook_c100p_lib/create.py
new file mode 100755 (executable)
index 0000000..2611802
--- /dev/null
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+#
+# Copyright 2016 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+"""Create the asset."""
+
+
+import argparse
+import glob
+import os
+import shutil
+import subprocess
+import sys
+
+
+def create_asset(target_dir, gl_path):
+  """Create the asset."""
+
+  cmd = [
+    'sudo','apt-get','install',
+    'libgles2-mesa-dev',
+    'libegl1-mesa-dev'
+  ]
+  print 'About to run:'
+  print ' '.join(cmd)
+  print 'Press Enter to Continue'
+  raw_input()
+  subprocess.check_call(cmd)
+
+
+  lib_dir = os.path.join(target_dir, 'lib')
+  os.mkdir(lib_dir)
+
+  for f in glob.glob(os.path.join(gl_path,'libGL*')):
+    shutil.copy(f, lib_dir)
+
+  for f in glob.glob(os.path.join(gl_path,'libEGL*')):
+    shutil.copy(f, lib_dir)
+
+  for f in glob.glob(os.path.join(gl_path,'libmali*')):
+    shutil.copy(f, lib_dir)
+
+  include_dir = os.path.join(target_dir, 'include')
+  os.mkdir(include_dir)
+  shutil.copytree('/usr/include/EGL', os.path.join(include_dir, 'EGL'))
+  shutil.copytree('/usr/include/KHR', os.path.join(include_dir, 'KHR'))
+  shutil.copytree('/usr/include/GLES2', os.path.join(include_dir, 'GLES2'))
+  shutil.copytree('/usr/include/GLES3', os.path.join(include_dir, 'GLES3'))
+
+
+def main():
+  if 'linux' not in sys.platform:
+    print >> sys.stderr, 'This script only runs on Linux.'
+    sys.exit(1)
+  parser = argparse.ArgumentParser()
+  parser.add_argument('--target_dir', '-t', required=True)
+  parser.add_argument('--lib_path', '-l', required=True)
+  args = parser.parse_args()
+  create_asset(args.target_dir, args.lib_path)
+
+
+if __name__ == '__main__':
+  main()
diff --git a/infra/bots/assets/chromebook_c100p_lib/create_and_upload.py b/infra/bots/assets/chromebook_c100p_lib/create_and_upload.py
new file mode 100755 (executable)
index 0000000..37e3ff9
--- /dev/null
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+#
+# Copyright 2016 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+"""Create the asset and upload it."""
+
+
+import argparse
+import common
+import os
+import subprocess
+import sys
+import utils
+
+
+def main():
+  if 'linux' not in sys.platform:
+    print >> sys.stderr, 'This script only runs on Linux.'
+    sys.exit(1)
+  parser = argparse.ArgumentParser()
+  parser.add_argument('--gsutil')
+  parser.add_argument('--lib_path', '-l', required=True)
+  args = parser.parse_args()
+
+  with utils.tmp_dir():
+    cwd = os.getcwd()
+    create_script = os.path.join(common.FILE_DIR, 'create.py')
+    upload_script = os.path.join(common.FILE_DIR, 'upload.py')
+
+    try:
+      subprocess.check_call(['python', create_script,
+                             '-t', cwd,
+                             '-l', args.lib_path])
+      cmd = ['python', upload_script, '-t', cwd]
+      if args.gsutil:
+        cmd.extend(['--gsutil', args.gsutil])
+      subprocess.check_call(cmd)
+    except subprocess.CalledProcessError:
+      # Trap exceptions to avoid printing two stacktraces.
+      sys.exit(1)
+
+
+if __name__ == '__main__':
+  main()
diff --git a/infra/bots/assets/chromebook_c100p_lib/download.py b/infra/bots/assets/chromebook_c100p_lib/download.py
new file mode 100755 (executable)
index 0000000..96cc87d
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+#
+# Copyright 2016 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+"""Download the current version of the asset."""
+
+
+import common
+
+
+if __name__ == '__main__':
+  common.run('download')
diff --git a/infra/bots/assets/chromebook_c100p_lib/upload.py b/infra/bots/assets/chromebook_c100p_lib/upload.py
new file mode 100755 (executable)
index 0000000..ba7fc8b
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+#
+# Copyright 2016 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+"""Upload a new version of the asset."""
+
+
+import common
+
+
+if __name__ == '__main__':
+  common.run('upload')
index 900d532..0301034 100644 (file)
@@ -102,6 +102,9 @@ func deriveCompileTaskName(jobName string, parts map[string]string) string {
                } else if task_os == "Chromecast" {
                        task_os = "Ubuntu"
                        ec = "Chromecast"
+               } else if strings.HasPrefix(task_os, "Chromebook") {
+                       ec = task_os
+                       task_os = "Ubuntu"
                } else if task_os == "iOS" {
                        ec = task_os
                        task_os = "Mac"
@@ -260,6 +263,12 @@ func compile(b *specs.TasksCfgBuilder, name string, parts map[string]string) str
                }
        } else if strings.Contains(name, "Chromecast") {
                pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("cast_toolchain"))
+       } else if strings.Contains(name, "Chromebook") {
+               pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux"))
+               pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("armhf_sysroot"))
+               if strings.Contains(name, "Chromebook_C100p") {
+                       pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("chromebook_c100p_lib"))
+               }
        } else if strings.Contains(name, "Ubuntu") {
                if strings.Contains(name, "Clang") {
                        pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux"))
index 4099276..68b3e98 100644 (file)
@@ -10,7 +10,9 @@
   "Build-Mac-Clang-x86_64-Release",
   "Build-Mac-Clang-x86_64-Release-CommandBuffer",
   "Build-Ubuntu-Clang-arm-Debug-Android",
+  "Build-Ubuntu-Clang-arm-Debug-Chromebook_C100p",
   "Build-Ubuntu-Clang-arm-Release-Android",
+  "Build-Ubuntu-Clang-arm-Release-Chromebook_C100p",
   "Build-Ubuntu-Clang-arm64-Debug-Android",
   "Build-Ubuntu-Clang-arm64-Debug-Android_FrameworkDefs",
   "Build-Ubuntu-Clang-arm64-Debug-Android_Vulkan",
diff --git a/infra/bots/recipe_modules/compile/example.expected/Build-Ubuntu-Clang-arm-Release-Chromebook_C100p.json b/infra/bots/recipe_modules/compile/example.expected/Build-Ubuntu-Clang-arm-Release-Chromebook_C100p.json
new file mode 100644 (file)
index 0000000..5cd6c17
--- /dev/null
@@ -0,0 +1,180 @@
+[
+  {
+    "cmd": [
+      "python",
+      "-u",
+      "\nimport sys, os\npath = sys.argv[1]\nmode = int(sys.argv[2])\nif not os.path.isdir(path):\n  if os.path.exists(path):\n    print \"%s exists but is not a dir\" % path\n    sys.exit(1)\n  os.makedirs(path, mode)\n",
+      "[CUSTOM_/_B_WORK]",
+      "511"
+    ],
+    "infra_step": true,
+    "name": "makedirs checkout_path",
+    "~followup_annotations": [
+      "@@@STEP_LOG_LINE@python.inline@@@@",
+      "@@@STEP_LOG_LINE@python.inline@import sys, os@@@",
+      "@@@STEP_LOG_LINE@python.inline@path = sys.argv[1]@@@",
+      "@@@STEP_LOG_LINE@python.inline@mode = int(sys.argv[2])@@@",
+      "@@@STEP_LOG_LINE@python.inline@if not os.path.isdir(path):@@@",
+      "@@@STEP_LOG_LINE@python.inline@  if os.path.exists(path):@@@",
+      "@@@STEP_LOG_LINE@python.inline@    print \"%s exists but is not a dir\" % path@@@",
+      "@@@STEP_LOG_LINE@python.inline@    sys.exit(1)@@@",
+      "@@@STEP_LOG_LINE@python.inline@  os.makedirs(path, mode)@@@",
+      "@@@STEP_LOG_END@python.inline@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "python",
+      "-u",
+      "RECIPE_MODULE[depot_tools::bot_update]/resources/bot_update.py",
+      "--spec",
+      "cache_dir = '[CUSTOM_/_B_CACHE]'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': False, 'name': 'skia', 'url': 'https://skia.googlesource.com/skia.git'}]",
+      "--patch_root",
+      "skia",
+      "--revision_mapping_file",
+      "{\"skia\": \"got_revision\"}",
+      "--git-cache-dir",
+      "[CUSTOM_/_B_CACHE]",
+      "--output_json",
+      "/path/to/tmp/json",
+      "--revision",
+      "skia@abc123",
+      "--output_manifest"
+    ],
+    "cwd": "[CUSTOM_/_B_WORK]",
+    "env": {
+      "GIT_HTTP_LOW_SPEED_LIMIT": "1000",
+      "GIT_HTTP_LOW_SPEED_TIME": "300",
+      "PATH": "%(PATH)s:RECIPE_PACKAGE_REPO[depot_tools]"
+    },
+    "infra_step": true,
+    "name": "bot_update",
+    "~followup_annotations": [
+      "@@@STEP_TEXT@Some step text@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"did_run\": true, @@@",
+      "@@@STEP_LOG_LINE@json.output@  \"fixed_revisions\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"skia\": \"abc123\"@@@",
+      "@@@STEP_LOG_LINE@json.output@  }, @@@",
+      "@@@STEP_LOG_LINE@json.output@  \"manifest\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"skia\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@      \"repository\": \"https://fake.org/skia.git\", @@@",
+      "@@@STEP_LOG_LINE@json.output@      \"revision\": \"9046e2e693bb92a76e972b694580e5d17ad10748\"@@@",
+      "@@@STEP_LOG_LINE@json.output@    }@@@",
+      "@@@STEP_LOG_LINE@json.output@  }, @@@",
+      "@@@STEP_LOG_LINE@json.output@  \"patch_failure\": false, @@@",
+      "@@@STEP_LOG_LINE@json.output@  \"patch_root\": \"skia\", @@@",
+      "@@@STEP_LOG_LINE@json.output@  \"properties\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"got_revision\": \"9046e2e693bb92a76e972b694580e5d17ad10748\", @@@",
+      "@@@STEP_LOG_LINE@json.output@    \"got_revision_cp\": \"refs/heads/master@{#164710}\"@@@",
+      "@@@STEP_LOG_LINE@json.output@  }, @@@",
+      "@@@STEP_LOG_LINE@json.output@  \"root\": \"skia\", @@@",
+      "@@@STEP_LOG_LINE@json.output@  \"step_text\": \"Some step text\"@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@",
+      "@@@SET_BUILD_PROPERTY@got_revision@\"9046e2e693bb92a76e972b694580e5d17ad10748\"@@@",
+      "@@@SET_BUILD_PROPERTY@got_revision_cp@\"refs/heads/master@{#164710}\"@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "python",
+      "-u",
+      "[CUSTOM_/_B_WORK]/skia/bin/fetch-gn"
+    ],
+    "cwd": "[CUSTOM_/_B_WORK]/skia",
+    "env": {
+      "BUILDTYPE": "Release",
+      "CC": "/usr/bin/clang",
+      "CHROME_HEADLESS": "1",
+      "CXX": "/usr/bin/clang++",
+      "LD_LIBRARY_PATH": "[START_DIR]/armhf_sysroot/lib",
+      "PATH": "%(PATH)s:RECIPE_PACKAGE_REPO[depot_tools]",
+      "SKIA_OUT": "[CUSTOM_/_B_WORK]/skia/out/Build-Ubuntu-Clang-arm-Release-Chromebook_C100p"
+    },
+    "infra_step": true,
+    "name": "fetch-gn"
+  },
+  {
+    "cmd": [
+      "[CUSTOM_/_B_WORK]/skia/bin/gn",
+      "gen",
+      "[CUSTOM_/_B_WORK]/skia/out/Build-Ubuntu-Clang-arm-Release-Chromebook_C100p/Release",
+      "--args=cc=\"[START_DIR]/clang_linux/bin/clang\" cxx=\"[START_DIR]/clang_linux/bin/clang++\" extra_asmflags=[\"--target=armv7a-linux-gnueabihf\", \"--sysroot=[START_DIR]/armhf_sysroot\", \"-march=armv7-a\", \"-mfpu=neon\", \"-mthumb\"] extra_cflags=[\"--target=armv7a-linux-gnueabihf\", \"--sysroot=[START_DIR]/armhf_sysroot\", \"-I[START_DIR]/chromebook_c100p_lib/include\", \"-I[START_DIR]/armhf_sysroot/include\", \"-I[START_DIR]/armhf_sysroot/include/c++/4.8.4\", \"-I[START_DIR]/armhf_sysroot/include/c++/4.8.4/arm-linux-gnueabihf\", \"-DMESA_EGL_NO_X11_HEADERS\"] extra_ldflags=[\"--target=armv7a-linux-gnueabihf\", \"--sysroot=[START_DIR]/armhf_sysroot\", \"-B[START_DIR]/armhf_sysroot/bin\", \"-B[START_DIR]/armhf_sysroot/gcc-cross\", \"-L[START_DIR]/armhf_sysroot/gcc-cross\", \"-L[START_DIR]/armhf_sysroot/lib\", \"-L[START_DIR]/chromebook_c100p_lib/lib\"] is_debug=false skia_use_egl=true skia_use_fontconfig=false skia_use_system_freetype2=false target_cpu=\"arm\""
+    ],
+    "cwd": "[CUSTOM_/_B_WORK]/skia",
+    "env": {
+      "BUILDTYPE": "Release",
+      "CC": "/usr/bin/clang",
+      "CHROME_HEADLESS": "1",
+      "CXX": "/usr/bin/clang++",
+      "LD_LIBRARY_PATH": "[START_DIR]/armhf_sysroot/lib",
+      "PATH": "%(PATH)s:RECIPE_PACKAGE_REPO[depot_tools]",
+      "SKIA_OUT": "[CUSTOM_/_B_WORK]/skia/out/Build-Ubuntu-Clang-arm-Release-Chromebook_C100p"
+    },
+    "name": "gn gen"
+  },
+  {
+    "cmd": [
+      "ninja",
+      "-C",
+      "[CUSTOM_/_B_WORK]/skia/out/Build-Ubuntu-Clang-arm-Release-Chromebook_C100p/Release",
+      "nanobench",
+      "dm"
+    ],
+    "cwd": "[CUSTOM_/_B_WORK]/skia",
+    "env": {
+      "BUILDTYPE": "Release",
+      "CC": "/usr/bin/clang",
+      "CHROME_HEADLESS": "1",
+      "CXX": "/usr/bin/clang++",
+      "LD_LIBRARY_PATH": "[START_DIR]/armhf_sysroot/lib",
+      "PATH": "%(PATH)s:RECIPE_PACKAGE_REPO[depot_tools]",
+      "SKIA_OUT": "[CUSTOM_/_B_WORK]/skia/out/Build-Ubuntu-Clang-arm-Release-Chromebook_C100p"
+    },
+    "name": "ninja"
+  },
+  {
+    "cmd": [
+      "python",
+      "-u",
+      "import errno\nimport glob\nimport os\nimport shutil\nimport sys\n\nsrc = sys.argv[1]\ndst = sys.argv[2]\nbuild_products_whitelist = ['dm', 'dm.exe', 'get_images_from_skps', 'get_images_from_skps.exe', 'nanobench', 'nanobench.exe', 'skpbench', '*.so', '*.dll', '*.dylib', 'skia_launcher', 'lib/*.so', 'iOSShell.app', 'iOSShell.ipa', 'visualbench', 'visualbench.exe', 'vulkan-1.dll']\n\ntry:\n  os.makedirs(dst)\nexcept OSError as e:\n  if e.errno != errno.EEXIST:\n    raise\n\nfor pattern in build_products_whitelist:\n  path = os.path.join(src, pattern)\n  for f in glob.glob(path):\n    dst_path = os.path.join(dst, os.path.relpath(f, src))\n    if not os.path.isdir(os.path.dirname(dst_path)):\n      os.makedirs(os.path.dirname(dst_path))\n    print 'Copying build product %s to %s' % (f, dst_path)\n    shutil.move(f, dst_path)\n",
+      "[CUSTOM_/_B_WORK]/skia/out/Build-Ubuntu-Clang-arm-Release-Chromebook_C100p/Release",
+      "[CUSTOM_[SWARM_OUT_DIR]]/out/Release"
+    ],
+    "infra_step": true,
+    "name": "copy build products",
+    "~followup_annotations": [
+      "@@@STEP_LOG_LINE@python.inline@import errno@@@",
+      "@@@STEP_LOG_LINE@python.inline@import glob@@@",
+      "@@@STEP_LOG_LINE@python.inline@import os@@@",
+      "@@@STEP_LOG_LINE@python.inline@import shutil@@@",
+      "@@@STEP_LOG_LINE@python.inline@import sys@@@",
+      "@@@STEP_LOG_LINE@python.inline@@@@",
+      "@@@STEP_LOG_LINE@python.inline@src = sys.argv[1]@@@",
+      "@@@STEP_LOG_LINE@python.inline@dst = sys.argv[2]@@@",
+      "@@@STEP_LOG_LINE@python.inline@build_products_whitelist = ['dm', 'dm.exe', 'get_images_from_skps', 'get_images_from_skps.exe', 'nanobench', 'nanobench.exe', 'skpbench', '*.so', '*.dll', '*.dylib', 'skia_launcher', 'lib/*.so', 'iOSShell.app', 'iOSShell.ipa', 'visualbench', 'visualbench.exe', 'vulkan-1.dll']@@@",
+      "@@@STEP_LOG_LINE@python.inline@@@@",
+      "@@@STEP_LOG_LINE@python.inline@try:@@@",
+      "@@@STEP_LOG_LINE@python.inline@  os.makedirs(dst)@@@",
+      "@@@STEP_LOG_LINE@python.inline@except OSError as e:@@@",
+      "@@@STEP_LOG_LINE@python.inline@  if e.errno != errno.EEXIST:@@@",
+      "@@@STEP_LOG_LINE@python.inline@    raise@@@",
+      "@@@STEP_LOG_LINE@python.inline@@@@",
+      "@@@STEP_LOG_LINE@python.inline@for pattern in build_products_whitelist:@@@",
+      "@@@STEP_LOG_LINE@python.inline@  path = os.path.join(src, pattern)@@@",
+      "@@@STEP_LOG_LINE@python.inline@  for f in glob.glob(path):@@@",
+      "@@@STEP_LOG_LINE@python.inline@    dst_path = os.path.join(dst, os.path.relpath(f, src))@@@",
+      "@@@STEP_LOG_LINE@python.inline@    if not os.path.isdir(os.path.dirname(dst_path)):@@@",
+      "@@@STEP_LOG_LINE@python.inline@      os.makedirs(os.path.dirname(dst_path))@@@",
+      "@@@STEP_LOG_LINE@python.inline@    print 'Copying build product %s to %s' % (f, dst_path)@@@",
+      "@@@STEP_LOG_LINE@python.inline@    shutil.move(f, dst_path)@@@",
+      "@@@STEP_LOG_END@python.inline@@@"
+    ]
+  },
+  {
+    "name": "$result",
+    "recipe_result": null,
+    "status_code": 0
+  }
+]
\ No newline at end of file
index c369f52..691be13 100644 (file)
@@ -22,6 +22,7 @@ TEST_BUILDERS = {
       'Build-Mac-Clang-x64-Release-iOS',
       'Build-Mac-Clang-x86_64-Debug-CommandBuffer',
       'Build-Mac-Clang-x86_64-Release-GN',
+      'Build-Ubuntu-Clang-arm-Release-Chromebook_C100p',
       'Build-Ubuntu-Clang-arm64-Debug-GN_Android-Trybot',
       'Build-Ubuntu-Clang-arm64-Debug-GN_Android_FrameworkDefs',
       'Build-Ubuntu-Clang-arm64-Release-GN_Android',
index b3093b4..3c49716 100644 (file)
@@ -11,6 +11,7 @@ from recipe_engine import recipe_api
 from . import default_flavor
 from . import flutter_flavor
 from . import gn_android_flavor
+from . import gn_chromebook_flavor
 from . import gn_chromecast_flavor
 from . import gn_flavor
 from . import ios_flavor
@@ -35,6 +36,10 @@ def is_chromecast(builder_cfg):
   return ('Chromecast' in builder_cfg.get('extra_config', '') or
           'Chromecast' in builder_cfg.get('os', ''))
 
+def is_chromebook(builder_cfg):
+  return ('Chromebook' in builder_cfg.get('extra_config', '') or
+          'Chromebook' in builder_cfg.get('os', ''))
+
 def is_flutter(builder_cfg):
   return 'Flutter' in builder_cfg.get('extra_config', '')
 
@@ -55,6 +60,8 @@ class SkiaFlavorApi(recipe_api.RecipeApi):
       return flutter_flavor.FlutterFlavorUtils(self.m)
     if is_chromecast(builder_cfg):
       return gn_chromecast_flavor.GNChromecastFlavorUtils(self.m)
+    if is_chromebook(builder_cfg):
+      return gn_chromebook_flavor.GNChromebookFlavorUtils(self.m)
     if is_android(builder_cfg):
       return gn_android_flavor.GNAndroidFlavorUtils(self.m)
     elif is_ios(builder_cfg):
diff --git a/infra/bots/recipe_modules/flavor/gn_chromebook_flavor.py b/infra/bots/recipe_modules/flavor/gn_chromebook_flavor.py
new file mode 100644 (file)
index 0000000..70b138d
--- /dev/null
@@ -0,0 +1,96 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from recipe_engine import recipe_api
+
+import gn_flavor
+import subprocess
+
+
+"""
+  GN Chromebook flavor utils, used for building and testing Skia for ARM
+  Chromebooks with GN
+"""
+class GNChromebookFlavorUtils(gn_flavor.GNFlavorUtils):
+
+  def compile(self, unused_target):
+    configuration = self.m.vars.builder_cfg.get('configuration')
+    os            = self.m.vars.builder_cfg.get('os')
+    target_arch   = self.m.vars.builder_cfg.get('target_arch')
+    extra_config  = self.m.vars.builder_cfg.get('extra_config', '')
+
+    clang_linux = self.m.vars.slave_dir.join('clang_linux')
+    # This is a pretty typical arm-linux-gnueabihf sysroot
+    sysroot_dir = self.m.vars.slave_dir.join('armhf_sysroot')
+    # This is the extra things needed to link against for the chromebook.
+    #  For example, the Mali GL drivers.
+    if extra_config == 'Chromebook_C100p':
+      gl_dir   = self.m.vars.slave_dir.join('chromebook_c100p_lib')
+
+    extra_asmflags = [
+      '--target=armv7a-linux-gnueabihf',
+      '--sysroot=%s' % sysroot_dir,
+      '-march=armv7-a',
+      '-mfpu=neon',
+      '-mthumb',
+    ]
+
+    extra_cflags = [
+      '--target=armv7a-linux-gnueabihf',
+      '--sysroot=%s' % sysroot_dir,
+      '-I%s' % gl_dir.join('include'),
+      '-I%s' % sysroot_dir.join('include'),
+      '-I%s' % sysroot_dir.join('include', 'c++', '4.8.4'),
+      '-I%s' % sysroot_dir.join('include', 'c++', '4.8.4',
+                                'arm-linux-gnueabihf'),
+       '-DMESA_EGL_NO_X11_HEADERS',
+    ]
+
+    extra_ldflags = [
+      '--target=armv7a-linux-gnueabihf',
+      '--sysroot=%s' % sysroot_dir,
+      # use sysroot's ld which can properly link things.
+      '-B%s' % sysroot_dir.join('bin'),
+      # helps locate crt*.o
+      '-B%s' % sysroot_dir.join('gcc-cross'),
+      # helps locate libgcc*.so
+      '-L%s' % sysroot_dir.join('gcc-cross'),
+      '-L%s' % sysroot_dir.join('lib'),
+      '-L%s' % gl_dir.join('lib'),
+      # Explicitly do not use lld for cross compiling like this - I observed
+      # failures like "Unrecognized reloc 41" and couldn't find out why.
+    ]
+
+    quote = lambda x: '"%s"' % x
+    args = {
+      'cc': quote(clang_linux.join('bin','clang')),
+      'cxx': quote(clang_linux.join('bin','clang++')),
+      'target_cpu': quote(target_arch),
+      'skia_use_fontconfig': 'false',
+      'skia_use_system_freetype2': 'false',
+      'skia_use_egl': 'true',
+    }
+
+    if configuration != 'Debug':
+      args['is_debug'] = 'false'
+    args['extra_asmflags'] = repr(extra_asmflags).replace("'", '"')
+    args['extra_cflags'] = repr(extra_cflags).replace("'", '"')
+    args['extra_ldflags'] = repr(extra_ldflags).replace("'", '"')
+
+    gn_args = ' '.join('%s=%s' % (k,v) for (k,v) in sorted(args.iteritems()))
+
+    gn    = 'gn.exe'    if 'Win' in os else 'gn'
+    ninja = 'ninja.exe' if 'Win' in os else 'ninja'
+    gn = self.m.vars.skia_dir.join('bin', gn)
+
+    context = {
+      'cwd': self.m.vars.skia_dir,
+      'env': {
+          'LD_LIBRARY_PATH': sysroot_dir.join('lib'),
+      }
+    }
+    with self.m.step.context(context):
+      self._py('fetch-gn', self.m.vars.skia_dir.join('bin', 'fetch-gn'))
+      self._run('gn gen', [gn, 'gen', self.out_dir, '--args=' + gn_args])
+      self._run('ninja', [ninja, '-C', self.out_dir, 'nanobench', 'dm'])
index 2b5983d..0296d98 100644 (file)
@@ -25,6 +25,7 @@ class GNChromecastFlavorUtils(gn_android_flavor.GNAndroidFlavorUtils):
     # Chromecast does not package libstdc++
     extra_ldflags = ['-static-libstdc++', '-static-libgcc']
 
+    # TODO(kjlubick): can this toolchain be replaced/shared with chromebook?
     toolchain_dir = self.m.vars.slave_dir.join('cast_toolchain')
 
     quote = lambda x: '"%s"' % x
index 7342741..5d97f6d 100644 (file)
         "Build-Ubuntu-Clang-arm-Debug-Android"
       ]
     },
+    "Build-Ubuntu-Clang-arm-Debug-Chromebook_C100p": {
+      "priority": 0.8,
+      "tasks": [
+        "Build-Ubuntu-Clang-arm-Debug-Chromebook_C100p"
+      ]
+    },
     "Build-Ubuntu-Clang-arm-Release-Android": {
       "priority": 0.8,
       "tasks": [
         "Build-Ubuntu-Clang-arm-Release-Android"
       ]
     },
+    "Build-Ubuntu-Clang-arm-Release-Chromebook_C100p": {
+      "priority": 0.8,
+      "tasks": [
+        "Build-Ubuntu-Clang-arm-Release-Chromebook_C100p"
+      ]
+    },
     "Build-Ubuntu-Clang-arm64-Debug-Android": {
       "priority": 0.8,
       "tasks": [
       "isolate": "compile_skia.isolate",
       "priority": 0.8
     },
+    "Build-Ubuntu-Clang-arm-Debug-Chromebook_C100p": {
+      "cipd_packages": [
+        {
+          "name": "skia/bots/clang_linux",
+          "path": "clang_linux",
+          "version": "version:4"
+        },
+        {
+          "name": "skia/bots/armhf_sysroot",
+          "path": "armhf_sysroot",
+          "version": "version:3"
+        },
+        {
+          "name": "skia/bots/chromebook_c100p_lib",
+          "path": "chromebook_c100p_lib",
+          "version": "version:2"
+        }
+      ],
+      "dimensions": [
+        "cpu:x86-64-avx2",
+        "gpu:none",
+        "os:Ubuntu-14.04",
+        "pool:Skia"
+      ],
+      "extra_args": [
+        "--workdir",
+        "../../..",
+        "swarm_compile",
+        "repository=<(REPO)",
+        "buildername=Build-Ubuntu-Clang-arm-Debug-Chromebook_C100p",
+        "mastername=fake-master",
+        "buildnumber=2",
+        "slavename=fake-buildslave",
+        "nobuildbot=True",
+        "swarm_out_dir=${ISOLATED_OUTDIR}",
+        "revision=<(REVISION)",
+        "patch_storage=<(PATCH_STORAGE)",
+        "patch_issue=<(ISSUE)",
+        "patch_set=<(PATCHSET)"
+      ],
+      "isolate": "compile_skia.isolate",
+      "priority": 0.8
+    },
     "Build-Ubuntu-Clang-arm-Release-Android": {
       "cipd_packages": [
         {
       "isolate": "compile_skia.isolate",
       "priority": 0.8
     },
+    "Build-Ubuntu-Clang-arm-Release-Chromebook_C100p": {
+      "cipd_packages": [
+        {
+          "name": "skia/bots/clang_linux",
+          "path": "clang_linux",
+          "version": "version:4"
+        },
+        {
+          "name": "skia/bots/armhf_sysroot",
+          "path": "armhf_sysroot",
+          "version": "version:3"
+        },
+        {
+          "name": "skia/bots/chromebook_c100p_lib",
+          "path": "chromebook_c100p_lib",
+          "version": "version:2"
+        }
+      ],
+      "dimensions": [
+        "cpu:x86-64-avx2",
+        "gpu:none",
+        "os:Ubuntu-14.04",
+        "pool:Skia"
+      ],
+      "extra_args": [
+        "--workdir",
+        "../../..",
+        "swarm_compile",
+        "repository=<(REPO)",
+        "buildername=Build-Ubuntu-Clang-arm-Release-Chromebook_C100p",
+        "mastername=fake-master",
+        "buildnumber=2",
+        "slavename=fake-buildslave",
+        "nobuildbot=True",
+        "swarm_out_dir=${ISOLATED_OUTDIR}",
+        "revision=<(REVISION)",
+        "patch_storage=<(PATCH_STORAGE)",
+        "patch_issue=<(ISSUE)",
+        "patch_set=<(PATCHSET)"
+      ],
+      "isolate": "compile_skia.isolate",
+      "priority": 0.8
+    },
     "Build-Ubuntu-Clang-arm64-Debug-Android": {
       "cipd_packages": [
         {