Commit c5a19a25 authored by Pierre Rossi's avatar Pierre Rossi Committed by Simon Hausmann
Browse files

Ease the switching between Debug and Release builds

Change the semantics of getOutDir, introduce getConfigDir.
Rely on Gyp's configurations mechanism to get a sensible
path for the BLINQ_PROCESS_PATH in both cases.
Also make the build smarter in that re-generation of gyp files
will lead to re-gyping.
Showing with 47 additions and 12 deletions
...@@ -21,8 +21,8 @@ This is a prototype of allowing embedding Chromium/Blink into Qt. ...@@ -21,8 +21,8 @@ This is a prototype of allowing embedding Chromium/Blink into Qt.
* set the CHROMIUM_SRC_DIR environment variable to point to /path/to/src/ * set the CHROMIUM_SRC_DIR environment variable to point to /path/to/src/
* Simply run qmake in the top-level directory (it will call ninja behind the scenes). * Simply run qmake in the top-level directory (it will call ninja behind the scenes).
Use qmake -r to forcefully re-gyp (without relying on make to determine if it's necessary). Use qmake -r to forcefully re-gyp (without relying on make to determine if it's necessary).
* switching between a debug and a release build can still be a bit cumbersome, for now it seems: * Release or debug builds can be obtained by running 'make release' or 'make debug' in the
rm **/Makefile && qmake -r CONFIG+=<debug or release> depending on what's needed should work well top level directory (only lib and process for now, and not so smart with dependencies)
(4) build with make ;) (4) build with make ;)
......
...@@ -9,3 +9,14 @@ SUBDIRS = lib \ ...@@ -9,3 +9,14 @@ SUBDIRS = lib \
build \ # This is where we use the generated qt_generated.gypi and run gyp build \ # This is where we use the generated qt_generated.gypi and run gyp
example \ example \
# Extra targets that invoke ninja on the desired configuration added for convenience
release.target = release
release.commands = $$CHROMIUM_SRC_DIR/../depot_tools/ninja -C $$getOutDir()/Release
release.depends: qmake
debug.target = debug
debug.commands = $$CHROMIUM_SRC_DIR/../depot_tools/ninja -C $$getOutDir()/Debug
debug.depends: qmake
QMAKE_EXTRA_TARGETS += release \
debug
...@@ -4,16 +4,12 @@ ...@@ -4,16 +4,12 @@
TEMPLATE = aux 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...) message(Running Gyp...)
GYP_OUTPUT = $$system(./gyp_blinq) GYP_OUTPUT = $$system(./gyp_blinq)
message($$GYP_OUTPUT) message($$GYP_OUTPUT)
ninja.target = ninja ninja.target = ninja
ninja.commands = $$CHROMIUM_SRC_DIR/../depot_tools/ninja -C $$getOutDir() ninja.commands = $$CHROMIUM_SRC_DIR/../depot_tools/ninja -C $$getOutDir()/$$getConfigDir()
ninja.depends: qmake ninja.depends: qmake
QMAKE_EXTRA_TARGETS += ninja QMAKE_EXTRA_TARGETS += ninja
......
...@@ -3,6 +3,10 @@ BLINQ_ROOT = $$replace(PWD, /build/qmake/mkspecs/features$,) ...@@ -3,6 +3,10 @@ BLINQ_ROOT = $$replace(PWD, /build/qmake/mkspecs/features$,)
BLINQ_PROCESS_NAME = blinq_process BLINQ_PROCESS_NAME = blinq_process
# Fetched from environment for now
CHROMIUM_SRC_DIR = $$(CHROMIUM_SRC_DIR)
isEmpty(CHROMIUM_SRC_DIR):error("please set CHOMIUM_SRC_DIR")
load(functions) load(functions)
# So that moc generated files don't end up polluting the source tree # So that moc generated files don't end up polluting the source tree
OUT_PWD = $$getOutDir() OUT_PWD = $$getOutDir()
...@@ -9,8 +9,13 @@ defineReplace(toGypTargetType) { ...@@ -9,8 +9,13 @@ defineReplace(toGypTargetType) {
} }
defineReplace(getOutDir) { defineReplace(getOutDir) {
CONFIG(release, debug|release):return("$$BLINQ_ROOT/out/Release") # FIXME: rely on env variable in here and in the gyp_blinq script, à la WEBKITOUTPUTDIR
return("$$BLINQ_ROOT/out/Debug") return("$$BLINQ_ROOT/out")
}
defineReplace(getConfigDir) {
CONFIG(release, debug|release):return("Release")
return("Debug")
} }
defineReplace(findMocables) { defineReplace(findMocables) {
......
...@@ -55,6 +55,20 @@ GYPI_CONTENTS += " ]," ...@@ -55,6 +55,20 @@ GYPI_CONTENTS += " ],"
for (define, DEFINES): GYPI_CONTENTS += " '$$define'," for (define, DEFINES): GYPI_CONTENTS += " '$$define',"
GYPI_CONTENTS += " ]," GYPI_CONTENTS += " ],"
} }
!isEmpty(PER_CONFIG_DEFINES) {
GYPI_CONTENTS += " 'configurations': {"\
" 'Release': {" \
" 'defines': ["
for (define, PER_CONFIG_DEFINES): GYPI_CONTENTS += " '$$replace(define,%config,Release)',"
GYPI_CONTENTS += " ]," \
" }," \
" 'Debug': {" \
" 'defines': ["
for (define, PER_CONFIG_DEFINES): GYPI_CONTENTS += " '$$replace(define,%config,Debug)',"
GYPI_CONTENTS += " ]," \
" }," \
" },"
}
GYPI_CONTENTS += " 'sources': [" GYPI_CONTENTS += " 'sources': ["
for (sourcefile, SOURCES): GYPI_CONTENTS += " '$$sourcefile'," for (sourcefile, SOURCES): GYPI_CONTENTS += " '$$sourcefile',"
for (headerfile, HEADERS): GYPI_CONTENTS += " '$$headerfile'," for (headerfile, HEADERS): GYPI_CONTENTS += " '$$headerfile',"
...@@ -80,6 +94,9 @@ GYPI_CONTENTS += " }," \ ...@@ -80,6 +94,9 @@ GYPI_CONTENTS += " }," \
write_file($$GYPI_FILE, GYPI_CONTENTS) write_file($$GYPI_FILE, GYPI_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 $$BLINQ_ROOT/build/build.pro")
# The generated Makefile shouldn't build anything by itself, just re-run qmake if necessary # The generated Makefile shouldn't build anything by itself, just re-run qmake if necessary
TEMPLATE = aux TEMPLATE = aux
SOURCES = SOURCES =
......
...@@ -5,7 +5,7 @@ SOURCES = main.cpp ...@@ -5,7 +5,7 @@ SOURCES = main.cpp
INCLUDEPATH += ../lib INCLUDEPATH += ../lib
LIBPATH = $$getOutDir()/lib LIBPATH = $$getOutDir()/$$getConfigDir()/lib
LIBS += -L$$LIBPATH -lblinq LIBS += -L$$LIBPATH -lblinq
QMAKE_RPATHDIR += $$LIBPATH QMAKE_RPATHDIR += $$LIBPATH
......
...@@ -8,8 +8,10 @@ TEMPLATE = lib ...@@ -8,8 +8,10 @@ TEMPLATE = lib
TARGET = blinq TARGET = blinq
# Defining keywords such as 'signal' clashes with the chromium code base. # Defining keywords such as 'signal' clashes with the chromium code base.
DEFINES += QT_NO_KEYWORDS \ DEFINES += QT_NO_KEYWORDS
BLINQ_PROCESS_PATH=\\\"$$getOutDir()/$$BLINQ_PROCESS_NAME\\\"
# We need a way to tap into gyp's Debug vs. Release configuration
PER_CONFIG_DEFINES = BLINQ_PROCESS_PATH=\\\"$$getOutDir()/%config/$$BLINQ_PROCESS_NAME\\\"
# Keep Skia happy # Keep Skia happy
CONFIG(release, debug|release): DEFINES += NDEBUG CONFIG(release, debug|release): DEFINES += NDEBUG
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment