| #!/usr/bin/env python |
| # Copyright (C) 2011 Igalia S.L. |
| # Copyright (C) 2012 Gustavo Noronha Silva <gns@gnome.org> |
| # Copyright (C) 2012 Intel Corporation |
| # |
| # This library is free software; you can redistribute it and/or |
| # modify it under the terms of the GNU Lesser General Public |
| # License as published by the Free Software Foundation; either |
| # version 2 of the License, or (at your option) any later version. |
| # |
| # This library is distributed in the hope that it will be useful, |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| # Lesser General Public License for more details. |
| # |
| # You should have received a copy of the GNU Lesser General Public |
| # License along with this library; if not, write to the Free Software |
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| |
| import os |
| import subprocess |
| import sys |
| |
| |
| top_level_dir = None |
| |
| |
| def top_level_path(*args): |
| global top_level_dir |
| if not top_level_dir: |
| top_level_dir = os.path.join(os.path.dirname(__file__), '..', '..') |
| return os.path.join(*(top_level_dir,) + args) |
| |
| |
| jhbuild_revision = '1eedc423f75c605224b430579e4c303292199507' |
| |
| installation_prefix = os.path.abspath(top_level_path('WebKitBuild', 'Dependencies', 'Root')) |
| source_path = os.path.abspath(top_level_path('WebKitBuild', 'Dependencies', 'Source')) |
| jhbuild_source_path = os.path.join(source_path, 'jhbuild') |
| jhbuild_path = top_level_path('WebKitBuild', 'Dependencies', 'Root', 'bin', 'jhbuild') |
| platform = None; |
| |
| |
| def jhbuild_installed(): |
| return os.path.exists(jhbuild_path) |
| |
| |
| def jhbuild_cloned(): |
| return os.path.exists(jhbuild_source_path) |
| |
| |
| def jhbuild_at_expected_revision(): |
| process = subprocess.Popen(['git', 'rev-list', 'HEAD^..'], cwd=jhbuild_source_path, |
| stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| output, err = process.communicate() |
| if process.returncode != 0: |
| raise Exception('failed to find jhbuild revision: %s' % err) |
| |
| return output.strip() == jhbuild_revision |
| |
| |
| def update_jhbuild(): |
| process = subprocess.Popen(['git', 'remote', 'update', 'origin'], cwd=jhbuild_source_path) |
| process.wait() |
| if process.returncode != 0: |
| raise Exception('jhbuild remote update origin failed with return code: %i' % process.returncode) |
| |
| process = subprocess.Popen(['git', 'checkout', '%s' % jhbuild_revision], |
| cwd=jhbuild_source_path) |
| process.wait() |
| if process.returncode != 0: |
| raise Exception('failed to checkout treeish %s: %i' % (jhbuild_revision, process.returncode)) |
| |
| |
| def clone_jhbuild(): |
| if not os.path.exists(source_path): |
| os.makedirs(source_path) |
| if not os.path.exists(installation_prefix): |
| os.makedirs(installation_prefix) |
| |
| process = subprocess.Popen(['git', 'clone', 'git://git.gnome.org/jhbuild'], cwd=source_path) |
| process.wait() |
| if process.returncode != 0: |
| raise Exception('jhbuild git clone failed with return code: %i' % process.returncode) |
| |
| |
| def install_jhbuild(): |
| process = subprocess.Popen(['bash', './autogen.sh', '--prefix=%s' % installation_prefix], cwd=jhbuild_source_path) |
| process.wait() |
| if process.returncode != 0: |
| raise Exception('jhbuild configure failed with return code: %i' % process.returncode) |
| |
| process = subprocess.Popen(['make', 'install'], cwd=jhbuild_source_path) |
| process.wait() |
| if process.returncode != 0: |
| raise Exception('jhbuild configure failed with return code: %i' % process.returncode) |
| |
| |
| def update_webkit_libs_jhbuild(): |
| process = subprocess.Popen([top_level_path('Tools', 'Scripts', 'update-webkit-libs-jhbuild'), '--' + platform]) |
| process.wait() |
| if process.returncode != 0: |
| raise Exception('jhbuild configure failed with return code: %i' % process.returncode) |
| |
| |
| def determine_platform(): |
| if '--efl' in sys.argv: |
| return "efl"; |
| if '--gtk' in sys.argv: |
| return "gtk"; |
| raise ValueError('No platform specified for jhbuild-wrapper.') |
| |
| |
| def ensure_jhbuild(): |
| if not jhbuild_cloned(): |
| clone_jhbuild() |
| update_jhbuild() |
| install_jhbuild() |
| update_webkit_libs_jhbuild() |
| elif not jhbuild_installed() \ |
| or not jhbuild_at_expected_revision(): |
| update_jhbuild() |
| install_jhbuild() |
| |
| # Work-around the fact that we may get called from inside the jhbuild environment |
| # which will cause problems if we just cleaned the jhbuild install root |
| if os.environ.has_key('UNDER_JHBUILD'): |
| del os.environ['ACLOCAL_FLAGS'] |
| |
| try: |
| platform = determine_platform() |
| except ValueError as e: |
| sys.exit(e) |
| ensure_jhbuild() |
| |
| process = subprocess.Popen([jhbuild_path, '--no-interact', '-f', top_level_path('Tools', platform, 'jhbuildrc')] + sys.argv[2:]) |
| process.wait() |
| sys.exit(process.returncode) |