Help automoc to find metadata JSON files referenced in the code
ClosedPublic

Authored by kossebau on Feb 22 2018, 12:59 AM.

Details

Summary

automoc by itself can only detect metadata files referenced by direct
usage of the Q_PLUGIN_METADATA macro. It does not do any C++ preprocessor
evaluation. Instead it needs to be helped with regexp-based filter rules
for detecting any names of files used as additional moc input.
See docs for AUTOMOC_DEPEND_FILTERS for further details.

In the near future all the boilerplate code should be replaced with a yet to
be designed ECM macro. For now explicit code is used to collect use cases
for the macro and still to fix the issue already.

Test Plan

Changing a JSON file (or for those generated from .desktop files
changing that one) and running make results in the related *.moc file
being regenerated and the related object file being recompiled.
qtplugininfo shows that the created plugin binary has up-to-date JSON
content.

Diff Detail

Repository
R242 Plasma Framework (Library)
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
kossebau created this revision.Feb 22 2018, 12:59 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptFeb 22 2018, 12:59 AM
kossebau requested review of this revision.Feb 22 2018, 12:59 AM

For more details see comments on D10724

apol added inline comments.Feb 22 2018, 2:19 AM
CMakeLists.txt
179

Can't we reuse this same code from kcoreaddons? Maybe kcoreaddons can offer a macro that does this?

Thanks for review.

Can't we reuse this same code from kcoreaddons? Maybe kcoreaddons can offer a macro that does this?

As hinted in the commit message, plan is to have some ECM macro instead, but only for 5.45 in a month, to not hurry macro signature design. Soon up for discussion though.

Current draft/working prototype results in code like the following for CMakeLists.txt (replacing the complete current code to set up things with CMAKE_AUTOMOC_MACRO_NAMES & :CMAKE_AUTOMOC_DEPEND_FILTERS):

include(ECMSetupQtPluginMacros)

ecm_setup_qtplugin_macros(
    JSON_NONE
        "K_EXPORT_PLASMA_SERVICE"
        "K_EXPORT_PLASMA_APPLET"
        "K_EXPORT_PLASMA_PACKAGE"
        "K_EXPORT_PLASMA_APPLETSCRIPTENGINE"
        "K_EXPORT_PLASMA_DATAENGINESCRIPTENGINE"
        "K_EXPORT_PLASMA_DATAENGINE"
    JSON_ARG2
        "K_EXPORT_PLASMA_PACKAGE_WITH_JSON"
    JSON_ARG3
        "K_EXPORT_PLASMA_SERVICE_WITH_JSON"
        "K_EXPORT_PLASMA_APPLET_WITH_JSON"
        "K_EXPORT_PLASMA_APPLETSCRIPTENGINE_WITH_JSON"
        "K_EXPORT_PLASMA_DATAENGINESCRIPTENGINE_WITH_JSON"
        "K_EXPORT_PLASMA_CONTAINMENTACTIONS_WITH_JSON"
        "K_EXPORT_PLASMA_DATAENGINE_WITH_JSON"
    CONFIG_VARIABLE
         PACKAGE_SETUP_AUTOMOC_MACROS
)

and in the KF5PlasmaConfig.cmake.in then just need some

@PACKAGE_SETUP_AUTOMOC_MACROS@

The complete code copies as now in the patch are just a temporary solution by purpose, to already fix the issue, but without rushed new public API.

kossebau updated this revision to Diff 27868.Feb 23 2018, 5:57 PM

have each macro added only once (closer to current draft of ECM macro)

Given there was no principal objection and this code is following the pattern of D10724, going to push now as well, so it gets some more field-testing before next weeks tagging.

This revision was not accepted when it landed; it landed in state Needs Review.Feb 25 2018, 9:23 PM
This revision was automatically updated to reflect the committed changes.