diff options
author | Pierre Rossi <pierre.rossi@digia.com> | 2013-04-30 08:31:31 +0200 |
---|---|---|
committer | Pierre Rossi <pierre.rossi@digia.com> | 2013-05-02 20:02:21 +0200 |
commit | 259a919a30cbdf867d7e2fef9c7e0ecf7056661e (patch) | |
tree | 2a66215985536c4ff924f5873a329a9ea861c832 | |
parent | 0a07a8e761ba628095e3301b7d7b671b87e49a0f (diff) |
Define blinq_process path at compile time
This way we won't have to define the BLINQ_PROCESS_PATH environment variable
except in the case where we want to override that value.
Refactored some of the output dir logic in the process
-rw-r--r-- | build/build.pro | 4 | ||||
-rw-r--r-- | build/qmake/mkspecs/features/default_pre.prf | 4 | ||||
-rw-r--r-- | build/qmake/mkspecs/features/functions.prf | 5 | ||||
-rw-r--r-- | example/example.pro | 3 | ||||
-rw-r--r-- | lib/blinqpage.cpp | 25 | ||||
-rw-r--r-- | lib/lib.pro | 3 | ||||
-rw-r--r-- | process/process.pro | 2 |
7 files changed, 33 insertions, 13 deletions
diff --git a/build/build.pro b/build/build.pro index f869aee89..83c074d60 100644 --- a/build/build.pro +++ b/build/build.pro @@ -13,9 +13,7 @@ GYP_OUTPUT = $$system(./gyp_blinq) message($$GYP_OUTPUT) ninja.target = ninja -ninja.commands = $$CHROMIUM_SRC_DIR/../depot_tools/ninja -C -CONFIG(debug, debug|release): ninja.commands += $$BLINQ_ROOT/out/Debug -else: ninja.commands += $$BLINQ_ROOT/out/Release +ninja.commands = $$CHROMIUM_SRC_DIR/../depot_tools/ninja -C $$getOutDir() 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 c54908efd..aee53ea1d 100644 --- a/build/qmake/mkspecs/features/default_pre.prf +++ b/build/qmake/mkspecs/features/default_pre.prf @@ -1,4 +1,6 @@ # Resolve root directories for sources BLINQ_ROOT = $$replace(PWD, /build/qmake/mkspecs/features$,) -# TODO: Build dir logic +BLINQ_PROCESS_NAME = blinq_process + +load(functions) diff --git a/build/qmake/mkspecs/features/functions.prf b/build/qmake/mkspecs/features/functions.prf index 8d0df1a4e..3ac1ffa12 100644 --- a/build/qmake/mkspecs/features/functions.prf +++ b/build/qmake/mkspecs/features/functions.prf @@ -7,3 +7,8 @@ defineReplace(toGypTargetType) { } return("none") } + +defineReplace(getOutDir) { + CONFIG(release, debug|release):return("$$BLINQ_ROOT/out/Release") + return("$$BLINQ_ROOT/out/Debug") +} diff --git a/example/example.pro b/example/example.pro index e126adff7..a12bd856f 100644 --- a/example/example.pro +++ b/example/example.pro @@ -5,8 +5,7 @@ SOURCES = main.cpp INCLUDEPATH += ../lib -CONFIG(debug, debug|release): LIBPATH = ../out/Debug/lib -else: LIBPATH = ../out/Release/lib +LIBPATH = $$getOutDir() LIBS += -L$$LIBPATH -lblinq QMAKE_RPATHDIR += $$LIBPATH diff --git a/lib/blinqpage.cpp b/lib/blinqpage.cpp index dc2cbea18..41aa649ff 100644 --- a/lib/blinqpage.cpp +++ b/lib/blinqpage.cpp @@ -75,16 +75,31 @@ static inline base::FilePath::StringType qStringToStringType(const QString &str) #endif } +static QByteArray blinqProcessPath() { + static bool initialized = false; +#ifdef BLINQ_PROCESS_PATH + static QByteArray processPath(BLINQ_PROCESS_PATH); +#else + static QByteArray processPath; +#endif + if (initialized) + return processPath; + // Allow overriding at runtime for the time being. + const QByteArray fromEnv = qgetenv("BLINQ_PROCESS_PATH"); + if (!fromEnv.isEmpty()) + processPath = fromEnv; + if (processPath.isEmpty()) + qFatal("BLINQ_PROCESS_PATH environment variable not set or empty."); + initialized = true; +} + static void initializeBlinkPaths() { static bool initialized = false; if (initialized) return; - QByteArray processPath = qgetenv("BLINQ_PROCESS_PATH"); - if (processPath.isEmpty()) - qFatal("BLINQ_PROCESS_PATH environment variable not set or empty."); - PathService::Override(content::CHILD_PROCESS_EXE, base::FilePath(qStringToStringType(QString(processPath)))); + PathService::Override(content::CHILD_PROCESS_EXE, base::FilePath(qStringToStringType(QString(blinqProcessPath())))); } class Context : public content::BrowserContext @@ -486,7 +501,7 @@ BlinqPage::BlinqPage(int argc, char **argv) for (int i = 0; i < argc; ++i) myArgv[i] = argv[i]; QByteArray subProcessPathOption("--browser-subprocess-path="); - subProcessPathOption.append(qgetenv("BLINQ_PROCESS_PATH")); + subProcessPathOption.append(blinqProcessPath()); myArgv[argc] = subProcessPathOption.constData(); myArgv[argc + 1] = "--no-sandbox"; diff --git a/lib/lib.pro b/lib/lib.pro index e2c4ce505..0d117f354 100644 --- a/lib/lib.pro +++ b/lib/lib.pro @@ -8,7 +8,8 @@ TEMPLATE = lib TARGET = blinq # 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\\\" QT += gui-private widgets diff --git a/process/process.pro b/process/process.pro index efb517a5f..b1b6a2611 100644 --- a/process/process.pro +++ b/process/process.pro @@ -3,7 +3,7 @@ # our gypi_gen.prf feature to the CONFIG variable since it is processed backwards CONFIG = gypi_gen $$CONFIG -TARGET = blinq_process +TARGET = $$BLINQ_PROCESS_NAME TEMPLATE = app QT -= gui core |