From 2a09f6fa45ad3eb2e377a1c64bcde3a166222af6 Mon Sep 17 00:00:00 2001 From: Prateek Machiraju Date: Sun, 6 Jun 2021 10:19:02 -0400 Subject: [PATCH] [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. --- shared/plugins/setupBuild.gradle | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/shared/plugins/setupBuild.gradle b/shared/plugins/setupBuild.gradle index af9b4c409b..0c4f1acfdf 100644 --- a/shared/plugins/setupBuild.gradle +++ b/shared/plugins/setupBuild.gradle @@ -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'