[Crosswalk] Integrate with Crosswalk gclient machinary.
authorAntonio Gomes <a1.gomes@samsung.com>
Wed, 3 Dec 2014 14:07:33 +0000 (06:07 -0800)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
Crosswalk first pulls itself (into src/xwalk) and then re-run
gclient in order to pull src and all its dependencies.

Patch makes it possible to pull in a custom src and blink code
by forking and adapting src/walk/DEPS.xwalk and src/xwalk/generate_gclient-xwalk.py.
(see script/xwalk). Patch also reintroduces sync_repos.sh, adapted
to crosswalk's integration needs.

Patch also adapts our build system to have .gclient as entry point.

Precedure:

$ create .gclient file (as below)
$ gclient sync

Details:

1) Gclient pulls chromium-efl into "src/tizen_src".
2) The it runs 3 custom hooks in order to get the rest of the source:
*) fetch-src-blink: src/tizen_src/sync_repos.sh is called and
   pulls in src and src/third_party/WebKit from a pre-defined locations.
*) generate-gclient-xwalk: .gclient-xwalk is created by running
   src/tizen_src/scripts/xwalkgenerate_gclient-xwalk.py (this is a fork
   of the same script in xwalk repository).
4) 'fetch-deps': actually fetches all depedencies in .gclient-xwalk.

.gclient content:

solutions = [
  { "name"        : "src/tizen_src",
    "url"         : "<chromium_efl_clone_url@branch>",
    "deps_file"   : "DEPS",
    "managed"     : True,
    "custom_hooks": [
      {
        # fetch custom src and blink repositories.
        "name": "fetch-src-blink",
        "pattern": ".",
        "action": ["src/tizen_src/sync_repos.sh"],
      },
      {
        # Generate .gclient-xwalk for Crosswalk's dependencies.
        "name": "generate-gclient-xwalk",
        "pattern": ".",
        "action": ["python", "src/tizen_src/scripts/xwalk/generate_gclient-xwalk.py"],
      },
      {
        # Fetch Crosswalk dependencies.
        "name": "fetch-deps",
        "pattern": ".",
        "action": ["python", "src/xwalk/tools/fetch_deps.py", "-v"],
      },
      {
        # At some point, we will integrate to gyp_xwalk. Not now...
        "name": "gyp-xwalk",
      }
    ],
    "safesync_url": "",
  },
]
cache_dir = None

Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=8505

Change-Id: I6d189daa1eae37a963422e0e0aa9102d871c667c
Signed-off-by: Piotr Tworek <p.tworek@samsung.com>
tizen_src/scripts/xwalk/DEPS.xwalk [new file with mode: 0644]
tizen_src/scripts/xwalk/generate_gclient-xwalk.py [new file with mode: 0755]
tizen_src/sync_repos.sh

diff --git a/tizen_src/scripts/xwalk/DEPS.xwalk b/tizen_src/scripts/xwalk/DEPS.xwalk
new file mode 100644 (file)
index 0000000..6e8ebce
--- /dev/null
@@ -0,0 +1,115 @@
+# Source code dependencies required for building Crosswalk.
+#
+# This file is used as a template to generate .gclient-xwalk, which is a
+# regular .gclient file pointing to additional source code repositories that
+# need to be checked out in order to build Crosswalk.
+#
+# These dependencies are not specified in DEPS for historical compatibility
+# reasons and also to allow us to perform some additional manipulation on some
+# entries (such as setting a custom value for "deps_file" in certain
+# solutions).
+#
+# If you are doing a DEPS roll, you should only need to worry about the *_rev
+# variables below.
+
+# -----------------------------------
+# Crosswalk dependencies.
+# Edit these when rolling DEPS.xwalk.
+# -----------------------------------
+
+chromium_crosswalk_rev = '52d4347d95a66afe54be98677b077fce0b7fd846'
+v8_crosswalk_rev = '35e0d97482e74df63e75088eec0378f19bad24dd'
+ozone_wayland_rev = '8f3a1b59dd183087269400208947031cac5fcfcd'
+
+# |blink_crosswalk_rev| specifies the SHA1 hash of the blink-crosswalk commit
+# we want to point to, very much like the variables above.
+# |blink_upstream_rev| indicates the revision of the latest upstream commit in
+# the blink-crosswalk repository, so that the devtools code can use it to fetch
+# assets from Chromium's servers with a revision that exists there. We need an
+# SVN revision while Blink is still in SVN.
+blink_crosswalk_rev = 'a6caf4f53deee46eb41c31d38dc990964615b8e5'
+blink_upstream_rev = '184144'  # FIXME(wang16): Specify a later revision than
+                               # the one we actually have in blink-crosswalk
+                               # because of crbug.com/425155.
+                               # This will not be needed in M40 or M39 past
+                               # Blink r184144.
+
+crosswalk_git = 'https://github.com/crosswalk-project'
+ozone_wayland_git = 'https://github.com/01org'
+
+# ------------------------------------------------------
+# gclient solutions.
+# You do not need to worry about these most of the time.
+# ------------------------------------------------------
+
+solutions = [
+  { 'name': 'src',
+    'url' : 'git://github.com/crosswalk-project/chromium-crosswalk-efl.git',
+    'deps_file': '.DEPS.git',
+    'custom_deps': {
+      'src': None,
+      'src/third_party/WebKit': None,
+      'src/v8':
+        crosswalk_git + '/v8-crosswalk.git@' + v8_crosswalk_rev,
+
+      # Include OpenCL header files for WebCL support, target version 1.2.
+      'src/third_party/khronos/CL':
+        'https://cvs.khronos.org/svn/repos/registry/trunk/public/cl/api/1.2@'
+           '28150',
+
+      # These directories are not relevant to Crosswalk and can be safely ignored
+      # in a checkout. It avoids creating additional directories outside src/ that
+      # are not used and also saves some bandwidth.
+      'build': None,
+      'build/scripts/command_wrapper/bin': None,
+      'build/scripts/gsd_generate_index': None,
+      'build/scripts/private/data/reliability': None,
+      'build/scripts/tools/deps2git': None,
+      'build/third_party/cbuildbot_chromite': None,
+      'build/third_party/gsutil': None,
+      'build/third_party/lighttpd': None,
+      'build/third_party/swarm_client': None,
+      'build/third_party/xvfb': None,
+      'build/xvfb': None,
+      'commit-queue': None,
+      'depot_tools': None,
+    },
+
+    'custom_hooks': [
+      # Disable Chromium's "gyp" hooks, which runs the gyp_chromium script. We
+      # are not interested in running it as we use gyp_xwalk instead (and it is
+      # run at a later stage as a hook in Crosswalk's own DEPS).
+      {
+        'name': 'gyp',
+      },
+    ],
+  },
+
+  # ozone-wayland is set as a separate solution because we gclient _not_ to read
+  # its .DEPS.git: it changes the recursion limit and tries to check Chromium
+  # upstream out itself, leading to URL conflicts and errors about duplicate
+  # entries.
+  { 'name': 'src/ozone',
+    'url': ozone_wayland_git + '/ozone-wayland.git@' + ozone_wayland_rev,
+    'deps_file': '',
+  }
+]
+
+hooks = [
+  {
+    'action': [
+      'python',
+      'src/xwalk/tools/upstream_revision.py',
+      '-r',
+      blink_upstream_rev,
+      '-o',
+      'src/xwalk/build/UPSTREAM.blink'
+    ],
+    'pattern': '.',
+    'name': 'upstream_revision'
+  }
+]
+
+# -------------------------------------------------
+# This area is edited by generate_gclient-xwalk.py.
+# -------------------------------------------------
diff --git a/tizen_src/scripts/xwalk/generate_gclient-xwalk.py b/tizen_src/scripts/xwalk/generate_gclient-xwalk.py
new file mode 100755 (executable)
index 0000000..63449fb
--- /dev/null
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2013 Intel Corporation. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+This script is responsible for generating .gclient-xwalk in the top-level
+source directory from DEPS.xwalk.
+
+User-configurable values such as |cache_dir| are fetched from .gclient instead.
+"""
+
+import logging
+import optparse
+import os
+import pprint
+
+
+CROSSWALK_ROOT = os.path.dirname(os.path.abspath(__file__))
+GCLIENT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(CROSSWALK_ROOT))))
+
+def ParseGClientConfig():
+  """
+  Parses the top-level .gclient file (NOT .gclient-xwalk) and returns the
+  values set there as a dictionary.
+  """
+  with open(os.path.join(GCLIENT_ROOT, '.gclient')) as dot_gclient:
+    config = {}
+    exec(dot_gclient, config)
+  return config
+
+
+def GenerateGClientXWalk(options):
+  with open(os.path.join(CROSSWALK_ROOT, 'DEPS.xwalk')) as deps_file:
+    deps_contents = deps_file.read()
+
+  if 'XWALK_OS_ANDROID' in os.environ:
+    deps_contents += 'target_os = [\'android\']\n'
+
+  gclient_config = ParseGClientConfig()
+  if options.cache_dir:
+    logging.warning('--cache_dir is deprecated and will be removed in '
+                    'Crosswalk 8. You should set cache_dir in .gclient '
+                    'instead.')
+    cache_dir = options.cache_dir
+  else:
+    cache_dir = gclient_config.get('cache_dir')
+  deps_contents += 'cache_dir = %s\n' % pprint.pformat(cache_dir)
+
+  with open(os.path.join(GCLIENT_ROOT, '.gclient-xwalk'), 'w') as gclient_file:
+    gclient_file.write(deps_contents)
+
+
+def main():
+  option_parser = optparse.OptionParser()
+  # TODO(rakuco): Remove in Crosswalk 8.
+  option_parser.add_option('--cache-dir',
+                           help='DEPRECATED Set "cache_dir" in .gclient-xwalk '
+                                'to this directory, so that all git '
+                                'repositories are cached there.')
+  options, _ = option_parser.parse_args()
+  GenerateGClientXWalk(options)
+
+
+if __name__ == '__main__':
+  main()
index d013b40..a5e5658 100755 (executable)
 #!/bin/bash
 
-BRANCH=beta/m40_2214_t
-URLBASE=$(git ls-remote --get-url)
-if echo "$@" | grep -c "\-\-reset" &> /dev/null; then
-  isReset=1
-fi
+SCRIPTDIR=$( cd $(dirname $0) ; pwd -P )
+TOPDIR=$( cd ${SCRIPTDIR}/../.. ; pwd -P )
 
-# Remove untracked files and directories.
-# This is needed by buildbot to avoid conflict when applying a patch.
-# Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=9584
-# WARNING: Be careful when using this since it'll delete your local changes.
-CleanCommand=':'
-if echo "$@" | grep -c "\-\-clean" &> /dev/null; then
-  CleanCommand='git clean -df'
-fi
-$CleanCommand
+BRANCH=efl/crosswalk-10/39.0.2171.19
+BRANCH_XWALK=master
 
-isLocalGit=$([ -d "$URLBASE" ] && echo 1 || echo 0)
-if [ $isLocalGit == "1" ]; then
-  declare -a REPOS
-  local_gits=$(find $URLBASE/src -name .git -type d | xargs dirname | sort)
-  for REPO in $local_gits; do
-    REPOPATH=${REPO#$URLBASE/}
-    echo $REPO $REPOPATH
-    if [ -d $REPOPATH ] ; then
-      pushd $REPOPATH 2>&1 > /dev/null
-      $CleanCommand
-      git fetch $REPO
-      if [ "$isReset" == "1" ]; then
-        git reset --hard FETCH_HEAD
-      else
-        git rebase FETCH_HEAD || exit $?
-      fi
-      popd 2>&1 >/dev/null
-    else
-      git clone $REPO $REPOPATH
-    fi
-  done
+URLBASE='git://github.com/crosswalk-project'
 
-  if [ -d $URLBASE/out.x64/Dependencies ] && [ ! -d out.x64/Dependencies ]; then
-    SCRIPTDIR=$(cd $(dirname $0); pwd -P)
-    SRCDIR=$URLBASE/out.x64/Dependencies
-    TGTDIR=$SCRIPTDIR/out.x64/Dependencies
-    mkdir out.x64 || :
-    cp -al $SRCDIR out.x64/
-    find out.x64/Dependencies -name *.pc -exec sed -i "s:$SRCDIR:$TGTDIR:g" {} \;
-  fi
-  exit
-fi
+REPOS=( "src|$URLBASE/chromium-crosswalk-efl.git|$BRANCH" \
+        "src/third_party/WebKit|$URLBASE/blink-crosswalk-efl.git|$BRANCH" \
+        "src/xwalk|$URLBASE/crosswalk.git|$BRANCH_XWALK" \
+      )
 
-URLBASE=$(dirname $URLBASE)
-REPOS=( "src|$URLBASE/s-chromium.git" \
-        "src/third_party/WebKit|$URLBASE/s-blink" \
-        "src/third_party/skia|$URLBASE/s-skia.git" \
-        "src/third_party/libjingle/source/talk|$URLBASE/s-libjingle_source_talk.git" \
-        "src/third_party/webrtc|$URLBASE/s-webrtc.git" \
-        "src/v8|$URLBASE/s-v8" )
-
-function rmdir_if_not_repo {
-  REPOPATH=$1
-  REPOURL=$2
-  if [ -d $REPOPATH ] ; then
-    isDesiredRepo=$(git --git-dir=$REPOPATH/.git --work-tree=$REPOPATH ls-remote --get-url \
-                    | grep -c $REPOURL || :)
-    if [ "$isDesiredRepo" == "0" ] ; then
-      echo "... Deleting ${REPOPATH} (backup: ${REPOPATH}.bak)"
-      mv ${REPOPATH} ${REPOPATH}.bak 2>&1 > /dev/null
-    fi
-  fi
-}
+pushd $TOPDIR 2>&1 > /dev/null
 
 for K in ${REPOS[@]} ; do
   L=(${K//\|/ })
   REPOPATH=${L[0]}
   REPO=${L[1]}
-  rmdir_if_not_repo $REPOPATH $REPO
-  if [ -d $REPOPATH ] ; then
+  BRANCH=${L[2]}
+
+  if [[ ! -d $REPOPATH || ! -d $REPOPATH/.git ]] ; then
+    echo Cloning branch $BRANCH of $REPO into $REPOPATH
+    mkdir -p $REPOPATH
+    pushd $REPOPATH 2>&1 > /dev/null
+    git init .
+    git remote add -t \* -f origin $REPO
+    git fetch $REPO $BRANCH:$BRANCH
+    git checkout $BRANCH
+    popd 2>&1 >/dev/null
+  else
     pushd $REPOPATH 2>&1 > /dev/null
-    $CleanCommand
     CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD`
     if [ "x$CURRENT_BRANCH" == "x$BRANCH" ] ; then
       echo Updating branch $BRANCH of $REPO in $REPOPATH
       git fetch $REPO $BRANCH
-      if [ "$isReset" == "1" ]; then
-        git reset --hard FETCH_HEAD
-      else
-        git rebase FETCH_HEAD || exit $?
-      fi
+      git rebase FETCH_HEAD
     else
       echo Fetching branch $BRANCH of $REPO into $REPOPATH
-      REMOTENAME=$(git remote -v | grep -m 1 $REPO | cut -f1)
-      git remote set-branches --add $REMOTENAME $BRANCH
-      git fetch $REMOTENAME $BRANCH
-      git checkout ${isReset:+-f} -B $BRANCH --track $REMOTENAME/$BRANCH
+      git fetch $REPO $BRANCH:$BRANCH
+      git checkout $BRANCH
     fi
     popd 2>&1 >/dev/null
-  else
-    echo Cloning branch $BRANCH of $REPO into $REPOPATH
-    git clone --single-branch -b $BRANCH $REPO $REPOPATH
   fi
 done
 
-if [ "$isReset" == "1" ]; then
-    gclient sync -R -f
-fi
+popd 2>&1 >/dev/null