2 # Copyright (C) 2011 Igalia S.L.
3 # Copyright (C) 2012 Gustavo Noronha Silva <gns@gnome.org>
4 # Copyright (C) 2012 Intel Corporation
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2 of the License, or (at your option) any later version.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
28 def top_level_path(*args):
31 top_level_dir = os.path.join(os.path.dirname(__file__), '..', '..')
32 return os.path.join(*(top_level_dir,) + args)
35 jhbuild_revision = '1eedc423f75c605224b430579e4c303292199507'
37 installation_prefix = os.path.abspath(top_level_path('WebKitBuild', 'Dependencies', 'Root'))
38 source_path = os.path.abspath(top_level_path('WebKitBuild', 'Dependencies', 'Source'))
39 jhbuild_source_path = os.path.join(source_path, 'jhbuild')
40 jhbuild_path = top_level_path('WebKitBuild', 'Dependencies', 'Root', 'bin', 'jhbuild')
44 def jhbuild_installed():
45 return os.path.exists(jhbuild_path)
49 return os.path.exists(jhbuild_source_path)
52 def jhbuild_at_expected_revision():
53 process = subprocess.Popen(['git', 'rev-list', 'HEAD^..'], cwd=jhbuild_source_path,
54 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
55 output, err = process.communicate()
56 if process.returncode != 0:
57 raise Exception('failed to find jhbuild revision: %s' % err)
59 return output.strip() == jhbuild_revision
63 process = subprocess.Popen(['git', 'remote', 'update', 'origin'], cwd=jhbuild_source_path)
65 if process.returncode != 0:
66 raise Exception('jhbuild remote update origin failed with return code: %i' % process.returncode)
68 process = subprocess.Popen(['git', 'checkout', '%s' % jhbuild_revision],
69 cwd=jhbuild_source_path)
71 if process.returncode != 0:
72 raise Exception('failed to checkout treeish %s: %i' % (jhbuild_revision, process.returncode))
76 if not os.path.exists(source_path):
77 os.makedirs(source_path)
78 if not os.path.exists(installation_prefix):
79 os.makedirs(installation_prefix)
81 process = subprocess.Popen(['git', 'clone', 'git://git.gnome.org/jhbuild'], cwd=source_path)
83 if process.returncode != 0:
84 raise Exception('jhbuild git clone failed with return code: %i' % process.returncode)
87 def install_jhbuild():
88 # jhbuild is really unhappy about having MAKE defined to something like 'make -j4'
89 # so we just undefine it here.
90 env_without_make = dict(os.environ)
91 if 'MAKE' in env_without_make:
92 del env_without_make['MAKE']
94 process = subprocess.Popen(['bash', './autogen.sh', '--prefix=%s' % installation_prefix],
95 cwd=jhbuild_source_path, env=env_without_make)
97 if process.returncode != 0:
98 raise Exception('jhbuild configure failed with return code: %i' % process.returncode)
100 process = subprocess.Popen(['make', 'install'], cwd=jhbuild_source_path, env=env_without_make)
102 if process.returncode != 0:
103 raise Exception('jhbuild configure failed with return code: %i' % process.returncode)
106 def update_webkit_libs_jhbuild():
107 process = subprocess.Popen([top_level_path('Tools', 'Scripts', 'update-webkit-libs-jhbuild'), '--' + platform])
109 if process.returncode != 0:
110 raise Exception('jhbuild configure failed with return code: %i' % process.returncode)
113 def determine_platform():
114 if '--efl' in sys.argv:
116 if '--gtk' in sys.argv:
118 raise ValueError('No platform specified for jhbuild-wrapper.')
121 def ensure_jhbuild():
122 if not jhbuild_cloned():
126 update_webkit_libs_jhbuild()
127 elif not jhbuild_installed() \
128 or not jhbuild_at_expected_revision():
133 platform = determine_platform()
134 except ValueError as e:
138 process = subprocess.Popen([jhbuild_path, '--no-interact', '-f', top_level_path('Tools', platform, 'jhbuildrc'), 'run'] + sys.argv[2:])
140 sys.exit(process.returncode)