# 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) 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 += " ]," } GYP_CONTENTS += " 'ldflags': [" for (lib, LIBS): GYP_CONTENTS += " '$$lib'," !isEmpty(QMAKE_RPATHDIR): GYP_CONTENTS += " '$$QMAKE_RPATH$$QMAKE_RPATHDIR'," GYP_CONTENTS += " ]," macx { GYP_CONTENTS += " 'link_settings': {" \ " 'libraries': [" 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 += " ]," \ " }," \ " }," } # Source files to compile GYP_CONTENTS += " 'sources': [" for (sourcefile, SOURCES): GYP_CONTENTS += " '$$sourcefile'," for (headerfile, HEADERS): GYP_CONTENTS += " '$$headerfile'," # 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 += " ]," } # Generate the actions for moc !isEmpty(MOCABLE_HEADERS) { GYP_CONTENTS += " 'actions': [" for(header, MOCABLE_HEADERS): GYP_CONTENTS += $$mocAction($$header) GYP_CONTENTS += " ]," } GYP_CONTENTS += " }," \ " ]," \ "}" 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 =