summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@digia.com>2013-04-19 11:07:15 +0200
committerPierre Rossi <pierre.rossi@digia.com>2013-04-29 14:05:05 +0200
commit3300873bba24594e4773d0e0a127d33a5a0f303c (patch)
treef780ce65de01b46635d08c0c5d61615ac6da9130 /build
parent5067310342ac2d2b7004ed7d036bda6e3015f7d7 (diff)
New qmake approach
This should allow us to have much better integration by generating the necessary gyp files directly from qmake. Mostly works for now, though we will most likely need to build the gyp generation as we go. * Out dir logic is still crap and needs to be (re)worked. * In the same vein, we probably don't want the generated gyp content ending up in the source tree in the long run, which could prove tricky with relative paths to sources and all.
Diffstat (limited to 'build')
-rw-r--r--build/build.pro25
-rwxr-xr-xbuild/gyp_blinq116
-rw-r--r--build/qmake/mkspecs/features/default_pre.prf4
-rw-r--r--build/qmake/mkspecs/features/functions.prf9
-rw-r--r--build/qmake/mkspecs/features/gypi_gen.prf48
5 files changed, 202 insertions, 0 deletions
diff --git a/build/build.pro b/build/build.pro
new file mode 100644
index 000000000..279823371
--- /dev/null
+++ b/build/build.pro
@@ -0,0 +1,25 @@
+# This .pro file serves a dual purpose:
+# 1) invoking gyp through the gyp_blinq script, which in turn makes use of the generated gypi include files
+# 2) produce a Makefile that will run ninja, and take care of actually building everything.
+
+TEMPLATE = aux
+
+# Fetched from environment for now
+CHROMIUM_SRC_DIR = $$(CHROMIUM_SRC_DIR)
+isEmpty(CHROMIUM_SRC_DIR):error("please set CHOMIUM_SRC_DIR")
+
+message(Running Gyp...)
+GYP_OUTPUT = $$system(./gyp_blinq)
+message($$GYP_OUTPUT)
+
+ninja.target = ninja
+# FIXME: Don't hardcode Release... might be tricky to get right if we also don't want to hardcode 'out'
+ninja.commands = $$CHROMIUM_SRC_DIR/../depot_tools/ninja -C $$BLINQ_ROOT/out/Release
+ninja.depends: qmake
+QMAKE_EXTRA_TARGETS += ninja
+
+build_pass:build_all:default_target.target = all
+else: default_target.target = first
+default_target.depends = ninja
+
+QMAKE_EXTRA_TARGETS += default_target
diff --git a/build/gyp_blinq b/build/gyp_blinq
new file mode 100755
index 000000000..b22e759b7
--- /dev/null
+++ b/build/gyp_blinq
@@ -0,0 +1,116 @@
+#!/usr/bin/env python
+
+import glob
+import os
+import subprocess
+import sys
+
+chrome_src = os.path.abspath(os.environ.get('CHROMIUM_SRC_DIR')) # null-checked in build.pro
+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, 'third_party', 'WebKit',
+ 'Source', 'WebCore', 'WebCore.gyp', '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'))
+
+ # 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:]
+
+ 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, 'blinq.gyp'))
+
+ args.extend(['-I' + i for i in additional_include_files(args)])
+
+ # 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', 'use_aura=1'])
+ args.extend(['-D', 'webkit_src_dir=' + chrome_src + '/third_party/WebKit'])
+ args.extend(["--depth=" + chrome_src])
+ args.extend(['-D', 'chromium_src_dir=' + chrome_src])
+ # Tweak the output location and format (hardcode ninja for now)
+ args.extend(['--generator-output', os.path.abspath(get_output_dir())])
+ args.extend(['-Goutput_dir='+ os.path.abspath(get_output_dir())])
+ args.extend(['--format=ninja'])
+ if "BLINQ_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/build/qmake/mkspecs/features/default_pre.prf b/build/qmake/mkspecs/features/default_pre.prf
new file mode 100644
index 000000000..c54908efd
--- /dev/null
+++ b/build/qmake/mkspecs/features/default_pre.prf
@@ -0,0 +1,4 @@
+# Resolve root directories for sources
+BLINQ_ROOT = $$replace(PWD, /build/qmake/mkspecs/features$,)
+
+# TODO: Build dir logic
diff --git a/build/qmake/mkspecs/features/functions.prf b/build/qmake/mkspecs/features/functions.prf
new file mode 100644
index 000000000..8d0df1a4e
--- /dev/null
+++ b/build/qmake/mkspecs/features/functions.prf
@@ -0,0 +1,9 @@
+# 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")
+}
diff --git a/build/qmake/mkspecs/features/gypi_gen.prf b/build/qmake/mkspecs/features/gypi_gen.prf
new file mode 100644
index 000000000..ee32c3661
--- /dev/null
+++ b/build/qmake/mkspecs/features/gypi_gen.prf
@@ -0,0 +1,48 @@
+# 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)
+
+GYPI_FILE = $$replace(_PRO_FILE_, .pro$, .gyp)
+
+TARGET_TYPE = $$toGypTargetType()
+
+GYPI_CONTENTS = "{" \
+ " 'targets': [" \
+ " {" \
+ " 'target_name': '$$TARGET'," \
+ " 'type': '$$TARGET_TYPE'," \
+ " 'includes': [" \
+ " '../blinq.gypi'," \
+ " ]," \
+ " 'ldflags': ["
+for (lib, LIBS): GYPI_CONTENTS += " '$$lib',"
+!isEmpty(QMAKE_RPATHDIR): GYPI_CONTENTS += " '$$QMAKE_RPATH$$QMAKE_RPATHDIR',"
+
+GYPI_CONTENTS += " ],"
+
+!isEmpty(DEFINES) {
+ GYPI_CONTENTS += " 'defines': ["
+ for (define, DEFINES): GYPI_CONTENTS += " '$$define',"
+ GYPI_CONTENTS += " ],"
+}
+GYPI_CONTENTS += " 'sources': ["
+for (sourcefile, SOURCES): GYPI_CONTENTS += " '$$sourcefile',"
+for (headerfile, HEADERS): GYPI_CONTENTS += " '$$headerfile',"
+GYPI_CONTENTS += " ],"
+!isEmpty(INCLUDEPATH) {
+ GYPI_CONTENTS += " 'include_dirs': ["
+ for (path, INCLUDEPATH): GYPI_CONTENTS += " '$$path',"
+ GYPI_CONTENTS += " ],"
+}
+GYPI_CONTENTS += " }," \
+ " ]," \
+ "}"
+
+write_file($$GYPI_FILE, GYPI_CONTENTS)
+
+# The generated Makefile shouldn't build anything by itself, just re-run qmake if necessary
+TEMPLATE = aux
+SOURCES =
+HEADERS =