diff --git a/README.rst b/README.rst index 7f255880a358d945d11816098608a240573bcdd8..ce627e880ff017abde7a94817fa39a95d3359ac4 100644 --- a/README.rst +++ b/README.rst @@ -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/ * 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). - * switching between a debug and a release build can still be a bit cumbersome, for now it seems: - rm **/Makefile && qmake -r CONFIG+=<debug or release> depending on what's needed should work well + * Release or debug builds can be obtained by running 'make release' or 'make debug' in the + top level directory (only lib and process for now, and not so smart with dependencies) (4) build with make ;) diff --git a/blinq.pro b/blinq.pro index cf5b1f5cd1b0555a002d9f6c3acf31c10733efc0..a745302de290945fcea92e1edb334f82efe6942e 100644 --- a/blinq.pro +++ b/blinq.pro @@ -9,3 +9,14 @@ SUBDIRS = lib \ build \ # This is where we use the generated qt_generated.gypi and run gyp 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 diff --git a/build/build.pro b/build/build.pro index 83c074d60153d0df3667163e5ed783124a688e87..0c3c87ba33e619cd86debd1bcb22467c4b837350 100644 --- a/build/build.pro +++ b/build/build.pro @@ -4,16 +4,12 @@ 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 -ninja.commands = $$CHROMIUM_SRC_DIR/../depot_tools/ninja -C $$getOutDir() +ninja.commands = $$CHROMIUM_SRC_DIR/../depot_tools/ninja -C $$getOutDir()/$$getConfigDir() ninja.depends: qmake QMAKE_EXTRA_TARGETS += ninja diff --git a/build/qmake/mkspecs/features/default_pre.prf b/build/qmake/mkspecs/features/default_pre.prf index 6a2c6f7f518868bc581bb955caf81a97b1795649..6d70a06abc6221fa0a7d983a068650353be4ea04 100644 --- a/build/qmake/mkspecs/features/default_pre.prf +++ b/build/qmake/mkspecs/features/default_pre.prf @@ -3,6 +3,10 @@ BLINQ_ROOT = $$replace(PWD, /build/qmake/mkspecs/features$,) 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) # So that moc generated files don't end up polluting the source tree OUT_PWD = $$getOutDir() diff --git a/build/qmake/mkspecs/features/functions.prf b/build/qmake/mkspecs/features/functions.prf index 5064ec441cf1364eb46521d3efe0109cb9becad2..bb1e152a23cade9fbf1ec7bee3e728a3736e6721 100644 --- a/build/qmake/mkspecs/features/functions.prf +++ b/build/qmake/mkspecs/features/functions.prf @@ -9,8 +9,13 @@ defineReplace(toGypTargetType) { } defineReplace(getOutDir) { - CONFIG(release, debug|release):return("$$BLINQ_ROOT/out/Release") - return("$$BLINQ_ROOT/out/Debug") + # FIXME: rely on env variable in here and in the gyp_blinq script, Ã la WEBKITOUTPUTDIR + return("$$BLINQ_ROOT/out") +} + +defineReplace(getConfigDir) { + CONFIG(release, debug|release):return("Release") + return("Debug") } defineReplace(findMocables) { diff --git a/build/qmake/mkspecs/features/gyp_generator.prf b/build/qmake/mkspecs/features/gyp_generator.prf index 4d46f84ecad9a0ef6bdbf859ac3ac1c71fad328e..47aafd25810e81678aaed41c4b2f34f5f9d7c373 100644 --- a/build/qmake/mkspecs/features/gyp_generator.prf +++ b/build/qmake/mkspecs/features/gyp_generator.prf @@ -55,6 +55,20 @@ GYPI_CONTENTS += " ]," for (define, DEFINES): GYPI_CONTENTS += " '$$define'," 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': [" for (sourcefile, SOURCES): GYPI_CONTENTS += " '$$sourcefile'," for (headerfile, HEADERS): GYPI_CONTENTS += " '$$headerfile'," @@ -80,6 +94,9 @@ 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 TEMPLATE = aux SOURCES = diff --git a/example/example.pro b/example/example.pro index c727b06aa002f4db90216579755f9079a77add58..7c76bb9a767113aac039d579960cf1af60ae5137 100644 --- a/example/example.pro +++ b/example/example.pro @@ -5,7 +5,7 @@ SOURCES = main.cpp INCLUDEPATH += ../lib -LIBPATH = $$getOutDir()/lib +LIBPATH = $$getOutDir()/$$getConfigDir()/lib LIBS += -L$$LIBPATH -lblinq QMAKE_RPATHDIR += $$LIBPATH diff --git a/lib/lib.pro b/lib/lib.pro index fbd5bbb13124547d5b79849e07ff43c779f23e8b..48fe29fcd8bb4f062a9b97de91fcf1029b949977 100644 --- a/lib/lib.pro +++ b/lib/lib.pro @@ -8,8 +8,10 @@ TEMPLATE = lib TARGET = blinq # Defining keywords such as 'signal' clashes with the chromium code base. -DEFINES += QT_NO_KEYWORDS \ - BLINQ_PROCESS_PATH=\\\"$$getOutDir()/$$BLINQ_PROCESS_NAME\\\" +DEFINES += QT_NO_KEYWORDS + +# 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 CONFIG(release, debug|release): DEFINES += NDEBUG