diff options
Diffstat (limited to 'tools/qmake/mkspecs')
-rw-r--r-- | tools/qmake/mkspecs/features/default_pre.prf | 29 | ||||
-rw-r--r-- | tools/qmake/mkspecs/features/functions.prf | 109 | ||||
-rw-r--r-- | tools/qmake/mkspecs/features/gyp_generator.prf | 208 | ||||
-rw-r--r-- | tools/qmake/mkspecs/features/mac/default_post.prf | 2 |
4 files changed, 348 insertions, 0 deletions
diff --git a/tools/qmake/mkspecs/features/default_pre.prf b/tools/qmake/mkspecs/features/default_pre.prf new file mode 100644 index 000000000..1e751b740 --- /dev/null +++ b/tools/qmake/mkspecs/features/default_pre.prf @@ -0,0 +1,29 @@ +# Resolve root directories for sources +QTWEBENGINE_ROOT = $$replace(PWD, /build/qmake/mkspecs/features$,) + +QTWEBENGINEPROCESS_NAME = QtWebEngineProcess + +git_chromium_src_dir = $$system("git config qtwebengine.chromiumsrcdir") + +# Fall back to the snapshot path if git does not know about chromium sources (i.e. init-repository.py has not been used) +isEmpty(git_chromium_src_dir): git_chromium_src_dir = "3rdparty/chromium" + +CHROMIUM_SRC_DIR = $$absolute_path("$$QTWEBENGINE_ROOT/$$git_chromium_src_dir") + +INCLUDEPATH += $$CHROMIUM_SRC_DIR + +# Tweaks that shouldn't affect our examples +!contains(_PRO_FILE_PWD_, $$QTWEBENGINE_ROOT/examples) { + # Used for our export macros + DEFINES += BUILDING_CHROMIUM + # We have to disable RTTI for now since that's how chromium builds on linux + unix:QMAKE_CXXFLAGS += -fno-rtti +} +# Location of sync.profile +MODULE_BASE_DIR = $$QTWEBENGINE_ROOT + + +load(functions) + +# Call the original default_pre. +load(default_pre) diff --git a/tools/qmake/mkspecs/features/functions.prf b/tools/qmake/mkspecs/features/functions.prf new file mode 100644 index 000000000..9d90d67bd --- /dev/null +++ b/tools/qmake/mkspecs/features/functions.prf @@ -0,0 +1,109 @@ +# 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") +} + +defineReplace(getOutDir) { + # FIXME: rely on env variable in here and in the gyp_qtwebengine script, à la WEBKITOUTPUTDIR + return("$$QTWEBENGINE_ROOT/out") +} + +defineReplace(getConfigDir) { + CONFIG(release, debug|release):return("Release") + return("Debug") +} + +defineReplace(extractCFlag) { + OPTION = $$find(QMAKE_CFLAGS, $$1) + OPTION = $$split(OPTION, =) + return ($$member(OPTION, 1)) +} + +defineReplace(findMocables) { + input = $$1 + for (file, input): \ + infiles += $$absolute_path($$file, $$_PRO_FILE_PWD_) + mocables = $$system("python $$QTWEBENGINE_ROOT/build/scripts/find-mocables $$infiles") + mocables = $$replace(mocables, $$_PRO_FILE_PWD_$${QMAKE_DIR_SEP}, '') + return($$mocables) +} + +defineReplace(findIncludedMocFiles) { + input = $$1 + for (file, input): \ + infiles += $$absolute_path($$file, $$_PRO_FILE_PWD_) + return($$system("python $$QTWEBENGINE_ROOT/build/scripts/find-included-moc-files $$infiles")) +} + +defineReplace(mocOutput) { + out = $$1 + # The order is important, since the output of the second replace would end up accidentaly transformed by the first one + out = $$replace(out, ^(.*)($$join(QMAKE_EXT_CPP,|)), $${QMAKE_CPP_MOD_MOC}\\1$${QMAKE_EXT_CPP_MOC}) + out = $$replace(out, ^(.*)($$join(QMAKE_EXT_H,|)), $${QMAKE_H_MOD_MOC}\\1$${first(QMAKE_EXT_CPP)}) + return($$out) +} + +defineReplace(rccOutput) { + out = $$1 + out = $$replace(out, .qrc, .cpp) + out = $$join(out, qrc_, qrc_) + return($$out) +} + +defineReplace(rccExternFunc) { + out = $$1 + out = $$replace(out, .qrc, ) + return($$out) +} + +defineReplace(which) { + out = $$1 + win32 { + command = $$split(out, " ") + executable = $$first(command) + # Return the first match only + out = $$system("((for /f \"usebackq delims=\" %i in (`where $$executable 2^> NUL`) do @if not defined _endwhich (@echo %i & set _endwhich=true)) & set _endwhich=)") + isEmpty(out) { + message($$executable not found) + out = $$executable + } + for(arg, command): !equals(arg, $$executable): out += $$arg + } else:unix { + command = $$split(out, " ") + executable = $$first(command) + out = $$system("which $$executable 2>/dev/null") + isEmpty(out) { + message($$executable not found) + out = $$executable + } + for(arg, command): !equals(arg, $$executable): out += $$arg + } + return($$out) +} + +defineReplace(findOrBuildNinja) { + !isEmpty(CACHED_NINJA_EXECUTABLE):exists($$CACHED_NINJA_EXECUTABLE): return($$CACHED_NINJA_EXECUTABLE) + out = $$which(ninja) + # Try to be smart about it if we know where the chromium sources are located + !exists($$out) { + git_chromium_src_dir = $$system("git config qtwebengine.chromiumsrcdir") + # Fall back to the snapshot path if git does not know about chromium sources (i.e. init-repository.py has not been used) + isEmpty(git_chromium_src_dir): git_chromium_src_dir = "3rdparty/chromium" + win32: out = $$system_path($$absolute_path("$$QTWEBENGINE_ROOT/$$git_chromium_src_dir/../ninja/ninja.exe")) + else: out = $$absolute_path("$$QTWEBENGINE_ROOT/$$git_chromium_src_dir/../ninja/ninja") + # If we still did not find ninja, then we bootstrap it. + !exists($$out) { + message("bootstrapping ninja...") + ninjadir = $$dirname(out) + system("python $$ninjadir/bootstrap.py") + } + } + message("using $$out") + cache(CACHED_NINJA_EXECUTABLE, set, out) + return($$out) +} diff --git a/tools/qmake/mkspecs/features/gyp_generator.prf b/tools/qmake/mkspecs/features/gyp_generator.prf new file mode 100644 index 000000000..d15b864c9 --- /dev/null +++ b/tools/qmake/mkspecs/features/gyp_generator.prf @@ -0,0 +1,208 @@ +# 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) +load(moc) +load(resources) + +defineReplace(mocAction) { + INPUT_FILE = $$1 + OUTPUT_NAME = $$mocOutput($$INPUT_FILE) + DEFINES_LIST = $$join(DEFINES, " -D", -D) + INCPATH = $$join(INCLUDEPATH, " -I", -I) + MOC_COMMAND = $$mocCmdBase() + MOC_COMMAND = $$replace(MOC_COMMAND, $$re_escape("$(DEFINES)"), $$DEFINES_LIST) + MOC_COMMAND = $$replace(MOC_COMMAND, $$re_escape("$(INCPATH)"), $$INCPATH) + MOC_COMMAND = $$split(MOC_COMMAND, " ") + OUTPUT_FILE = $$absolute_path($$MOC_DIR, $$OUT_PWD)$${QMAKE_DIR_SEP}$${OUTPUT_NAME} + contents = " {" \ + " 'action_name':'$$OUTPUT_NAME'," \ + " 'inputs': ['$$INPUT_FILE',]," \ + " 'outputs': ['$$OUTPUT_FILE',]," \ + " 'action': [" + for(token, MOC_COMMAND): contents += " '$$token'," + contents += " '$$INPUT_FILE'," \ + " '-o'," \ + " '$$OUTPUT_FILE'," \ + " ]," \ + " }," + + return($$contents) +} + +defineReplace(rccAction) { + win32-*: QMAKE_RCC ~= s,\\\\,/,g + INPUT_FILE = $$1 + OUTPUT_NAME = $$rccOutput($$INPUT_FILE) + EXTERN_FUNC = $$rccExternFunc($$INPUT_FILE) + OUTPUT_FILE = $$absolute_path($$RCC_DIR, $$OUT_PWD)$${QMAKE_DIR_SEP}$${OUTPUT_NAME} + contents = " {" \ + " 'action_name':'$$OUTPUT_NAME'," \ + " 'inputs': ['$$INPUT_FILE',]," \ + " 'outputs': ['$$OUTPUT_FILE',]," \ + " 'action': [" \ + " '$$QMAKE_RCC'," + for(resource_flag, $$QMAKE_RESOURCE_FLAGS): contents += " '$$resource_flag'," + contents += " '-name'," \ + " '$$EXTERN_FUNC'," \ + " '$$INPUT_FILE'," \ + " '-o'," \ + " '$$OUTPUT_FILE'," + contents += " ]," \ + " }," + + return($$contents) +} + +GYPI_FILE = $$replace(_PRO_FILE_, .pro$, .gyp) + +TARGET_TYPE = $$toGypTargetType() +MOCABLE_HEADERS = $$findMocables($$HEADERS) +INCLUDED_MOC_FILES = $$findIncludedMocFiles($$SOURCES) + +GYP_CONTENTS = "{" \ + " 'targets': [" \ + " {" \ + " 'target_name': '$$TARGET'," \ + " 'type': '$$TARGET_TYPE'," +!isEmpty(GYPINCLUDES) { +GYP_CONTENTS += " 'includes': [" +for (incl, GYPINCLUDES): GYP_CONTENTS += " '$$incl'," +GYP_CONTENTS += " ]," +} + +# Split LIBS into linker flags and actual libraries, and add them to the +# appropriate section (ldflags vs link_settings: libraries) in the gyp file. +LIBRARIES = $$find(LIBS, "-l") +LIBRARIES = $$unique(LIBRARIES) +for (library, LIBRARIES): LIBS -= "$$library" + +GYP_CONTENTS += " 'ldflags': [" +for (lib, LIBS): GYP_CONTENTS += " '$$lib'," +for (rpath, QMAKE_RPATHDIR): GYP_CONTENTS += " '$$QMAKE_RPATH$$rpath'," +GYP_CONTENTS += " ]," + +!isEmpty(QMAKE_CFLAGS) { + GYP_CONTENTS += " 'cflags': [" + for(flag, QMAKE_CFLAGS): GYP_CONTENTS += " '$$flag'," + GYP_CONTENTS += " ]," +} +!isEmpty(QMAKE_CXXFLAGS) { + GYP_CONTENTS += " 'cflags_cc': [" + for(flag, QMAKE_CXXFLAGS): GYP_CONTENTS += " '$$flag'," + GYP_CONTENTS += " ]," +} +GYP_CONTENTS += " 'link_settings': {" \ + " 'libraries': [" +for (library, LIBRARIES): GYP_CONTENTS += " '$$library'," +macx { + FRAMEWORKS = $$find(LIBS, "Q*") + FRAMEWORKS = $$unique(FRAMEWORKS) + FRAMEWORKS ~= s/-.*/ + FRAMEWORKS -= "-framework" + for (framework, FRAMEWORKS): { + framework_name = $$join(framework, "", "", ".framework") + GYP_CONTENTS += " '$$framework_name'," + } + + FRAMEWORK_PATHS = $$find(LIBS, "-F*") + FRAMEWORK_PATHS = $$unique(FRAMEWORK_PATHS) + FRAMEWORK_PATHS -= "-framework" + for (framework_path, FRAMEWORK_PATHS): GYP_CONTENTS += " '$$framework_path'," + !isEmpty(QMAKE_FRAMEWORKPATH): GYP_CONTENTS += " '-F$$QMAKE_FRAMEWORKPATH'," +} +GYP_CONTENTS += " ]," \ + " }," + +!isEmpty(GYPDEPENDENCIES) { + GYP_CONTENTS += " 'dependencies': [" + for (dep, GYPDEPENDENCIES): GYP_CONTENTS += " '$$dep'," + GYP_CONTENTS += " ]," +} +!isEmpty(DEFINES) { + GYP_CONTENTS += " 'defines': [" + for (define, DEFINES): GYP_CONTENTS += " '$$define'," + GYP_CONTENTS += " ]," +} +!isEmpty(PER_CONFIG_DEFINES) { + GYP_CONTENTS += " 'configurations': {"\ + " 'Release': {" \ + " 'defines': [" + for (define, PER_CONFIG_DEFINES): GYP_CONTENTS += " '$$replace(define,%config,Release)'," + GYP_CONTENTS += " ]," \ + " }," \ + " 'Debug': {" \ + " 'defines': [" + for (define, PER_CONFIG_DEFINES): GYP_CONTENTS += " '$$replace(define,%config,Debug)'," + GYP_CONTENTS += " ]," \ + " }," \ + " }," +} +!isEmpty(GYP_DYLIB_INSTALL_NAME_BASE) { + GYP_CONTENTS += " 'xcode_settings': {" \ + " 'DYLIB_INSTALL_NAME_BASE': '$$GYP_DYLIB_INSTALL_NAME_BASE'," \ + " }," +} + +# Source files to compile +GYP_CONTENTS += " 'sources': [" +for (sourcefile, SOURCES): GYP_CONTENTS += " '$$sourcefile'," +for (headerfile, HEADERS): GYP_CONTENTS += " '$$headerfile'," + +# Add Sources generated by rcc from qrc files. +for (resourcefile, RESOURCES) { + RCC_CPP = $$replace(resourcefile, .qrc, .cpp) + RCC_CPP = $$join(RCC_CPP, "qrc_", qrc_) + RCC_CPP = $$absolute_path($$RCC_DIR, $$OUT_PWD)$${QMAKE_DIR_SEP}$${RCC_CPP} + GYP_CONTENTS += " '$$RCC_CPP'," +} + +# Add moc output files to compile that aren't included at the end of any other source +MOC_OUT_PATH = $$absolute_path($$MOC_DIR, $$OUT_PWD)$${QMAKE_DIR_SEP} +for (mocable_header, MOCABLE_HEADERS) { + !contains(INCLUDED_MOC_FILES, $$mocOutput($$mocable_header)) { + GYP_CONTENTS += " '$$MOC_OUT_PATH$$mocOutput($$mocable_header)'," + } +} + +GYP_CONTENTS += " ]," +!isEmpty(INCLUDEPATH) { + GYP_CONTENTS += " 'include_dirs': [" + for (path, INCLUDEPATH): GYP_CONTENTS += " '$$path'," + GYP_CONTENTS += " ]," +} + +# Some needed files (like devtools_resources.pak) are both _generated_ as part of the build process and are _needed_ as part of the build process. +!isEmpty(COPY_FILES) { + GYP_CONTENTS += " 'copies': [" + for (index, 0..$$size(COPY_FILES)) { + copyFile = $$member(COPY_FILES, $$index) + !isEmpty(copyFile) { + copyDestination = $$member(COPY_DESTINATIONS, $$index) + GYP_CONTENTS += " {'destination': '$$copyDestination', 'files': ['$$copyFile']}," + } + } + GYP_CONTENTS += " ]," +} + +# Generate the actions for moc, copy +GYP_CONTENTS += " 'actions': [" +for(resourcefile, RESOURCES): GYP_CONTENTS += $$rccAction($$resourcefile) +for(header, MOCABLE_HEADERS): GYP_CONTENTS += $$mocAction($$header) +GYP_CONTENTS += " ]," \ + " }," + +GYP_CONTENTS += " ]," \ + "}" + +!build_pass: write_file($$GYPI_FILE, GYP_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 $$QTWEBENGINE_ROOT/build/build.pro") + +# The generated Makefile shouldn't build anything by itself, just re-run qmake if necessary +TEMPLATE = aux +SOURCES = +HEADERS = +RESOURCES = diff --git a/tools/qmake/mkspecs/features/mac/default_post.prf b/tools/qmake/mkspecs/features/mac/default_post.prf new file mode 100644 index 000000000..2b9fed81b --- /dev/null +++ b/tools/qmake/mkspecs/features/mac/default_post.prf @@ -0,0 +1,2 @@ +CONFIG -= build_all +load(default_post) |