DEKI/ENGINE docs
manual api reference
Deki 0.40.1
Modular C++ engine with a visual editor, for 2D and 3D
Loading...
Searching...
No Matches
DekiEditor::CMakeGen Namespace Reference

Generates the CMake projects for builds, from the installed packages and the platform. More...

Classes

struct  ExecutableCMakeOptions
 What a build backend chooses for a game built as one ordinary executable. More...
struct  ExecutableLibrary
 A third-party library the executable links, as CMake text the backend writes: the backend resolved it (a prebuilt archive, a source checkout), so only it knows how it is found. More...
struct  FeatureEntry
 One entry of a package's "features": a compile definition the package brings, the component types it provides, and whether it may be left out. More...
struct  FrameworkDependency
 One thing a package needs from a build framework, from package.json: "dependencies": { "<framework id>": [ "bare-name", { "name": "...", ... } ] }. More...
struct  PackageEntry
 Package manifest data, parsed from package.json and package.cmake.

Enumerations

enum class  TransformWidth { None = 0 , TwoD = 2 , ThreeD = 3 }
 The transform width a build compiles into Deki::Object (see deki-engine/include/deki/Object.h and COMPATIBILITY.md). More...

Functions

std::vector< std::string > AddRequiredPackageDefines (const std::string &projectPath, const PlatformConfig &config, const std::vector< std::string > &packageDefines, std::vector< std::string > &missing)
 The build defines with the buildDefine of every package the platform's requiresPackages names added, so a board's own layer (its display and input) is built in whether or not a scene names it.
std::string CapabilityDefineName (const std::string &capability)
 The define a capability becomes: DEKI_CAPABILITY_ and the name upper-cased, any other character as '_' ("opengl" is DEKI_CAPABILITY_OPENGL).
std::vector< std::string > CapabilityDefinesFor (const std::set< std::string > &platformCapabilities, const std::vector< PackageEntry > &packages)
 The capability defines a build for a platform offering platformCapabilities compiles with: DEKI_CAPABILITY_<NAME> for each capability a package names in its capabilityDefines that the platform offers, once each, sorted.
std::set< std::string > CapabilityDefinesTestedBy (const std::filesystem::path &packageDir)
 The DEKI_CAPABILITY_ names the game code of the package in packageDir tests: its .c, .cpp and .h files outside editor/, tests/ and generated/.
std::string CMakeIdentifier (const std::string &name)
 A name as CMake spells it after string(MAKE_C_IDENTIFIER): every character outside [A-Za-z0-9] becomes '', and a leading digit gets a '' in front.
void EmitActivePackageSources (std::ostream &out, const std::vector< PackageEntry > &allPackages, const std::set< std::string > &activePackageIds, const std::vector< std::string > &sourceExcludeRegexes={}, bool excludeGenerated=false)
 Writes one GLOB_RECURSE per active package, leaving out editor/.
void EmitEngineCoreSourceCollection (std::ostream &out, const std::vector< std::string > &extraExclusions={})
 Writes the CMake that collects the engine core sources (GLOB_RECURSE plus the standard exclusions).
void EmitGeneratedFileSources (std::ostream &out, const std::string &enginePath, const std::vector< PackageEntry > &allPackages, const std::set< std::string > &activePackageIds)
 Writes the .gen.cpp sources of the active packages only.
void EmitIncludePaths (std::ostream &out, const std::string &targetName, const std::string &projectSrcRelPath="${DEKI_PROJECT_PATH}/src", const std::vector< std::string > &extraPaths={})
 Writes the target_include_directories block.
void EmitPlatformDefines (std::ostream &out, const std::string &targetName, const PlatformConfig &config, const std::vector< std::string > &packageDefines, const std::vector< std::string > &skipDefines={})
 Writes the target_compile_definitions block.
void EmitProjectSourceCollection (std::ostream &out, const std::string &relPath="${DEKI_PROJECT_PATH}/src", bool excludePluginExports=false)
 Writes the CMake that collects the project's own sources from src/.
std::string EscapeCMakeString (const std::string &s)
 s escaped to sit between double quotes in generated CMake: backslashes, quotes, $ and ; escaped so it stays one literal argument.
std::string EscapeCppString (const std::string &s)
 s escaped to sit between double quotes in generated C++: backslashes, quotes and newlines escaped.
bool FeatureInBuild (const FeatureEntry &feature, const std::vector< std::string > &packageDefines)
 Whether a feature is compiled into a build with these defines: always when no feature plan is in force (the editor's own build), else when its define is.
bool GenerateExecutableCMakeLists (const std::string &projectPath, const std::string &buildDir, const PlatformConfig &config, const std::vector< std::string > &packageDefines, const ExecutableCMakeOptions &options, std::string &error)
 Writes <buildDir>/CMakeLists.txt and its deki_package_init.gen.cpp for config, with WriteIfChanged, so an unchanged build is not reconfigured.
std::string GeneratePackageInitFile (const std::filesystem::path &outputDir, const std::vector< PackageEntry > &allPackages, const std::set< std::string > &activePackageIds, const std::filesystem::path &projectSrcPath="", bool engineDefinesSystemInit=false, bool gameShutsPackagesDown=false)
 Generates a package_init.cpp that calls each package's RegisterComponents() and registers project components with ComponentFactory, for embedded builds.
std::vector< std::string > MissingCapabilities (const PackageEntry &pkg, const std::set< std::string > &platformCapabilities)
 What pkg needs that platformCapabilities does not offer.
bool PackageSupportsPlatform (const PackageEntry &pkg, const std::set< std::string > &platformCapabilities)
 True when MissingCapabilities is empty.
std::vector< std::string > ReadProjectTags (const std::string &projectPath)
 deki.json "tags", or an empty list when there is none.
std::vector< std::string > RequiredPackagesInBuild (const PackageEntry &pkg, const std::vector< std::string > &packageDefines)
 The packages pkg needs in a build with these defines: the package's own requires plus those of each feature in the build.
std::set< std::string > ResolveActivePackages (const std::vector< PackageEntry > &allPackages, const std::vector< std::string > &packageDefines, const std::set< std::string > &platformCapabilities={})
 The packages active for these build defines, transitive dependencies included.
TransformWidth ResolveProjectTransformWidth (const std::vector< PackageEntry > &allPackages, const std::vector< std::string > &projectTags, std::string *why=nullptr)
 The width for a project, which is what a build must compile.
TransformWidth ResolveTransformWidth (const std::vector< PackageEntry > &allPackages, const std::set< std::string > &activeIds, const std::vector< std::string > &projectTags, std::string *why=nullptr)
 The widest transform anything active declares.
std::vector< PackageEntry > ScanPackageManifests (const std::string &projectPath)
 Reads every package manifest in the project's packages/ directory.
std::vector< std::string > SourcesDefiningMain (const std::filesystem::path &packageDir)
 The game code files of the package in packageDir (as above) that define main(), relative to it.
std::set< std::string > TextureFilteringCapabilities (const std::vector< PackageEntry > &packages)
 Every capability some package filters textures with (its filtersTexturesWith).
std::vector< std::string > TransformDefines (TransformWidth width)
 The compile definitions for a width: none, DEKI_TRANSFORM_2D, or both.
std::vector< std::string > UndeclaredCapabilities (const std::set< std::string > &platformCapabilities, const PackageEntry &pkg, const std::set< std::string > &tested)
 The capabilities of platformCapabilities whose define tested (what the package's code tests, CapabilityDefinesTestedBy) names but pkg does not declare in its capabilityDefines: a package from before the list, or one that forgot.
bool WriteIfChanged (const std::filesystem::path &filePath, const std::string &content)
 Writes content only if the file differs, so unchanged files cause no rebuild.

Detailed Description

Generates the CMake projects for builds, from the installed packages and the platform.

Enumeration Type Documentation

◆ TransformWidth

The transform width a build compiles into Deki::Object (see deki-engine/include/deki/Object.h and COMPATIBILITY.md).

A package that reads or writes an object's position, rotation or scale carries "transform_2d" in its package.json "tags"; one that needs the third axis carries "transform_3d"; a project's own scripts declare the same in deki.json. The build takes the widest across the active packages and the project. If nothing declares one, the object has no transform.

Enumerator
None 
TwoD 
ThreeD 

Function Documentation

◆ AddRequiredPackageDefines()

std::vector< std::string > DekiEditor::CMakeGen::AddRequiredPackageDefines ( const std::string & projectPath,
const PlatformConfig & config,
const std::vector< std::string > & packageDefines,
std::vector< std::string > & missing )

The build defines with the buildDefine of every package the platform's requiresPackages names added, so a board's own layer (its display and input) is built in whether or not a scene names it.

A package that is not installed is a problem in missing, one line each, for the backend to report: the build cannot work without it.

◆ CapabilityDefineName()

std::string DekiEditor::CMakeGen::CapabilityDefineName ( const std::string & capability)

The define a capability becomes: DEKI_CAPABILITY_ and the name upper-cased, any other character as '_' ("opengl" is DEKI_CAPABILITY_OPENGL).

◆ CapabilityDefinesFor()

std::vector< std::string > DekiEditor::CMakeGen::CapabilityDefinesFor ( const std::set< std::string > & platformCapabilities,
const std::vector< PackageEntry > & packages )

The capability defines a build for a platform offering platformCapabilities compiles with: DEKI_CAPABILITY_<NAME> for each capability a package names in its capabilityDefines that the platform offers, once each, sorted.

NAME is the capability upper-cased with any other character as '_' ("opengl" is DEKI_CAPABILITY_OPENGL). Empty for a board none of them names, so its build is exactly what it was.

◆ CapabilityDefinesTestedBy()

std::set< std::string > DekiEditor::CMakeGen::CapabilityDefinesTestedBy ( const std::filesystem::path & packageDir)

The DEKI_CAPABILITY_ names the game code of the package in packageDir tests: its .c, .cpp and .h files outside editor/, tests/ and generated/.

◆ CMakeIdentifier()

std::string DekiEditor::CMakeGen::CMakeIdentifier ( const std::string & name)

A name as CMake spells it after string(MAKE_C_IDENTIFIER): every character outside [A-Za-z0-9] becomes '', and a leading digit gets a '' in front.

◆ EmitActivePackageSources()

void DekiEditor::CMakeGen::EmitActivePackageSources ( std::ostream & out,
const std::vector< PackageEntry > & allPackages,
const std::set< std::string > & activePackageIds,
const std::vector< std::string > & sourceExcludeRegexes = {},
bool excludeGenerated = false )

Writes one GLOB_RECURSE per active package, leaving out editor/.

sourceExcludeRegexes leave stripped components out (FeatureResolver); excludeGenerated leaves out the package's checked-in generated/ when the build regenerates reflection itself.

◆ EmitEngineCoreSourceCollection()

void DekiEditor::CMakeGen::EmitEngineCoreSourceCollection ( std::ostream & out,
const std::vector< std::string > & extraExclusions = {} )

Writes the CMake that collects the engine core sources (GLOB_RECURSE plus the standard exclusions).

◆ EmitGeneratedFileSources()

void DekiEditor::CMakeGen::EmitGeneratedFileSources ( std::ostream & out,
const std::string & enginePath,
const std::vector< PackageEntry > & allPackages,
const std::set< std::string > & activePackageIds )

Writes the .gen.cpp sources of the active packages only.

◆ EmitIncludePaths()

void DekiEditor::CMakeGen::EmitIncludePaths ( std::ostream & out,
const std::string & targetName,
const std::string & projectSrcRelPath = "${DEKI_PROJECT_PATH}/src",
const std::vector< std::string > & extraPaths = {} )

Writes the target_include_directories block.

◆ EmitPlatformDefines()

void DekiEditor::CMakeGen::EmitPlatformDefines ( std::ostream & out,
const std::string & targetName,
const PlatformConfig & config,
const std::vector< std::string > & packageDefines,
const std::vector< std::string > & skipDefines = {} )

Writes the target_compile_definitions block.

◆ EmitProjectSourceCollection()

void DekiEditor::CMakeGen::EmitProjectSourceCollection ( std::ostream & out,
const std::string & relPath = "${DEKI_PROJECT_PATH}/src",
bool excludePluginExports = false )

Writes the CMake that collects the project's own sources from src/.

◆ EscapeCMakeString()

std::string DekiEditor::CMakeGen::EscapeCMakeString ( const std::string & s)

s escaped to sit between double quotes in generated CMake: backslashes, quotes, $ and ; escaped so it stays one literal argument.

◆ EscapeCppString()

std::string DekiEditor::CMakeGen::EscapeCppString ( const std::string & s)

s escaped to sit between double quotes in generated C++: backslashes, quotes and newlines escaped.

◆ FeatureInBuild()

bool DekiEditor::CMakeGen::FeatureInBuild ( const FeatureEntry & feature,
const std::vector< std::string > & packageDefines )

Whether a feature is compiled into a build with these defines: always when no feature plan is in force (the editor's own build), else when its define is.

◆ GenerateExecutableCMakeLists()

bool DekiEditor::CMakeGen::GenerateExecutableCMakeLists ( const std::string & projectPath,
const std::string & buildDir,
const PlatformConfig & config,
const std::vector< std::string > & packageDefines,
const ExecutableCMakeOptions & options,
std::string & error )

Writes <buildDir>/CMakeLists.txt and its deki_package_init.gen.cpp for config, with WriteIfChanged, so an unchanged build is not reconfigured.

The engine path is a configure argument (-DDEKI_ENGINE_PATH, from EditorSettings::GetCMakeLocationArgs), never a literal in the file.

packageDefines are the build's package and feature defines; the platform's requiresPackages are added to them here. False, with the reason in error, when the file cannot be written for this platform.

◆ GeneratePackageInitFile()

std::string DekiEditor::CMakeGen::GeneratePackageInitFile ( const std::filesystem::path & outputDir,
const std::vector< PackageEntry > & allPackages,
const std::set< std::string > & activePackageIds,
const std::filesystem::path & projectSrcPath = "",
bool engineDefinesSystemInit = false,
bool gameShutsPackagesDown = false )

Generates a package_init.cpp that calls each package's RegisterComponents() and registers project components with ComponentFactory, for embedded builds.

Returns the generated file's path, to add to the sources.

engineDefinesSystemInit true: the engine core already defines deki_init_package_systems()/deki_shutdown_package_systems() (the static desktop simulator links the committed empty AllPackageInit.gen.cpp stub). This file must not define them again, or the link fails; the package *_InitSystem() calls go at the end of DekiRegisterProjectPackages() instead. False (the default, firmware): the engine leaves the stub out and this file defines both functions.

gameShutsPackagesDown (with engineDefinesSystemInit): the build leaves the engine's stub out (DEKI_GAME_DEFINES_PACKAGE_SYSTEMS, as GenerateExecutableCMakeLists sets it), so this file defines both functions: DekiInitPackageSystems() empty, the systems having started in DekiRegisterProjectPackages() as above, and DekiShutdownPackageSystems() shutting them down in reverse order. Without it a game built as a program never shut its packages down, and their memory (the render system, the passes, the 3D rasteriser's working memory) was reported as a leak.

◆ MissingCapabilities()

std::vector< std::string > DekiEditor::CMakeGen::MissingCapabilities ( const PackageEntry & pkg,
const std::set< std::string > & platformCapabilities )

What pkg needs that platformCapabilities does not offer.

Empty means it can build there. A package that requires nothing builds anywhere, and so does any package when the capability set is empty (no target in hand).

◆ PackageSupportsPlatform()

bool DekiEditor::CMakeGen::PackageSupportsPlatform ( const PackageEntry & pkg,
const std::set< std::string > & platformCapabilities )

True when MissingCapabilities is empty.

◆ ReadProjectTags()

std::vector< std::string > DekiEditor::CMakeGen::ReadProjectTags ( const std::string & projectPath)

deki.json "tags", or an empty list when there is none.

◆ RequiredPackagesInBuild()

std::vector< std::string > DekiEditor::CMakeGen::RequiredPackagesInBuild ( const PackageEntry & pkg,
const std::vector< std::string > & packageDefines )

The packages pkg needs in a build with these defines: the package's own requires plus those of each feature in the build.

◆ ResolveActivePackages()

std::set< std::string > DekiEditor::CMakeGen::ResolveActivePackages ( const std::vector< PackageEntry > & allPackages,
const std::vector< std::string > & packageDefines,
const std::set< std::string > & platformCapabilities = {} )

The packages active for these build defines, transitive dependencies included.

platformCapabilities drops packages the target cannot satisfy, along with dependency edges to them; empty means no platform filtering.

◆ ResolveProjectTransformWidth()

TransformWidth DekiEditor::CMakeGen::ResolveProjectTransformWidth ( const std::vector< PackageEntry > & allPackages,
const std::vector< std::string > & projectTags,
std::string * why = nullptr )

The width for a project, which is what a build must compile.

It ignores which packages a given target ends up with, so all targets of a project agree on what a Deki::Object is. Otherwise a board without deki-3d would compile a narrower object and a scene authored with a third axis would lose it there without warning. The cost is a board carrying a wider object than it needs.

◆ ResolveTransformWidth()

TransformWidth DekiEditor::CMakeGen::ResolveTransformWidth ( const std::vector< PackageEntry > & allPackages,
const std::set< std::string > & activeIds,
const std::vector< std::string > & projectTags,
std::string * why = nullptr )

The widest transform anything active declares.

why receives one line for the build log saying who declared what, or that nothing did.

◆ ScanPackageManifests()

std::vector< PackageEntry > DekiEditor::CMakeGen::ScanPackageManifests ( const std::string & projectPath)

Reads every package manifest in the project's packages/ directory.

◆ SourcesDefiningMain()

std::vector< std::string > DekiEditor::CMakeGen::SourcesDefiningMain ( const std::filesystem::path & packageDir)

The game code files of the package in packageDir (as above) that define main(), relative to it.

A game built as a program has the engine's entry (deki-engine-hosted), so a package with its own is one from before it.

◆ TextureFilteringCapabilities()

std::set< std::string > DekiEditor::CMakeGen::TextureFilteringCapabilities ( const std::vector< PackageEntry > & packages)

Every capability some package filters textures with (its filtersTexturesWith).

◆ TransformDefines()

std::vector< std::string > DekiEditor::CMakeGen::TransformDefines ( TransformWidth width)

The compile definitions for a width: none, DEKI_TRANSFORM_2D, or both.

◆ UndeclaredCapabilities()

std::vector< std::string > DekiEditor::CMakeGen::UndeclaredCapabilities ( const std::set< std::string > & platformCapabilities,
const PackageEntry & pkg,
const std::set< std::string > & tested )

The capabilities of platformCapabilities whose define tested (what the package's code tests, CapabilityDefinesTestedBy) names but pkg does not declare in its capabilityDefines: a package from before the list, or one that forgot.

A build defines them anyway and says so, so the package keeps building as it did; the old editor defined DEKI_CAPABILITY_OPENGL for every platform with "opengl".

◆ WriteIfChanged()

bool DekiEditor::CMakeGen::WriteIfChanged ( const std::filesystem::path & filePath,
const std::string & content )

Writes content only if the file differs, so unchanged files cause no rebuild.