Skip to content

Commit

Permalink
ProjectGen: Added metadata support to target merge feature
Browse files Browse the repository at this point in the history
  • Loading branch information
LiberatorUSA committed Sep 24, 2023
1 parent f4574ff commit 792409c
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 44 deletions.
74 changes: 37 additions & 37 deletions tools/ProjectGen/include/gucefProjectGen_DataTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions tools/ProjectGen/src/gucefProjectGen_CArduinoCLIGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?
Expand Down
50 changes: 49 additions & 1 deletion tools/ProjectGen/src/gucefProjectGen_DataTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down Expand Up @@ -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 ,
Expand Down Expand Up @@ -1702,6 +1745,7 @@ MergeModuleInfo( const CModuleInfoEntry& moduleInfoEntry ,
// Now merge in the platform specific info
MergeModuleInfo( mergedModuleInfo, *targetPlatformInfo );

MergeModuleMetaData( moduleInfoEntry, targetPlatform, mergedModuleInfo );
return true;
}
}
Expand All @@ -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
Expand All @@ -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;
}
}
Expand Down

0 comments on commit 792409c

Please sign in to comment.