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 +++++++++++++++++++++++++++++ 4 files changed, 309 insertions(+) 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 (limited to 'tools/buildscripts') 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)) -- cgit v1.2.3