From fd61d752e313bf91a09c85020b3fb50067c610c8 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Tue, 19 Nov 2013 17:55:49 +0100 Subject: Moving sources to src part 1: Move files. This only move files without adjusting any paths. This moves: - lib/quick -> src/webengine/api (API files) lib/quick -> src/webengine (other files) This contains the main QtWebEngine module library since . - lib/widgets -> src/webenginewidgets Also rename this directory to match its module name and rename Api to api. - lib -> src/core - process -> src/process - resources -> src/core/resources - tools/* -> tools/scripts/ The build directory is spread as follow: - build/build.pro -> src/core/gyp_run.pro - build/qmake_extras/* -> src/core/ (for the host and target .pro files) - build/qmake -> tools/qmake - Build related scripts -> tools/buildscripts Change-Id: I0cded1de772c99c0c1da6536c9afea353236b4a1 Reviewed-by: Zeno Albisser Reviewed-by: Pierre Rossi Reviewed-by: Andras Becsi --- tools/buildscripts/build_resources.py | 103 +++++++++ tools/buildscripts/find-included-moc-files | 13 ++ tools/buildscripts/find-mocables | 26 +++ tools/buildscripts/gyp_qtwebengine | 167 ++++++++++++++ tools/git_submodule.py | 255 ---------------------- tools/qmake/mkspecs/features/default_pre.prf | 29 +++ tools/qmake/mkspecs/features/functions.prf | 109 +++++++++ tools/qmake/mkspecs/features/gyp_generator.prf | 208 ++++++++++++++++++ tools/qmake/mkspecs/features/mac/default_post.prf | 2 + tools/scripts/git_submodule.py | 255 ++++++++++++++++++++++ tools/scripts/take_snapshot.py | 189 ++++++++++++++++ tools/take_snapshot.py | 189 ---------------- 12 files changed, 1101 insertions(+), 444 deletions(-) create mode 100755 tools/buildscripts/build_resources.py create mode 100755 tools/buildscripts/find-included-moc-files create mode 100755 tools/buildscripts/find-mocables create mode 100755 tools/buildscripts/gyp_qtwebengine delete mode 100644 tools/git_submodule.py create mode 100644 tools/qmake/mkspecs/features/default_pre.prf create mode 100644 tools/qmake/mkspecs/features/functions.prf create mode 100644 tools/qmake/mkspecs/features/gyp_generator.prf create mode 100644 tools/qmake/mkspecs/features/mac/default_post.prf create mode 100644 tools/scripts/git_submodule.py create mode 100755 tools/scripts/take_snapshot.py delete mode 100755 tools/take_snapshot.py (limited to 'tools') diff --git a/tools/buildscripts/build_resources.py b/tools/buildscripts/build_resources.py new file mode 100755 index 000000000..7b20aa9ad --- /dev/null +++ b/tools/buildscripts/build_resources.py @@ -0,0 +1,103 @@ +#!/usr/bin/env python + +############################################################################# +# +# Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +# Contact: http://www.qt-project.org/legal +# +# This file is part of the QtWebEngine module of the Qt Toolkit. +# +# $QT_BEGIN_LICENSE:LGPL$ +# Commercial License Usage +# Licensees holding valid commercial Qt licenses may use this file in +# accordance with the commercial license agreement provided with the +# Software or, alternatively, in accordance with the terms contained in +# a written agreement between you and Digia. For licensing terms and +# conditions see http://qt.digia.com/licensing. For further information +# use the contact form at http://qt.digia.com/contact-us. +# +# GNU Lesser General Public License Usage +# Alternatively, this file may be used under the terms of the GNU Lesser +# General Public License version 2.1 as published by the Free Software +# Foundation and appearing in the file LICENSE.LGPL included in the +# packaging of this file. Please review the following information to +# ensure the GNU Lesser General Public License version 2.1 requirements +# will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +# +# In addition, as a special exception, Digia gives you certain additional +# rights. These rights are described in the Digia Qt LGPL Exception +# version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +# +# GNU General Public License Usage +# Alternatively, this file may be used under the terms of the GNU +# General Public License version 3.0 as published by the Free Software +# Foundation and appearing in the file LICENSE.GPL included in the +# packaging of this file. Please review the following information to +# ensure the GNU General Public License version 3.0 requirements will be +# met: http://www.gnu.org/copyleft/gpl.html. +# +# +# $QT_END_LICENSE$ +# +############################################################################# + +import glob +import os +import subprocess +import sys +import string +import time + +qtwebengine_src = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..")) + + +chrome_src = subprocess.check_output("git config qtwebengine.chromiumsrcdir || true", shell=True).strip() +if chrome_src: + chrome_src = os.path.join(qtwebengine_src, chrome_src) +if not chrome_src or not os.path.isdir(chrome_src): + chrome_src = os.path.join(qtwebengine_src, '3rdparty/chromium') + print 'CHROMIUM_SRC_DIR not set, falling back to ' + chrome_src + +grit_tool = os.path.join(chrome_src, 'tools/grit/grit.py') +resources_subdir = os.path.join(qtwebengine_src, 'resources') + +def checkNeedForRebuild(grd_file): + grit_files = subprocess.check_output(['python', grit_tool, '-i', grd_file, 'buildinfo']).splitlines() + + dependencies = [grd_file] + data_packages = [] + for line in grit_files: + if line.startswith('input|'): + dependencies.append(line.split('|')[1]) + if line.startswith('data_package|'): + data_packages.append(line.split('|')[1]) + + target_timestamp = 0 + for data_package in data_packages: + data_package_file = os.path.join(resources_subdir, data_package) + if not os.path.isfile(data_package_file): + return True + + data_package_timestamp = os.path.getmtime(data_package_file) + if data_package_timestamp < target_timestamp or target_timestamp == 0: + target_timestamp = data_package_timestamp + + for dependency in dependencies: + dependency_timestamp = os.path.getmtime(dependency) + if (dependency_timestamp > target_timestamp): + return True + return False + +def rebuildPakFile(grd_file): + print 'Rebuilding resource file for:' + grd_file + resource_ids_file = os.path.join(chrome_src, 'tools/gritsettings/resource_ids') + subprocess.call(['python', grit_tool, '-i', grd_file, 'build', '-f', resource_ids_file, '-o', resources_subdir]) + +def rebuildIfNeeded(grd_file): + grd_file = os.path.join(chrome_src, grd_file) + if checkNeedForRebuild(grd_file): + rebuildPakFile(grd_file) + + +# The grd_file is specified relative to the chromium source directory. +rebuildIfNeeded('net/base/net_resources.grd') diff --git a/tools/buildscripts/find-included-moc-files b/tools/buildscripts/find-included-moc-files new file mode 100755 index 000000000..e55f3824c --- /dev/null +++ b/tools/buildscripts/find-included-moc-files @@ -0,0 +1,13 @@ +#!/usr/bin/env python + +import re, sys, os + +includedMocs = set() +for f in filter(os.path.isfile, sys.argv[1:]): + inBlockComment = False + for line in open(f).readlines(): + m = re.search('#include "(moc_\w+.cpp)"', line) + if m: + includedMocs.add(m.group(1)) +for moc in includedMocs: + print moc diff --git a/tools/buildscripts/find-mocables b/tools/buildscripts/find-mocables new file mode 100755 index 000000000..7c383cfec --- /dev/null +++ b/tools/buildscripts/find-mocables @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +import re, sys, os + +mocables = set() +for f in filter(os.path.isfile, sys.argv[1:]): + inBlockComment = False + for line in open(f).readlines(): + # Block comments handling + if "/*" in line: + inBlockComment = True + if inBlockComment and "*/" in line: + inBlockComment = False + if line.find("*/") != len(line) - 3: + line = line[line.find("*/")+2:] + else: + continue + if inBlockComment: + continue + #simple comments handling + if "//" in line: + line = line.partition("//")[0] + if re.match(".*Q_OBJECT", line): + mocables.add(f) +for mocable in mocables: + print mocable diff --git a/tools/buildscripts/gyp_qtwebengine b/tools/buildscripts/gyp_qtwebengine new file mode 100755 index 000000000..e715cb821 --- /dev/null +++ b/tools/buildscripts/gyp_qtwebengine @@ -0,0 +1,167 @@ +#!/usr/bin/env python + +import glob +import os +import subprocess +import sys + +print 'using python: ' + sys.executable + ' version: ' + sys.version + +qtwebengine_src = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) +chrome_src = subprocess.check_output("git config qtwebengine.chromiumsrcdir || true", shell=True).strip() +if chrome_src: + chrome_src = os.path.join(qtwebengine_src, chrome_src) +if not chrome_src or not os.path.isdir(chrome_src): + chrome_src = os.path.join(qtwebengine_src, '3rdparty/chromium') + print 'CHROMIUM_SRC_DIR not set, falling back to ' + chrome_src + +script_dir = os.path.abspath(os.path.join(chrome_src, 'build')) +if not os.path.isdir(script_dir): + print script_dir + " is not a valid directory" + sys.exit(1) +root_dir = os.path.abspath(os.path.join(os.getcwd(), os.pardir)) + +sys.path.insert(0, script_dir) +import gyp_helper +sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) +import gyp + +# Add paths so that pymod_do_main(...) can import files. +sys.path.insert(1, os.path.join(chrome_src, 'tools', 'grit')) +sys.path.insert(1, os.path.join(chrome_src, 'tools', 'generate_shim_headers')) + +sys.path.insert(1, os.path.join(chrome_src, 'third_party', 'WebKit', + 'Source', 'core', 'core.gyp', 'scripts')) +# Remove the above and keep the line below once we require a newer specific +# Chromium revision. +sys.path.insert(1, os.path.join(chrome_src, 'third_party', 'WebKit', + 'Source', 'core', 'scripts')) + +sys.path.insert(1, os.path.join(chrome_src, 'chrome', 'tools', 'build')) + +import repack_locales + +def additional_include_files(args=[]): + """ + Returns a list of additional (.gypi) files to include, without + duplicating ones that are already specified on the command line. + """ + # Determine the include files specified on the command line. + # This doesn't cover all the different option formats you can use, + # but it's mainly intended to avoid duplicating flags on the automatic + # makefile regeneration which only uses this format. + specified_includes = set() + for arg in args: + if arg.startswith('-I') and len(arg) > 2: + specified_includes.add(os.path.realpath(arg[2:])) + + result = [] + def AddInclude(path): + if os.path.realpath(path) not in specified_includes: + result.append(path) + + # Always include common.gypi. + AddInclude(os.path.join(script_dir, 'common.gypi')) + + # Used for additional build tweaks such as file exclusions + AddInclude(os.path.join(qtwebengine_src, 'build', 'qtwebengine_extras.gypi')) + + # Common stuff we generate and extract from qmake + AddInclude(os.path.join(qtwebengine_src, 'build', 'qmake_extras.gypi')) + + # Optionally add supplemental .gypi files if present. + supplements = glob.glob(os.path.join(chrome_src, '*', 'supplement.gypi')) + for supplement in supplements: + AddInclude(supplement) + + return result + +# TODO: later we probably want to hook that up with qmake to allow shadow builds. (Might not play nice with the rest of chromium though) +def get_output_dir(): + outdir = os.path.join(root_dir, "out") # Hardcode for now + if not os.path.isdir(outdir): + os.mkdir(outdir) + + return outdir + +if __name__ == '__main__': + args = sys.argv[1:] + + # On Mac we want to override CXX and CC that is provided with + # the Chromium GYP environment. + if sys.platform.startswith('darwin') and not 'GYP_CROSSCOMPILE' in os.environ: + os.environ['CXX'] = 'clang++' + os.environ['CC'] = 'clang' + + gyp_helper.apply_chromium_gyp_env() + + # This could give false positives since it doesn't actually do real option + # parsing. Oh well. + gyp_file_specified = False + for arg in args: + if arg.endswith('.gyp'): + gyp_file_specified = True + break + + if not gyp_file_specified: + args.append(os.path.join(root_dir, 'qtwebengine.gyp')) + + args.extend(['-I' + i for i in additional_include_files(args)]) + + # On Mac we want to build in x64 mode. And we want to use libc++. + # Even though we are not on linux, it seems we specifically have to disable linux_use_tcmalloc. + if sys.platform in ('darwin',) and not 'GYP_CROSSCOMPILE' in os.environ: + args.extend(['-D', 'host_arch=x64', '-D', 'use_libcpp=1', '-D', 'linux_use_tcmalloc=0']) + + # There shouldn't be a circular dependency relationship between .gyp files, + # but in Chromium's .gyp files, on non-Mac platforms, circular relationships + # currently exist. The check for circular dependencies is currently + # bypassed on other platforms, but is left enabled on the Mac, where a + # violation of the rule causes Xcode to misbehave badly. + # TODO(mark): Find and kill remaining circular dependencies, and remove this + # option. http://crbug.com/35878. + # TODO(tc): Fix circular dependencies in ChromiumOS then add linux2 to the + # list. + if sys.platform not in ('darwin',): + args.append('--no-circular-check') + + args.extend(['-D', 'webkit_src_dir=' + chrome_src + '/third_party/WebKit']) + # the top_level source directory is the first common ancestor of our module and the chromium source tree for the build to be sane. + # commonprefix works on a character basis, so it might return a phony common prefix (not the common parent directory we expect), + toplevel= os.path.commonprefix([root_dir, chrome_src]) + if not os.path.exists(toplevel): + toplevel = os.path.join(toplevel, os.pardir) + args.extend(["--toplevel-dir=" + toplevel]) + # Chromium specific Hack: for Chromium to build, the depth has to be set to the chromium src dir. + args.extend(["--depth=" + chrome_src]) + args.extend(['-D', 'qtwebengine_src_dir=' + qtwebengine_src]) + args.extend(['-D', 'chromium_src_dir=' + chrome_src]) + + if 'qt_cross_compile=1' in sys.argv: + os.environ['GYP_CROSSCOMPILE'] = '1' + + # linux_use_gold_binary currently relies on a hardcoded relative path from chromium/src/out/(Release|Debug) + # Disable it along with the -Wl,--threads flag just in case gold isn't installed on the system. + args.extend(['-D', 'linux_use_gold_binary=0']) + args.extend(['-D', 'linux_use_gold_flags=0']) + # Trigger Qt-specific build conditions. + args.extend(['-D', 'use_qt=1']) + # Tweak the output location and format (hardcode ninja for now if not set) + args.extend(['--generator-output', os.path.abspath(get_output_dir())]) + args.extend(['-Goutput_dir='+ os.path.abspath(get_output_dir())]) + if not os.environ.get('GYP_GENERATORS'): + args.extend(['--format=ninja']) + if "QTWEBENGINE_GYP_DEBUG" in os.environ: + args.append("--check") + args.append("-d all") + print args + ret_code = gyp.main(args) + sys.exit(ret_code) + + ################################### + + print 'Updating projects from gyp files...' + #sys.stdout.flush() + + # Off we go... + sys.exit(gyp.main(args)) diff --git a/tools/git_submodule.py b/tools/git_submodule.py deleted file mode 100644 index 084bd2b1f..000000000 --- a/tools/git_submodule.py +++ /dev/null @@ -1,255 +0,0 @@ -############################################################################# -# -# Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -# Contact: http://www.qt-project.org/legal -# -# This file is part of the QtWebEngine module of the Qt Toolkit. -# -# $QT_BEGIN_LICENSE:LGPL$ -# Commercial License Usage -# Licensees holding valid commercial Qt licenses may use this file in -# accordance with the commercial license agreement provided with the -# Software or, alternatively, in accordance with the terms contained in -# a written agreement between you and Digia. For licensing terms and -# conditions see http://qt.digia.com/licensing. For further information -# use the contact form at http://qt.digia.com/contact-us. -# -# GNU Lesser General Public License Usage -# Alternatively, this file may be used under the terms of the GNU Lesser -# General Public License version 2.1 as published by the Free Software -# Foundation and appearing in the file LICENSE.LGPL included in the -# packaging of this file. Please review the following information to -# ensure the GNU Lesser General Public License version 2.1 requirements -# will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -# -# In addition, as a special exception, Digia gives you certain additional -# rights. These rights are described in the Digia Qt LGPL Exception -# version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -# -# GNU General Public License Usage -# Alternatively, this file may be used under the terms of the GNU -# General Public License version 3.0 as published by the Free Software -# Foundation and appearing in the file LICENSE.GPL included in the -# packaging of this file. Please review the following information to -# ensure the GNU General Public License version 3.0 requirements will be -# met: http://www.gnu.org/copyleft/gpl.html. -# -# -# $QT_END_LICENSE$ -# -############################################################################# - -import glob -import os -import subprocess -import sys - -extra_os = [] - -def subprocessCall(args): - print args - return subprocess.call(args) - -def subprocessCheckOutput(args): - print args - return subprocess.check_output(args) - -class DEPSParser: - def __init__(self): - self.global_scope = { - 'Var': self.Lookup, - 'deps_os': {}, - } - self.local_scope = {} - - def Lookup(self, var_name): - return self.local_scope["vars"][var_name] - - def createSubmodulesFromScope(self, scope, os): - submodules = [] - for dep in scope: - if (type(scope[dep]) == str): - repo_rev = scope[dep].split('@') - repo = repo_rev[0] - rev = repo_rev[1] - subdir = dep - if subdir.startswith('src/'): - subdir = subdir[4:] - submodule = Submodule(subdir, repo, rev, os) - submodule.deps = True - submodules.append(submodule) - return submodules - - def sanityCheckModules(self, submodules): - subdirectories = [] - for submodule in submodules: - if submodule.path in subdirectories: - print 'SUBMODULE WARNING: duplicate for submodule' + submodule.path - subdirectories.append(submodule.path) - - def parseFile(self, deps_file_name): - currentDir = os.getcwd() - if not os.path.isfile(deps_file_name): - return [] - deps_file = open(deps_file_name) - deps_content = deps_file.read().decode('utf-8') - deps_file.close() - exec(deps_content, self.global_scope, self.local_scope) - - submodules = [] - submodules.extend(self.createSubmodulesFromScope(self.local_scope['deps'], 'all')) - for os_dep in self.local_scope['deps_os']: - submodules.extend(self.createSubmodulesFromScope(self.local_scope['deps_os'][os_dep], os_dep)) - - self.sanityCheckModules(submodules) - - return submodules - - - -class Submodule: - def __init__(self, path='', url='', shasum='', os=[], ref=''): - self.path = path - self.url = url - self.shasum = shasum - self.os = os - self.ref = '' - self.deps = False - - def matchesOS(self): - if not self.os: - return True - if 'all' in self.os: - return True - if sys.platform.startswith('win32') and 'win' in self.os: - return True - if sys.platform.startswith('linux') and 'unix' in self.os: - return True - if sys.platform.startswith('darwin') and ('unix' in self.os or 'mac' in self.os): - return True - for os in extra_os: - if os in self.os: - return True - return False - - def findSha(self): - if self.shasum != '': - return - line = subprocessCheckOutput(['git', 'submodule', 'status', self.path]) - line = line.lstrip(' -') - self.shasum = line.split(' ')[0] - - def findGitDir(self): - try: - return subprocessCheckOutput(['git', 'rev-parse', '--git-dir']).strip() - except subprocess.CalledProcessError, e: - sys.exit("git dir could not be determined! - Initialization failed!" + e.output) - - def reset(self): - currentDir = os.getcwd() - os.chdir(self.path) - gitdir = self.findGitDir() - if os.path.isdir(os.path.join(gitdir, 'rebase-merge')): - if os.path.isfile(os.path.join(gitdir, 'MERGE_HEAD')): - print 'merge in progress... aborting merge.' - subprocessCall(['git', 'merge', '--abort']) - else: - print 'rebase in progress... aborting merge.' - subprocessCall(['git', 'rebase', '--abort']) - if os.path.isdir(os.path.join(gitdir, 'rebase-apply')): - print 'am in progress... aborting am.' - subprocessCall(['git', 'am', '--abort']) - subprocessCall(['git', 'reset', '--hard']) - os.chdir(currentDir) - - def initialize(self): - if self.matchesOS(): - print '-- initializing ' + self.path + ' --' - if os.path.isdir(self.path): - self.reset() - if self.deps: - subprocessCall(['git', 'submodule', 'add', '-f', self.url, self.path]) - subprocessCall(['git', 'submodule', 'init', self.path]) - subprocessCall(['git', 'submodule', 'update', self.path]) - self.findSha() - currentDir = os.getcwd() - os.chdir(self.path) - # Make sure we have checked out the right shasum. - # In case there were other patches applied before. - if self.ref: - val = subprocessCall(['git', 'fetch', 'origin', self.ref]); - if val != 0: - sys.exit("Could not fetch branch from upstream.") - subprocessCall(['git', 'checkout', 'FETCH_HEAD']); - else: - val = subprocessCall(['git', 'checkout', self.shasum]) - if val != 0: - sys.exit("!!! initialization failed !!!") - self.initSubmodules() - os.chdir(currentDir) - else: - print '-- skipping ' + self.path + ' for this operating system. --' - - def listFiles(self): - if self.matchesOS(): - currentDir = os.getcwd() - os.chdir(self.path) - files = subprocessCheckOutput(['git', 'ls-files']).splitlines() - os.chdir(currentDir) - return files - else: - print '-- skipping ' + self.path + ' for this operating system. --' - return [] - - - def readSubmodules(self): - if not os.path.isfile('.gitmodules'): - return [] - gitmodules_file = open('.gitmodules') - gitmodules_lines = gitmodules_file.readlines() - gitmodules_file.close() - - submodules = [] - currentSubmodule = None - for line in gitmodules_lines: - if line.find('[submodule') == 0: - if currentSubmodule: - submodules.append(currentSubmodule) - currentSubmodule = Submodule() - tokens = line.split('=') - if len(tokens) >= 2: - key = tokens[0].strip() - value = tokens[1].strip() - if key == 'path': - currentSubmodule.path = value - elif key == 'url': - currentSubmodule.url = value - elif key == 'os': - currentSubmodule.os = value.split(',') - if currentSubmodule: - submodules.append(currentSubmodule) - return submodules - - def readDeps(self): - parser = DEPSParser() - return parser.parseFile('.DEPS.git') - - def initSubmodules(self): - # try reading submodules from .gitmodules. - submodules = self.readSubmodules() - for submodule in submodules: - submodule.initialize() - if submodules: - return - # if we could not find any submodules in .gitmodules, try .DEPS.git - submodules = self.readDeps() - - if not submodules: - return - - print 'DEPS file provides the following submodules:' - for submodule in submodules: - print '{:<80}'.format(submodule.path) + '{:<120}'.format(submodule.url) + submodule.shasum - for submodule in submodules: - submodule.initialize() - subprocessCall(['git', 'commit', '-a', '-m', '"initialize submodules"']) diff --git a/tools/qmake/mkspecs/features/default_pre.prf b/tools/qmake/mkspecs/features/default_pre.prf new file mode 100644 index 000000000..1e751b740 --- /dev/null +++ b/tools/qmake/mkspecs/features/default_pre.prf @@ -0,0 +1,29 @@ +# Resolve root directories for sources +QTWEBENGINE_ROOT = $$replace(PWD, /build/qmake/mkspecs/features$,) + +QTWEBENGINEPROCESS_NAME = QtWebEngineProcess + +git_chromium_src_dir = $$system("git config qtwebengine.chromiumsrcdir") + +# Fall back to the snapshot path if git does not know about chromium sources (i.e. init-repository.py has not been used) +isEmpty(git_chromium_src_dir): git_chromium_src_dir = "3rdparty/chromium" + +CHROMIUM_SRC_DIR = $$absolute_path("$$QTWEBENGINE_ROOT/$$git_chromium_src_dir") + +INCLUDEPATH += $$CHROMIUM_SRC_DIR + +# Tweaks that shouldn't affect our examples +!contains(_PRO_FILE_PWD_, $$QTWEBENGINE_ROOT/examples) { + # Used for our export macros + DEFINES += BUILDING_CHROMIUM + # We have to disable RTTI for now since that's how chromium builds on linux + unix:QMAKE_CXXFLAGS += -fno-rtti +} +# Location of sync.profile +MODULE_BASE_DIR = $$QTWEBENGINE_ROOT + + +load(functions) + +# Call the original default_pre. +load(default_pre) diff --git a/tools/qmake/mkspecs/features/functions.prf b/tools/qmake/mkspecs/features/functions.prf new file mode 100644 index 000000000..9d90d67bd --- /dev/null +++ b/tools/qmake/mkspecs/features/functions.prf @@ -0,0 +1,109 @@ +# Map to the correct target type for gyp +defineReplace(toGypTargetType) { + equals(TEMPLATE, "app"):return("executable") + equals(TEMPLATE, "lib") { + CONFIG(static): return("static_library") + return("shared_library") + } + return("none") +} + +defineReplace(getOutDir) { + # FIXME: rely on env variable in here and in the gyp_qtwebengine script, à la WEBKITOUTPUTDIR + return("$$QTWEBENGINE_ROOT/out") +} + +defineReplace(getConfigDir) { + CONFIG(release, debug|release):return("Release") + return("Debug") +} + +defineReplace(extractCFlag) { + OPTION = $$find(QMAKE_CFLAGS, $$1) + OPTION = $$split(OPTION, =) + return ($$member(OPTION, 1)) +} + +defineReplace(findMocables) { + input = $$1 + for (file, input): \ + infiles += $$absolute_path($$file, $$_PRO_FILE_PWD_) + mocables = $$system("python $$QTWEBENGINE_ROOT/build/scripts/find-mocables $$infiles") + mocables = $$replace(mocables, $$_PRO_FILE_PWD_$${QMAKE_DIR_SEP}, '') + return($$mocables) +} + +defineReplace(findIncludedMocFiles) { + input = $$1 + for (file, input): \ + infiles += $$absolute_path($$file, $$_PRO_FILE_PWD_) + return($$system("python $$QTWEBENGINE_ROOT/build/scripts/find-included-moc-files $$infiles")) +} + +defineReplace(mocOutput) { + out = $$1 + # The order is important, since the output of the second replace would end up accidentaly transformed by the first one + out = $$replace(out, ^(.*)($$join(QMAKE_EXT_CPP,|)), $${QMAKE_CPP_MOD_MOC}\\1$${QMAKE_EXT_CPP_MOC}) + out = $$replace(out, ^(.*)($$join(QMAKE_EXT_H,|)), $${QMAKE_H_MOD_MOC}\\1$${first(QMAKE_EXT_CPP)}) + return($$out) +} + +defineReplace(rccOutput) { + out = $$1 + out = $$replace(out, .qrc, .cpp) + out = $$join(out, qrc_, qrc_) + return($$out) +} + +defineReplace(rccExternFunc) { + out = $$1 + out = $$replace(out, .qrc, ) + return($$out) +} + +defineReplace(which) { + out = $$1 + win32 { + command = $$split(out, " ") + executable = $$first(command) + # Return the first match only + out = $$system("((for /f \"usebackq delims=\" %i in (`where $$executable 2^> NUL`) do @if not defined _endwhich (@echo %i & set _endwhich=true)) & set _endwhich=)") + isEmpty(out) { + message($$executable not found) + out = $$executable + } + for(arg, command): !equals(arg, $$executable): out += $$arg + } else:unix { + command = $$split(out, " ") + executable = $$first(command) + out = $$system("which $$executable 2>/dev/null") + isEmpty(out) { + message($$executable not found) + out = $$executable + } + for(arg, command): !equals(arg, $$executable): out += $$arg + } + return($$out) +} + +defineReplace(findOrBuildNinja) { + !isEmpty(CACHED_NINJA_EXECUTABLE):exists($$CACHED_NINJA_EXECUTABLE): return($$CACHED_NINJA_EXECUTABLE) + out = $$which(ninja) + # Try to be smart about it if we know where the chromium sources are located + !exists($$out) { + git_chromium_src_dir = $$system("git config qtwebengine.chromiumsrcdir") + # Fall back to the snapshot path if git does not know about chromium sources (i.e. init-repository.py has not been used) + isEmpty(git_chromium_src_dir): git_chromium_src_dir = "3rdparty/chromium" + win32: out = $$system_path($$absolute_path("$$QTWEBENGINE_ROOT/$$git_chromium_src_dir/../ninja/ninja.exe")) + else: out = $$absolute_path("$$QTWEBENGINE_ROOT/$$git_chromium_src_dir/../ninja/ninja") + # If we still did not find ninja, then we bootstrap it. + !exists($$out) { + message("bootstrapping ninja...") + ninjadir = $$dirname(out) + system("python $$ninjadir/bootstrap.py") + } + } + message("using $$out") + cache(CACHED_NINJA_EXECUTABLE, set, out) + return($$out) +} diff --git a/tools/qmake/mkspecs/features/gyp_generator.prf b/tools/qmake/mkspecs/features/gyp_generator.prf new file mode 100644 index 000000000..d15b864c9 --- /dev/null +++ b/tools/qmake/mkspecs/features/gyp_generator.prf @@ -0,0 +1,208 @@ +# This file is loaded after the dummy .pro and all the default_post ran. +# This is the right point to extract the variables we're interested in and generate +# the .gyp file that we'll use later on when running gyp + +load(functions) +load(moc) +load(resources) + +defineReplace(mocAction) { + INPUT_FILE = $$1 + OUTPUT_NAME = $$mocOutput($$INPUT_FILE) + DEFINES_LIST = $$join(DEFINES, " -D", -D) + INCPATH = $$join(INCLUDEPATH, " -I", -I) + MOC_COMMAND = $$mocCmdBase() + MOC_COMMAND = $$replace(MOC_COMMAND, $$re_escape("$(DEFINES)"), $$DEFINES_LIST) + MOC_COMMAND = $$replace(MOC_COMMAND, $$re_escape("$(INCPATH)"), $$INCPATH) + MOC_COMMAND = $$split(MOC_COMMAND, " ") + OUTPUT_FILE = $$absolute_path($$MOC_DIR, $$OUT_PWD)$${QMAKE_DIR_SEP}$${OUTPUT_NAME} + contents = " {" \ + " 'action_name':'$$OUTPUT_NAME'," \ + " 'inputs': ['$$INPUT_FILE',]," \ + " 'outputs': ['$$OUTPUT_FILE',]," \ + " 'action': [" + for(token, MOC_COMMAND): contents += " '$$token'," + contents += " '$$INPUT_FILE'," \ + " '-o'," \ + " '$$OUTPUT_FILE'," \ + " ]," \ + " }," + + return($$contents) +} + +defineReplace(rccAction) { + win32-*: QMAKE_RCC ~= s,\\\\,/,g + INPUT_FILE = $$1 + OUTPUT_NAME = $$rccOutput($$INPUT_FILE) + EXTERN_FUNC = $$rccExternFunc($$INPUT_FILE) + OUTPUT_FILE = $$absolute_path($$RCC_DIR, $$OUT_PWD)$${QMAKE_DIR_SEP}$${OUTPUT_NAME} + contents = " {" \ + " 'action_name':'$$OUTPUT_NAME'," \ + " 'inputs': ['$$INPUT_FILE',]," \ + " 'outputs': ['$$OUTPUT_FILE',]," \ + " 'action': [" \ + " '$$QMAKE_RCC'," + for(resource_flag, $$QMAKE_RESOURCE_FLAGS): contents += " '$$resource_flag'," + contents += " '-name'," \ + " '$$EXTERN_FUNC'," \ + " '$$INPUT_FILE'," \ + " '-o'," \ + " '$$OUTPUT_FILE'," + contents += " ]," \ + " }," + + return($$contents) +} + +GYPI_FILE = $$replace(_PRO_FILE_, .pro$, .gyp) + +TARGET_TYPE = $$toGypTargetType() +MOCABLE_HEADERS = $$findMocables($$HEADERS) +INCLUDED_MOC_FILES = $$findIncludedMocFiles($$SOURCES) + +GYP_CONTENTS = "{" \ + " 'targets': [" \ + " {" \ + " 'target_name': '$$TARGET'," \ + " 'type': '$$TARGET_TYPE'," +!isEmpty(GYPINCLUDES) { +GYP_CONTENTS += " 'includes': [" +for (incl, GYPINCLUDES): GYP_CONTENTS += " '$$incl'," +GYP_CONTENTS += " ]," +} + +# Split LIBS into linker flags and actual libraries, and add them to the +# appropriate section (ldflags vs link_settings: libraries) in the gyp file. +LIBRARIES = $$find(LIBS, "-l") +LIBRARIES = $$unique(LIBRARIES) +for (library, LIBRARIES): LIBS -= "$$library" + +GYP_CONTENTS += " 'ldflags': [" +for (lib, LIBS): GYP_CONTENTS += " '$$lib'," +for (rpath, QMAKE_RPATHDIR): GYP_CONTENTS += " '$$QMAKE_RPATH$$rpath'," +GYP_CONTENTS += " ]," + +!isEmpty(QMAKE_CFLAGS) { + GYP_CONTENTS += " 'cflags': [" + for(flag, QMAKE_CFLAGS): GYP_CONTENTS += " '$$flag'," + GYP_CONTENTS += " ]," +} +!isEmpty(QMAKE_CXXFLAGS) { + GYP_CONTENTS += " 'cflags_cc': [" + for(flag, QMAKE_CXXFLAGS): GYP_CONTENTS += " '$$flag'," + GYP_CONTENTS += " ]," +} +GYP_CONTENTS += " 'link_settings': {" \ + " 'libraries': [" +for (library, LIBRARIES): GYP_CONTENTS += " '$$library'," +macx { + FRAMEWORKS = $$find(LIBS, "Q*") + FRAMEWORKS = $$unique(FRAMEWORKS) + FRAMEWORKS ~= s/-.*/ + FRAMEWORKS -= "-framework" + for (framework, FRAMEWORKS): { + framework_name = $$join(framework, "", "", ".framework") + GYP_CONTENTS += " '$$framework_name'," + } + + FRAMEWORK_PATHS = $$find(LIBS, "-F*") + FRAMEWORK_PATHS = $$unique(FRAMEWORK_PATHS) + FRAMEWORK_PATHS -= "-framework" + for (framework_path, FRAMEWORK_PATHS): GYP_CONTENTS += " '$$framework_path'," + !isEmpty(QMAKE_FRAMEWORKPATH): GYP_CONTENTS += " '-F$$QMAKE_FRAMEWORKPATH'," +} +GYP_CONTENTS += " ]," \ + " }," + +!isEmpty(GYPDEPENDENCIES) { + GYP_CONTENTS += " 'dependencies': [" + for (dep, GYPDEPENDENCIES): GYP_CONTENTS += " '$$dep'," + GYP_CONTENTS += " ]," +} +!isEmpty(DEFINES) { + GYP_CONTENTS += " 'defines': [" + for (define, DEFINES): GYP_CONTENTS += " '$$define'," + GYP_CONTENTS += " ]," +} +!isEmpty(PER_CONFIG_DEFINES) { + GYP_CONTENTS += " 'configurations': {"\ + " 'Release': {" \ + " 'defines': [" + for (define, PER_CONFIG_DEFINES): GYP_CONTENTS += " '$$replace(define,%config,Release)'," + GYP_CONTENTS += " ]," \ + " }," \ + " 'Debug': {" \ + " 'defines': [" + for (define, PER_CONFIG_DEFINES): GYP_CONTENTS += " '$$replace(define,%config,Debug)'," + GYP_CONTENTS += " ]," \ + " }," \ + " }," +} +!isEmpty(GYP_DYLIB_INSTALL_NAME_BASE) { + GYP_CONTENTS += " 'xcode_settings': {" \ + " 'DYLIB_INSTALL_NAME_BASE': '$$GYP_DYLIB_INSTALL_NAME_BASE'," \ + " }," +} + +# Source files to compile +GYP_CONTENTS += " 'sources': [" +for (sourcefile, SOURCES): GYP_CONTENTS += " '$$sourcefile'," +for (headerfile, HEADERS): GYP_CONTENTS += " '$$headerfile'," + +# Add Sources generated by rcc from qrc files. +for (resourcefile, RESOURCES) { + RCC_CPP = $$replace(resourcefile, .qrc, .cpp) + RCC_CPP = $$join(RCC_CPP, "qrc_", qrc_) + RCC_CPP = $$absolute_path($$RCC_DIR, $$OUT_PWD)$${QMAKE_DIR_SEP}$${RCC_CPP} + GYP_CONTENTS += " '$$RCC_CPP'," +} + +# Add moc output files to compile that aren't included at the end of any other source +MOC_OUT_PATH = $$absolute_path($$MOC_DIR, $$OUT_PWD)$${QMAKE_DIR_SEP} +for (mocable_header, MOCABLE_HEADERS) { + !contains(INCLUDED_MOC_FILES, $$mocOutput($$mocable_header)) { + GYP_CONTENTS += " '$$MOC_OUT_PATH$$mocOutput($$mocable_header)'," + } +} + +GYP_CONTENTS += " ]," +!isEmpty(INCLUDEPATH) { + GYP_CONTENTS += " 'include_dirs': [" + for (path, INCLUDEPATH): GYP_CONTENTS += " '$$path'," + GYP_CONTENTS += " ]," +} + +# Some needed files (like devtools_resources.pak) are both _generated_ as part of the build process and are _needed_ as part of the build process. +!isEmpty(COPY_FILES) { + GYP_CONTENTS += " 'copies': [" + for (index, 0..$$size(COPY_FILES)) { + copyFile = $$member(COPY_FILES, $$index) + !isEmpty(copyFile) { + copyDestination = $$member(COPY_DESTINATIONS, $$index) + GYP_CONTENTS += " {'destination': '$$copyDestination', 'files': ['$$copyFile']}," + } + } + GYP_CONTENTS += " ]," +} + +# Generate the actions for moc, copy +GYP_CONTENTS += " 'actions': [" +for(resourcefile, RESOURCES): GYP_CONTENTS += $$rccAction($$resourcefile) +for(header, MOCABLE_HEADERS): GYP_CONTENTS += $$mocAction($$header) +GYP_CONTENTS += " ]," \ + " }," + +GYP_CONTENTS += " ]," \ + "}" + +!build_pass: write_file($$GYPI_FILE, GYP_CONTENTS) + +# Overwriting the generated gyp file seems like a good reason to re-gyp +unix: phony_variable_name_for_qmake_to_be_happy=$$system("touch $$QTWEBENGINE_ROOT/build/build.pro") + +# The generated Makefile shouldn't build anything by itself, just re-run qmake if necessary +TEMPLATE = aux +SOURCES = +HEADERS = +RESOURCES = diff --git a/tools/qmake/mkspecs/features/mac/default_post.prf b/tools/qmake/mkspecs/features/mac/default_post.prf new file mode 100644 index 000000000..2b9fed81b --- /dev/null +++ b/tools/qmake/mkspecs/features/mac/default_post.prf @@ -0,0 +1,2 @@ +CONFIG -= build_all +load(default_post) diff --git a/tools/scripts/git_submodule.py b/tools/scripts/git_submodule.py new file mode 100644 index 000000000..084bd2b1f --- /dev/null +++ b/tools/scripts/git_submodule.py @@ -0,0 +1,255 @@ +############################################################################# +# +# Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +# Contact: http://www.qt-project.org/legal +# +# This file is part of the QtWebEngine module of the Qt Toolkit. +# +# $QT_BEGIN_LICENSE:LGPL$ +# Commercial License Usage +# Licensees holding valid commercial Qt licenses may use this file in +# accordance with the commercial license agreement provided with the +# Software or, alternatively, in accordance with the terms contained in +# a written agreement between you and Digia. For licensing terms and +# conditions see http://qt.digia.com/licensing. For further information +# use the contact form at http://qt.digia.com/contact-us. +# +# GNU Lesser General Public License Usage +# Alternatively, this file may be used under the terms of the GNU Lesser +# General Public License version 2.1 as published by the Free Software +# Foundation and appearing in the file LICENSE.LGPL included in the +# packaging of this file. Please review the following information to +# ensure the GNU Lesser General Public License version 2.1 requirements +# will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +# +# In addition, as a special exception, Digia gives you certain additional +# rights. These rights are described in the Digia Qt LGPL Exception +# version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +# +# GNU General Public License Usage +# Alternatively, this file may be used under the terms of the GNU +# General Public License version 3.0 as published by the Free Software +# Foundation and appearing in the file LICENSE.GPL included in the +# packaging of this file. Please review the following information to +# ensure the GNU General Public License version 3.0 requirements will be +# met: http://www.gnu.org/copyleft/gpl.html. +# +# +# $QT_END_LICENSE$ +# +############################################################################# + +import glob +import os +import subprocess +import sys + +extra_os = [] + +def subprocessCall(args): + print args + return subprocess.call(args) + +def subprocessCheckOutput(args): + print args + return subprocess.check_output(args) + +class DEPSParser: + def __init__(self): + self.global_scope = { + 'Var': self.Lookup, + 'deps_os': {}, + } + self.local_scope = {} + + def Lookup(self, var_name): + return self.local_scope["vars"][var_name] + + def createSubmodulesFromScope(self, scope, os): + submodules = [] + for dep in scope: + if (type(scope[dep]) == str): + repo_rev = scope[dep].split('@') + repo = repo_rev[0] + rev = repo_rev[1] + subdir = dep + if subdir.startswith('src/'): + subdir = subdir[4:] + submodule = Submodule(subdir, repo, rev, os) + submodule.deps = True + submodules.append(submodule) + return submodules + + def sanityCheckModules(self, submodules): + subdirectories = [] + for submodule in submodules: + if submodule.path in subdirectories: + print 'SUBMODULE WARNING: duplicate for submodule' + submodule.path + subdirectories.append(submodule.path) + + def parseFile(self, deps_file_name): + currentDir = os.getcwd() + if not os.path.isfile(deps_file_name): + return [] + deps_file = open(deps_file_name) + deps_content = deps_file.read().decode('utf-8') + deps_file.close() + exec(deps_content, self.global_scope, self.local_scope) + + submodules = [] + submodules.extend(self.createSubmodulesFromScope(self.local_scope['deps'], 'all')) + for os_dep in self.local_scope['deps_os']: + submodules.extend(self.createSubmodulesFromScope(self.local_scope['deps_os'][os_dep], os_dep)) + + self.sanityCheckModules(submodules) + + return submodules + + + +class Submodule: + def __init__(self, path='', url='', shasum='', os=[], ref=''): + self.path = path + self.url = url + self.shasum = shasum + self.os = os + self.ref = '' + self.deps = False + + def matchesOS(self): + if not self.os: + return True + if 'all' in self.os: + return True + if sys.platform.startswith('win32') and 'win' in self.os: + return True + if sys.platform.startswith('linux') and 'unix' in self.os: + return True + if sys.platform.startswith('darwin') and ('unix' in self.os or 'mac' in self.os): + return True + for os in extra_os: + if os in self.os: + return True + return False + + def findSha(self): + if self.shasum != '': + return + line = subprocessCheckOutput(['git', 'submodule', 'status', self.path]) + line = line.lstrip(' -') + self.shasum = line.split(' ')[0] + + def findGitDir(self): + try: + return subprocessCheckOutput(['git', 'rev-parse', '--git-dir']).strip() + except subprocess.CalledProcessError, e: + sys.exit("git dir could not be determined! - Initialization failed!" + e.output) + + def reset(self): + currentDir = os.getcwd() + os.chdir(self.path) + gitdir = self.findGitDir() + if os.path.isdir(os.path.join(gitdir, 'rebase-merge')): + if os.path.isfile(os.path.join(gitdir, 'MERGE_HEAD')): + print 'merge in progress... aborting merge.' + subprocessCall(['git', 'merge', '--abort']) + else: + print 'rebase in progress... aborting merge.' + subprocessCall(['git', 'rebase', '--abort']) + if os.path.isdir(os.path.join(gitdir, 'rebase-apply')): + print 'am in progress... aborting am.' + subprocessCall(['git', 'am', '--abort']) + subprocessCall(['git', 'reset', '--hard']) + os.chdir(currentDir) + + def initialize(self): + if self.matchesOS(): + print '-- initializing ' + self.path + ' --' + if os.path.isdir(self.path): + self.reset() + if self.deps: + subprocessCall(['git', 'submodule', 'add', '-f', self.url, self.path]) + subprocessCall(['git', 'submodule', 'init', self.path]) + subprocessCall(['git', 'submodule', 'update', self.path]) + self.findSha() + currentDir = os.getcwd() + os.chdir(self.path) + # Make sure we have checked out the right shasum. + # In case there were other patches applied before. + if self.ref: + val = subprocessCall(['git', 'fetch', 'origin', self.ref]); + if val != 0: + sys.exit("Could not fetch branch from upstream.") + subprocessCall(['git', 'checkout', 'FETCH_HEAD']); + else: + val = subprocessCall(['git', 'checkout', self.shasum]) + if val != 0: + sys.exit("!!! initialization failed !!!") + self.initSubmodules() + os.chdir(currentDir) + else: + print '-- skipping ' + self.path + ' for this operating system. --' + + def listFiles(self): + if self.matchesOS(): + currentDir = os.getcwd() + os.chdir(self.path) + files = subprocessCheckOutput(['git', 'ls-files']).splitlines() + os.chdir(currentDir) + return files + else: + print '-- skipping ' + self.path + ' for this operating system. --' + return [] + + + def readSubmodules(self): + if not os.path.isfile('.gitmodules'): + return [] + gitmodules_file = open('.gitmodules') + gitmodules_lines = gitmodules_file.readlines() + gitmodules_file.close() + + submodules = [] + currentSubmodule = None + for line in gitmodules_lines: + if line.find('[submodule') == 0: + if currentSubmodule: + submodules.append(currentSubmodule) + currentSubmodule = Submodule() + tokens = line.split('=') + if len(tokens) >= 2: + key = tokens[0].strip() + value = tokens[1].strip() + if key == 'path': + currentSubmodule.path = value + elif key == 'url': + currentSubmodule.url = value + elif key == 'os': + currentSubmodule.os = value.split(',') + if currentSubmodule: + submodules.append(currentSubmodule) + return submodules + + def readDeps(self): + parser = DEPSParser() + return parser.parseFile('.DEPS.git') + + def initSubmodules(self): + # try reading submodules from .gitmodules. + submodules = self.readSubmodules() + for submodule in submodules: + submodule.initialize() + if submodules: + return + # if we could not find any submodules in .gitmodules, try .DEPS.git + submodules = self.readDeps() + + if not submodules: + return + + print 'DEPS file provides the following submodules:' + for submodule in submodules: + print '{:<80}'.format(submodule.path) + '{:<120}'.format(submodule.url) + submodule.shasum + for submodule in submodules: + submodule.initialize() + subprocessCall(['git', 'commit', '-a', '-m', '"initialize submodules"']) diff --git a/tools/scripts/take_snapshot.py b/tools/scripts/take_snapshot.py new file mode 100755 index 000000000..1a6976902 --- /dev/null +++ b/tools/scripts/take_snapshot.py @@ -0,0 +1,189 @@ +#!/usr/bin/env python + +############################################################################# +# +# Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +# Contact: http://www.qt-project.org/legal +# +# This file is part of the QtWebEngine module of the Qt Toolkit. +# +# $QT_BEGIN_LICENSE:LGPL$ +# Commercial License Usage +# Licensees holding valid commercial Qt licenses may use this file in +# accordance with the commercial license agreement provided with the +# Software or, alternatively, in accordance with the terms contained in +# a written agreement between you and Digia. For licensing terms and +# conditions see http://qt.digia.com/licensing. For further information +# use the contact form at http://qt.digia.com/contact-us. +# +# GNU Lesser General Public License Usage +# Alternatively, this file may be used under the terms of the GNU Lesser +# General Public License version 2.1 as published by the Free Software +# Foundation and appearing in the file LICENSE.LGPL included in the +# packaging of this file. Please review the following information to +# ensure the GNU Lesser General Public License version 2.1 requirements +# will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +# +# In addition, as a special exception, Digia gives you certain additional +# rights. These rights are described in the Digia Qt LGPL Exception +# version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +# +# GNU General Public License Usage +# Alternatively, this file may be used under the terms of the GNU +# General Public License version 3.0 as published by the Free Software +# Foundation and appearing in the file LICENSE.GPL included in the +# packaging of this file. Please review the following information to +# ensure the GNU General Public License version 3.0 requirements will be +# met: http://www.gnu.org/copyleft/gpl.html. +# +# +# $QT_END_LICENSE$ +# +############################################################################# + +import glob +import os +import subprocess +import sys +import imp +import errno +import shutil + +import git_submodule as GitSubmodule + +qtwebengine_src = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) +os.chdir(qtwebengine_src) + +def isInGitBlacklist(file_path): + # We do need all the gyp files. + if file_path.endswith('.gyp') or file_path.endswith('.gypi'): + False + if ( '.gitignore' in file_path + or '.gitmodules' in file_path + or '.DEPS' in file_path ): + return True + +def isInChromiumBlacklist(file_path): + # Filter out empty submodule directories. + if (os.path.isdir(file_path)): + return True + # We do need all the gyp files. + if file_path.endswith('.gyp') or file_path.endswith('.gypi'): + return False + if ( '/tests/' in file_path + or ('/test/' in file_path and + not '/webrtc/test/testsupport/' in file_path and + not file_path.startswith('net/test/') and + not file_path.endswith('mock_chrome_application_mac.h')) + or file_path.startswith('third_party/WebKit/LayoutTests') + or file_path.startswith('third_party/WebKit/PerformanceTests') + or file_path.startswith('third_party/WebKit/ManualTests') + or file_path.startswith('android_webview') + or file_path.startswith('apps/') + or file_path.startswith('build/android/') + or (file_path.startswith('chrome/') and + not 'repack_locales' in file_path and + not file_path.endswith('version.py')) + or file_path.startswith('chrome_frame') + or file_path.startswith('chromeos') + or file_path.startswith('breakpad') + or file_path.startswith('third_party/GTM') + or file_path.startswith('third_party/chromite') + or file_path.startswith('third_party/webgl_conformance') + or file_path.startswith('third_party/hunspell_dictionaries') + or file_path.startswith('cloud_print') + or file_path.startswith('ios') + or file_path.startswith('google_update') + or file_path.startswith('courgette') + or file_path.startswith('native_client') + or (file_path.startswith('third_party/trace-viewer') and + not file_path.endswith('.template') and + not file_path.endswith('.html') and + not file_path.endswith('.js') and + not file_path.endswith('.css') and + not file_path.endswith('.png') and + not '/build/' in file_path) + or file_path.startswith('remoting') + or file_path.startswith('win8') ): + return True + return False + + +def createHardLinkForFile(src, dst): + src = os.path.abspath(src) + dst = os.path.abspath(dst) + dst_dir = os.path.dirname(dst) + + if not os.path.isdir(dst_dir): + os.makedirs(dst_dir) + + if os.path.exists(dst): + os.remove(dst) + + try: + os.link(src, dst) + except OSError as exception: + if exception.errno == errno.ENOENT: + print 'file does not exist:' + src + else: + raise + + +third_party_upstream = os.path.join(qtwebengine_src, '3rdparty_upstream') +third_party = os.path.join(qtwebengine_src, '3rdparty') + +def clearDirectory(directory): + currentDir = os.getcwd() + os.chdir(directory) + print 'clearing the directory:' + directory + for direntry in os.listdir(directory): + if not direntry == '.git': + print 'clearing:' + direntry + shutil.rmtree(direntry) + os.chdir(currentDir) + +def listFilesInCurrentRepository(): + currentRepo = GitSubmodule.Submodule(os.getcwd()) + files = subprocess.check_output(['git', 'ls-files']).splitlines() + submodules = currentRepo.readSubmodules() + for submodule in submodules: + submodule_files = submodule.listFiles() + for submodule_file in submodule_files: + files.append(os.path.join(submodule.path, submodule_file)) + return files + +def exportNinja(): + third_party_upstream_ninja = os.path.join(third_party_upstream, 'ninja') + third_party_ninja = os.path.join(third_party, 'ninja') + os.makedirs(third_party_ninja); + print 'exporting contents of:' + third_party_upstream_ninja + os.chdir(third_party_upstream_ninja) + files = listFilesInCurrentRepository() + print 'creating hardlinks in ' + third_party_ninja + for f in files: + if not isInGitBlacklist(f): + createHardLinkForFile(f, os.path.join(third_party_ninja, f)) + +def exportChromium(): + third_party_upstream_chromium = os.path.join(third_party_upstream, 'chromium') + third_party_chromium = os.path.join(third_party, 'chromium') + os.makedirs(third_party_chromium); + print 'exporting contents of:' + third_party_upstream_chromium + os.chdir(third_party_upstream_chromium) + files = listFilesInCurrentRepository() + # Add LASTCHANGE files which are not tracked by git. + files.append('build/util/LASTCHANGE') + files.append('build/util/LASTCHANGE.blink') + print 'creating hardlinks in ' + third_party_chromium + for f in files: + if not isInChromiumBlacklist(f) and not isInGitBlacklist(f): + createHardLinkForFile(f, os.path.join(third_party_chromium, f)) + + +clearDirectory(third_party) + +exportNinja() +exportChromium() + +print 'done.' + diff --git a/tools/take_snapshot.py b/tools/take_snapshot.py deleted file mode 100755 index 1a6976902..000000000 --- a/tools/take_snapshot.py +++ /dev/null @@ -1,189 +0,0 @@ -#!/usr/bin/env python - -############################################################################# -# -# Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -# Contact: http://www.qt-project.org/legal -# -# This file is part of the QtWebEngine module of the Qt Toolkit. -# -# $QT_BEGIN_LICENSE:LGPL$ -# Commercial License Usage -# Licensees holding valid commercial Qt licenses may use this file in -# accordance with the commercial license agreement provided with the -# Software or, alternatively, in accordance with the terms contained in -# a written agreement between you and Digia. For licensing terms and -# conditions see http://qt.digia.com/licensing. For further information -# use the contact form at http://qt.digia.com/contact-us. -# -# GNU Lesser General Public License Usage -# Alternatively, this file may be used under the terms of the GNU Lesser -# General Public License version 2.1 as published by the Free Software -# Foundation and appearing in the file LICENSE.LGPL included in the -# packaging of this file. Please review the following information to -# ensure the GNU Lesser General Public License version 2.1 requirements -# will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -# -# In addition, as a special exception, Digia gives you certain additional -# rights. These rights are described in the Digia Qt LGPL Exception -# version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -# -# GNU General Public License Usage -# Alternatively, this file may be used under the terms of the GNU -# General Public License version 3.0 as published by the Free Software -# Foundation and appearing in the file LICENSE.GPL included in the -# packaging of this file. Please review the following information to -# ensure the GNU General Public License version 3.0 requirements will be -# met: http://www.gnu.org/copyleft/gpl.html. -# -# -# $QT_END_LICENSE$ -# -############################################################################# - -import glob -import os -import subprocess -import sys -import imp -import errno -import shutil - -import git_submodule as GitSubmodule - -qtwebengine_src = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -os.chdir(qtwebengine_src) - -def isInGitBlacklist(file_path): - # We do need all the gyp files. - if file_path.endswith('.gyp') or file_path.endswith('.gypi'): - False - if ( '.gitignore' in file_path - or '.gitmodules' in file_path - or '.DEPS' in file_path ): - return True - -def isInChromiumBlacklist(file_path): - # Filter out empty submodule directories. - if (os.path.isdir(file_path)): - return True - # We do need all the gyp files. - if file_path.endswith('.gyp') or file_path.endswith('.gypi'): - return False - if ( '/tests/' in file_path - or ('/test/' in file_path and - not '/webrtc/test/testsupport/' in file_path and - not file_path.startswith('net/test/') and - not file_path.endswith('mock_chrome_application_mac.h')) - or file_path.startswith('third_party/WebKit/LayoutTests') - or file_path.startswith('third_party/WebKit/PerformanceTests') - or file_path.startswith('third_party/WebKit/ManualTests') - or file_path.startswith('android_webview') - or file_path.startswith('apps/') - or file_path.startswith('build/android/') - or (file_path.startswith('chrome/') and - not 'repack_locales' in file_path and - not file_path.endswith('version.py')) - or file_path.startswith('chrome_frame') - or file_path.startswith('chromeos') - or file_path.startswith('breakpad') - or file_path.startswith('third_party/GTM') - or file_path.startswith('third_party/chromite') - or file_path.startswith('third_party/webgl_conformance') - or file_path.startswith('third_party/hunspell_dictionaries') - or file_path.startswith('cloud_print') - or file_path.startswith('ios') - or file_path.startswith('google_update') - or file_path.startswith('courgette') - or file_path.startswith('native_client') - or (file_path.startswith('third_party/trace-viewer') and - not file_path.endswith('.template') and - not file_path.endswith('.html') and - not file_path.endswith('.js') and - not file_path.endswith('.css') and - not file_path.endswith('.png') and - not '/build/' in file_path) - or file_path.startswith('remoting') - or file_path.startswith('win8') ): - return True - return False - - -def createHardLinkForFile(src, dst): - src = os.path.abspath(src) - dst = os.path.abspath(dst) - dst_dir = os.path.dirname(dst) - - if not os.path.isdir(dst_dir): - os.makedirs(dst_dir) - - if os.path.exists(dst): - os.remove(dst) - - try: - os.link(src, dst) - except OSError as exception: - if exception.errno == errno.ENOENT: - print 'file does not exist:' + src - else: - raise - - -third_party_upstream = os.path.join(qtwebengine_src, '3rdparty_upstream') -third_party = os.path.join(qtwebengine_src, '3rdparty') - -def clearDirectory(directory): - currentDir = os.getcwd() - os.chdir(directory) - print 'clearing the directory:' + directory - for direntry in os.listdir(directory): - if not direntry == '.git': - print 'clearing:' + direntry - shutil.rmtree(direntry) - os.chdir(currentDir) - -def listFilesInCurrentRepository(): - currentRepo = GitSubmodule.Submodule(os.getcwd()) - files = subprocess.check_output(['git', 'ls-files']).splitlines() - submodules = currentRepo.readSubmodules() - for submodule in submodules: - submodule_files = submodule.listFiles() - for submodule_file in submodule_files: - files.append(os.path.join(submodule.path, submodule_file)) - return files - -def exportNinja(): - third_party_upstream_ninja = os.path.join(third_party_upstream, 'ninja') - third_party_ninja = os.path.join(third_party, 'ninja') - os.makedirs(third_party_ninja); - print 'exporting contents of:' + third_party_upstream_ninja - os.chdir(third_party_upstream_ninja) - files = listFilesInCurrentRepository() - print 'creating hardlinks in ' + third_party_ninja - for f in files: - if not isInGitBlacklist(f): - createHardLinkForFile(f, os.path.join(third_party_ninja, f)) - -def exportChromium(): - third_party_upstream_chromium = os.path.join(third_party_upstream, 'chromium') - third_party_chromium = os.path.join(third_party, 'chromium') - os.makedirs(third_party_chromium); - print 'exporting contents of:' + third_party_upstream_chromium - os.chdir(third_party_upstream_chromium) - files = listFilesInCurrentRepository() - # Add LASTCHANGE files which are not tracked by git. - files.append('build/util/LASTCHANGE') - files.append('build/util/LASTCHANGE.blink') - print 'creating hardlinks in ' + third_party_chromium - for f in files: - if not isInChromiumBlacklist(f) and not isInGitBlacklist(f): - createHardLinkForFile(f, os.path.join(third_party_chromium, f)) - - -clearDirectory(third_party) - -exportNinja() -exportChromium() - -print 'done.' - -- cgit v1.2.3