summaryrefslogtreecommitdiffstats
path: root/build/qmake/mkspecs/features/gyp_generator.prf
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@digia.com>2013-05-22 21:03:05 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2013-05-31 10:55:53 +0200
commit534c1b9e6c4204cd4fbccb77d1f26db124410ca4 (patch)
tree35a6b710a54a2e08fda1e172424ea14297492706 /build/qmake/mkspecs/features/gyp_generator.prf
parent18d0fc90d3faa65ad06bcbe4bb2a62436025534c (diff)
Rename gypi_gen to gyp_generator
technically it's more correct now that we don't even bother and generate the .gyp file directly.
Diffstat (limited to 'build/qmake/mkspecs/features/gyp_generator.prf')
-rw-r--r--build/qmake/mkspecs/features/gyp_generator.prf86
1 files changed, 86 insertions, 0 deletions
diff --git a/build/qmake/mkspecs/features/gyp_generator.prf b/build/qmake/mkspecs/features/gyp_generator.prf
new file mode 100644
index 000000000..4d46f84ec
--- /dev/null
+++ b/build/qmake/mkspecs/features/gyp_generator.prf
@@ -0,0 +1,86 @@
+# 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)
+
+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)
+}
+
+GYPI_FILE = $$replace(_PRO_FILE_, .pro$, .gyp)
+
+TARGET_TYPE = $$toGypTargetType()
+MOCABLE_HEADERS = $$findMocables($$HEADERS)
+MOCABLE_SOURCES = $$findMocables($$SOURCES)
+
+GYPI_CONTENTS = "{" \
+ " 'targets': [" \
+ " {" \
+ " 'target_name': '$$TARGET'," \
+ " 'type': '$$TARGET_TYPE'," \
+ " 'includes': [" \
+ " '../blinq.gypi'," \
+ " ]," \
+ " 'ldflags': ["
+for (lib, LIBS): GYPI_CONTENTS += " '$$lib',"
+!isEmpty(QMAKE_RPATHDIR): GYPI_CONTENTS += " '$$QMAKE_RPATH$$QMAKE_RPATHDIR',"
+
+GYPI_CONTENTS += " ],"
+
+!isEmpty(DEFINES) {
+ GYPI_CONTENTS += " 'defines': ["
+ for (define, DEFINES): GYPI_CONTENTS += " '$$define',"
+ GYPI_CONTENTS += " ],"
+}
+GYPI_CONTENTS += " 'sources': ["
+for (sourcefile, SOURCES): GYPI_CONTENTS += " '$$sourcefile',"
+for (headerfile, HEADERS): GYPI_CONTENTS += " '$$headerfile',"
+MOC_OUT_PATH = $$absolute_path($$MOC_DIR, $$OUT_PWD)$${QMAKE_DIR_SEP}
+for (mocable_header, MOCABLE_HEADERS): GYPI_CONTENTS += " '$$MOC_OUT_PATH$$mocOutput($$mocable_header)',"
+for (mocable_source, MOCABLE_SOURCES): GYPI_CONTENTS += " '$$MOC_OUT_PATH$$mocOutput($$mocable_source)',"
+GYPI_CONTENTS += " ],"
+!isEmpty(INCLUDEPATH) {
+ GYPI_CONTENTS += " 'include_dirs': ["
+ for (path, INCLUDEPATH): GYPI_CONTENTS += " '$$path',"
+ GYPI_CONTENTS += " ],"
+}
+# Generate the actions for moc
+!isEmpty(MOCABLE_HEADERS)|!isEmpty(MOCABLE_SOURCES) {
+ GYPI_CONTENTS += " 'actions': ["
+ for(header, MOCABLE_HEADERS): GYPI_CONTENTS += $$mocAction($$header)
+ GYPI_CONTENTS += " ],"
+}
+
+GYPI_CONTENTS += " }," \
+ " ]," \
+ "}"
+
+write_file($$GYPI_FILE, GYPI_CONTENTS)
+
+# The generated Makefile shouldn't build anything by itself, just re-run qmake if necessary
+TEMPLATE = aux
+SOURCES =
+HEADERS =