Fixed sometimes focus ring is hidden when context menu is shown by longTap
[framework/web/webkit-efl.git] / Tools / jhbuild / jhbuild-wrapper
1 #!/usr/bin/env python
2 # Copyright (C) 2011 Igalia S.L.
3 # Copyright (C) 2012 Gustavo Noronha Silva <gns@gnome.org>
4 # Copyright (C) 2012 Intel Corporation
5 #
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.
10 #
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.
15 #
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
19
20 import os
21 import shlex
22 import subprocess
23 import sys
24
25
26 top_level_dir = None
27
28
29 def top_level_path(*args):
30     global top_level_dir
31     if not top_level_dir:
32         top_level_dir = os.path.join(os.path.dirname(__file__), '..', '..')
33     return os.path.join(*(top_level_dir,) + args)
34
35
36 jhbuild_revision = '1eedc423f75c605224b430579e4c303292199507'
37
38 if os.environ.has_key('WEBKITOUTPUTDIR'):
39     dependencies_path = os.path.abspath(os.path.join(os.environ['WEBKITOUTPUTDIR'], 'Dependencies'))
40 else:
41     dependencies_path = os.path.abspath(top_level_path('WebKitBuild', 'Dependencies'))
42
43 installation_prefix = os.path.abspath(os.path.join(dependencies_path, 'Root'))
44 source_path = os.path.abspath(os.path.join(dependencies_path, 'Source'))
45 jhbuild_source_path = os.path.join(source_path, 'jhbuild')
46 jhbuild_path = os.path.join(installation_prefix, 'bin', 'jhbuild')
47
48
49 platform = None;
50
51
52 def jhbuild_installed():
53     return os.path.exists(jhbuild_path)
54
55
56 def jhbuild_cloned():
57     return os.path.exists(jhbuild_source_path)
58
59
60 def jhbuild_at_expected_revision():
61     process = subprocess.Popen(['git', 'rev-list', 'HEAD^..'], cwd=jhbuild_source_path,
62                                stdout=subprocess.PIPE, stderr=subprocess.PIPE)
63     output, err = process.communicate()
64     if process.returncode != 0:
65         raise Exception('failed to find jhbuild revision: %s' % err)
66
67     return output.strip() == jhbuild_revision
68
69
70 def update_jhbuild():
71     process = subprocess.Popen(['git', 'remote', 'update', 'origin'], cwd=jhbuild_source_path)
72     process.wait()
73     if process.returncode != 0:
74         raise Exception('jhbuild remote update origin failed with return code: %i' % process.returncode)
75
76     process = subprocess.Popen(['git', 'checkout', '%s' % jhbuild_revision],
77                                cwd=jhbuild_source_path)
78     process.wait()
79     if process.returncode != 0:
80         raise Exception('failed to checkout treeish %s: %i' % (jhbuild_revision, process.returncode))
81
82
83 def clone_jhbuild():
84     if not os.path.exists(source_path):
85         os.makedirs(source_path)
86     if not os.path.exists(installation_prefix):
87         os.makedirs(installation_prefix)
88
89     process = subprocess.Popen(['git', 'clone', 'git://git.gnome.org/jhbuild'], cwd=source_path)
90     process.wait()
91     if process.returncode != 0:
92         raise Exception('jhbuild git clone failed with return code: %i' % process.returncode)
93
94
95 def install_jhbuild():
96     process = subprocess.Popen(['bash', './autogen.sh', '--prefix=%s' % installation_prefix], cwd=jhbuild_source_path)
97     process.wait()
98     if process.returncode != 0:
99         raise Exception('jhbuild configure failed with return code: %i' % process.returncode)
100
101     # This is a hackish approach to make the subprocess.Popen call even when people set
102     # MAKE to 'make -j3' instead of using the MAKEFLAGS environment variable.
103     make = shlex.split(os.environ.get('MAKE', 'make'))
104
105     process = subprocess.Popen(make + ['install'], cwd=jhbuild_source_path)
106     process.wait()
107     if process.returncode != 0:
108         raise Exception('jhbuild configure failed with return code: %i' % process.returncode)
109
110
111 def update_webkit_libs_jhbuild():
112     process = subprocess.Popen([top_level_path('Tools', 'Scripts', 'update-webkit-libs-jhbuild'), '--' + platform])
113     process.wait()
114     if process.returncode != 0:
115         raise Exception('jhbuild configure failed with return code: %i' % process.returncode)
116
117
118 def determine_platform():
119     if '--efl' in sys.argv:
120         return "efl";
121     if '--gtk' in sys.argv:
122         return "gtk";
123     raise ValueError('No platform specified for jhbuild-wrapper.')
124
125
126 def ensure_jhbuild():
127     if not jhbuild_cloned():
128         clone_jhbuild()
129         update_jhbuild()
130         install_jhbuild()
131         update_webkit_libs_jhbuild()
132     elif not jhbuild_installed() \
133             or not jhbuild_at_expected_revision():
134         update_jhbuild()
135         install_jhbuild()
136
137 # Work-around the fact that we may get called from inside the jhbuild environment
138 # which will cause problems if we just cleaned the jhbuild install root
139 if os.environ.has_key('UNDER_JHBUILD'):
140     del os.environ['ACLOCAL_FLAGS']
141
142 try:
143     platform = determine_platform()
144 except ValueError as e:
145     sys.exit(e)
146 ensure_jhbuild()
147
148 process = subprocess.Popen([jhbuild_path, '--no-interact', '-f', top_level_path('Tools', platform, 'jhbuildrc')] + sys.argv[2:])
149 process.wait()
150 sys.exit(process.returncode)