summaryrefslogtreecommitdiffstats
path: root/tools/qmake/mkspecs/features/gyp_generator.prf
diff options
context:
space:
mode:
Diffstat (limited to 'tools/qmake/mkspecs/features/gyp_generator.prf')
-rw-r--r--tools/qmake/mkspecs/features/gyp_generator.prf208
1 files changed, 208 insertions, 0 deletions
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 =