[build] Also build sim modules as static libraries

This allows sim modules to be statically linked into an executable to
create a "perfectly static" simulated desktop program. The entry point
was changed to be unique when building static libraries to avoid symbol
collisions.
This commit is contained in:
Prateek Machiraju
2021-06-06 10:19:02 -04:00
committed by Peter Johnson
parent 0e702eb799
commit 2a09f6fa45

View File

@@ -21,10 +21,15 @@ if (!project.hasProperty('onlylinuxathena')) {
}
}
binaries.all {
// Define a custom entry point if we are building statically to avoid symbol collision.
if (it instanceof StaticLibraryBinarySpec) {
it.buildable = false
return
// These scenario is seldom used, except in sysid to build a fully static exe
// with simulation modules. When building static, it is important that no two
// modules have the same entry point symbolically.
def name = project.name.replace("halsim_", "").toUpperCase()
it.cppCompiler.define("HALSIM_InitExtension", "HALSIM_InitExtension_$name")
}
project(':hal').addHalDependency(it, 'shared')
if (project.hasProperty('includeNtCore')) {
lib project: ':ntcore', library: 'ntcore', linkage: 'shared'