From 792409cb51e69d71ac68c342dbb506274e1df7df Mon Sep 17 00:00:00 2001 From: Dinand Vanvelzen Date: Sat, 23 Sep 2023 20:50:08 -0500 Subject: [PATCH] ProjectGen: Added metadata support to target merge feature --- .../include/gucefProjectGen_DataTypes.h | 74 +++++++++---------- .../gucefProjectGen_CArduinoCLIGenerator.cpp | 12 +-- .../src/gucefProjectGen_DataTypes.cpp | 50 ++++++++++++- 3 files changed, 92 insertions(+), 44 deletions(-) diff --git a/tools/ProjectGen/include/gucefProjectGen_DataTypes.h b/tools/ProjectGen/include/gucefProjectGen_DataTypes.h index 5366cc697..a4667b346 100644 --- a/tools/ProjectGen/include/gucefProjectGen_DataTypes.h +++ b/tools/ProjectGen/include/gucefProjectGen_DataTypes.h @@ -165,43 +165,6 @@ typedef struct SPreprocessorSettings TPreprocessorSettings; /*---------------------------------------------------------------------------*/ -struct SModuleInfo -{ - CORE::CString name; // the name of the module - TModuleType moduleType; // The type of module we are dealing with - TStringSet tags; // optional tags that can be associated which allows filtering of modules - - TStringSet dependencies; // list of module names of all modules this module depends on - TStringSet dependencyIncludeDirs; // include directories needed for the headers of the dependencies, paths only no files - TStringSet runtimeDependencies; // dependencies not relative for builds but desired to be easily accessable due to runtime dependency, typically plugins - - TStringSetMap includeDirs; // include directories of this module's own headers - TStringSetMap sourceDirs; // source directories of this module's own source - - int buildOrder; // order number of this module in the build dependency chain - int buildChain; // index of the build chain, different build chains can be build independently but may depend on other chains - TInt32Set buildChainDependencies; // other build chains this build chain is dependent on, if any - bool considerSubDirs; // Whether only the dir with the ModuleInfo is to be considered or whether subdirs are recursively considered - - TLinkerSettings linkerSettings; // all linker related settings for this module - TCompilerSettings compilerSettings; // all compiler related settings for this module - TPreprocessorSettings preprocessorSettings; // all preprocessor related settings for this module - - bool ignoreModule; // whether this module should be included in the build - CORE::CVersion semver; // SemVer at the ModuleInfo level allowing for inheritance/overrides -}; -typedef struct SModuleInfo TModuleInfo; - -/*---------------------------------------------------------------------------*/ - -typedef std::vector< TModuleInfo > TModuleInfoVector; -typedef std::map< CORE::CString, TModuleInfoVector > TModuleInfoVectorMap; -typedef std::map< CORE::CString, TModuleInfo > TModuleInfoMap; -typedef std::vector< TModuleInfo* > TModuleInfoPtrVector; -typedef std::map< CORE::CString, const TModuleInfo* > TConstModuleInfoPtrMap; - -/*---------------------------------------------------------------------------*/ - class GUCEF_PROJECTGEN_PUBLIC_CPP CModuleMetaData : public CORE::CIDataNodeSerializable { public: @@ -248,6 +211,43 @@ class GUCEF_PROJECTGEN_PUBLIC_CPP CModuleMetaData : public CORE::CIDataNodeSeria /*---------------------------------------------------------------------------*/ +struct SModuleInfo +{ + CORE::CString name; // the name of the module + TModuleType moduleType; // The type of module we are dealing with + TStringSet tags; // optional tags that can be associated which allows filtering of modules + + TStringSet dependencies; // list of module names of all modules this module depends on + TStringSet dependencyIncludeDirs; // include directories needed for the headers of the dependencies, paths only no files + TStringSet runtimeDependencies; // dependencies not relative for builds but desired to be easily accessable due to runtime dependency, typically plugins + + TStringSetMap includeDirs; // include directories of this module's own headers + TStringSetMap sourceDirs; // source directories of this module's own source + + int buildOrder; // order number of this module in the build dependency chain + int buildChain; // index of the build chain, different build chains can be build independently but may depend on other chains + TInt32Set buildChainDependencies; // other build chains this build chain is dependent on, if any + bool considerSubDirs; // Whether only the dir with the ModuleInfo is to be considered or whether subdirs are recursively considered + + TLinkerSettings linkerSettings; // all linker related settings for this module + TCompilerSettings compilerSettings; // all compiler related settings for this module + TPreprocessorSettings preprocessorSettings; // all preprocessor related settings for this module + + bool ignoreModule; // whether this module should be included in the build + CModuleMetaData metadata; // module metadata +}; +typedef struct SModuleInfo TModuleInfo; + +/*---------------------------------------------------------------------------*/ + +typedef std::vector< TModuleInfo > TModuleInfoVector; +typedef std::map< CORE::CString, TModuleInfoVector > TModuleInfoVectorMap; +typedef std::map< CORE::CString, TModuleInfo > TModuleInfoMap; +typedef std::vector< TModuleInfo* > TModuleInfoPtrVector; +typedef std::map< CORE::CString, const TModuleInfo* > TConstModuleInfoPtrMap; + +/*---------------------------------------------------------------------------*/ + class GUCEF_PROJECTGEN_PUBLIC_CPP CModuleInfoEntry : public CORE::CIDataNodeSerializable { public: diff --git a/tools/ProjectGen/src/gucefProjectGen_CArduinoCLIGenerator.cpp b/tools/ProjectGen/src/gucefProjectGen_CArduinoCLIGenerator.cpp index 8d62be297..fe6ca9b98 100644 --- a/tools/ProjectGen/src/gucefProjectGen_CArduinoCLIGenerator.cpp +++ b/tools/ProjectGen/src/gucefProjectGen_CArduinoCLIGenerator.cpp @@ -360,12 +360,12 @@ CreateArduinoCLILibraryPropertiesFiles( const TModuleInfoEntryPairVector& mergeL GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "Generating library.properties for module \"" + mergedModule->name + "\" at: " + libPropsPath ); CORE::CString content = "name=" + mergedModule->name + "\n"; - content += "version=" + mergedModule->semver.ToString( true, true, false ) + "\n"; - content += "author=" + CORE::StringSetToString( originalModule->metadata.authors, CORE::CString::Empty, ',' ) + "\n"; - content += "maintainer=" + CORE::StringSetToString( originalModule->metadata.maintainers, CORE::CString::Empty, ',' ) + "\n"; - content += "sentence=" + originalModule->metadata.descriptionHeadline + "\n"; - content += "paragraph=" + originalModule->metadata.descriptionDetails + "\n"; - content += "license=" + originalModule->metadata.license + "\n"; + content += "version=" + mergedModule->metadata.semver.ToString( true, true, false ) + "\n"; + content += "author=" + CORE::StringSetToString( mergedModule->metadata.authors, CORE::CString::Empty, ',' ) + "\n"; + content += "maintainer=" + CORE::StringSetToString( mergedModule->metadata.maintainers, CORE::CString::Empty, ',' ) + "\n"; + content += "sentence=" + mergedModule->metadata.descriptionHeadline + "\n"; + content += "paragraph=" + mergedModule->metadata.descriptionDetails + "\n"; + content += "license=" + mergedModule->metadata.license + "\n"; //architectures=avr,megaavr ? //includes=src/common/include/gucef.h ? diff --git a/tools/ProjectGen/src/gucefProjectGen_DataTypes.cpp b/tools/ProjectGen/src/gucefProjectGen_DataTypes.cpp index ac3fcbbb5..70033cb30 100644 --- a/tools/ProjectGen/src/gucefProjectGen_DataTypes.cpp +++ b/tools/ProjectGen/src/gucefProjectGen_DataTypes.cpp @@ -1092,7 +1092,6 @@ DeserializeModuleInfo( TModuleInfo& moduleInfo , return false; // Find the overall module properties - moduleInfo.semver.FromString( moduleInfoNode->GetAttributeValue( "SemVer", moduleInfo.semver.ToString(), false ).AsString( moduleInfo.semver.ToString(), true ) ); CORE::CString tmpStr = moduleInfoNode->GetAttributeValue( "BuildOrder", "-1" ); moduleInfo.buildOrder = CORE::StringToInt32( tmpStr ); tmpStr = moduleInfoNode->GetAttributeValue( "BuildChain", "-1" ); @@ -1675,6 +1674,50 @@ FindModuleInfoForPlatform( const CModuleInfoEntry& moduleInfoEntry , /*-------------------------------------------------------------------------*/ +bool +MergeModuleMetaData( const CModuleMetaData& priorityA , + const CModuleMetaData& priorityB , + CModuleMetaData& target ) +{GUCEF_TRACE; + + MergeStringSet( target.authors, priorityA.authors, false ); + MergeStringSet( target.authors, priorityB.authors, false ); + MergeStringSet( target.maintainers, priorityA.maintainers, false ); + MergeStringSet( target.maintainers, priorityB.maintainers, false ); + + target.descriptionDetails = priorityA.descriptionDetails.IsNULLOrEmpty() ? priorityB.descriptionDetails : priorityA.descriptionDetails; + target.descriptionHeadline = priorityA.descriptionHeadline.IsNULLOrEmpty() ? priorityB.descriptionHeadline : priorityA.descriptionHeadline; + target.license = priorityA.license.IsNULLOrEmpty() ? priorityB.license : priorityA.license; + target.lastEditBy = priorityA.lastEditBy.IsNULLOrEmpty() ? priorityB.lastEditBy : priorityA.lastEditBy; + target.semver = priorityA.semver.IsAllZero() ? priorityB.semver : priorityA.semver; + + return true; +} + +/*-------------------------------------------------------------------------*/ + +bool +MergeModuleMetaData( const CModuleInfoEntry& moduleInfoEntry , + const CORE::CString& targetPlatform , + TModuleInfo& mergedModuleInfo ) +{GUCEF_TRACE; + + const TModuleInfo* allPlatformsInfo = FindModuleInfoForPlatform( moduleInfoEntry, AllPlatforms ); + const TModuleInfo* targetPlatformInfo = FindModuleInfoForPlatform( moduleInfoEntry, targetPlatform ); + + // an all-platforms module level meta-data overrules overarching meta-data + if ( GUCEF_NULL != allPlatformsInfo ) + MergeModuleMetaData( allPlatformsInfo->metadata, moduleInfoEntry.metadata, mergedModuleInfo.metadata ); + + // a platform specific module level meta-data overrules all-platforms meta-data + if ( GUCEF_NULL != targetPlatformInfo ) + MergeModuleMetaData( targetPlatformInfo->metadata, mergedModuleInfo.metadata, mergedModuleInfo.metadata ); + + return true; +} + +/*-------------------------------------------------------------------------*/ + bool MergeModuleInfo( const CModuleInfoEntry& moduleInfoEntry , const CORE::CString& targetPlatform , @@ -1702,6 +1745,7 @@ MergeModuleInfo( const CModuleInfoEntry& moduleInfoEntry , // Now merge in the platform specific info MergeModuleInfo( mergedModuleInfo, *targetPlatformInfo ); + MergeModuleMetaData( moduleInfoEntry, targetPlatform, mergedModuleInfo ); return true; } } @@ -1715,6 +1759,8 @@ MergeModuleInfo( const CModuleInfoEntry& moduleInfoEntry , { // We only have the 'all' platform which is fine, we will just use that mergedModuleInfo = *allPlatformsInfo; + + MergeModuleMetaData( moduleInfoEntry, targetPlatform, mergedModuleInfo ); return true; } else @@ -1723,6 +1769,8 @@ MergeModuleInfo( const CModuleInfoEntry& moduleInfoEntry , // We only have the target platform which is fine, we will just use that // this module aparently is not available for all platforms even in altered form mergedModuleInfo = *targetPlatformInfo; + + MergeModuleMetaData( moduleInfoEntry, targetPlatform, mergedModuleInfo ); return true; } }