aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiguel Costa <miguel.costa@qt.io>2025-11-26 18:54:20 +0100
committerMiguel Costa <miguel.costa@qt.io>2025-11-28 15:17:00 +0000
commit5d79412eb4b9102052ff9552765c8c8ae1c4bef0 (patch)
treec6a793e28fb6e42696b8bfcb26c5fed19d4da13d
parent5719c13424cc735f4c5c96746818c4407c5cc1a8 (diff)
Add macro to embed assembly name in native host
Change-Id: I532c6feb15eaba7aa41432dc25a8a625f89f4cc8 Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
-rw-r--r--include/qdotnethost.h10
-rw-r--r--src/Qt.DotNet.GenerationRules/Qt/DotNet/CodeGeneration/Rules/GenerateMainCpp.cs9
2 files changed, 11 insertions, 8 deletions
diff --git a/include/qdotnethost.h b/include/qdotnethost.h
index 2a3fa98..6be7d32 100644
--- a/include/qdotnethost.h
+++ b/include/qdotnethost.h
@@ -481,3 +481,13 @@ private:
load_assembly_fn fnLoadAssembly = nullptr;
get_function_pointer_fn fnGetFunctionPointer = nullptr;
};
+
+#define EMBED_HASH_HI_PART_UTF8 "c3ab8ff13720e8ad9047dd39466b3c89"
+#define EMBED_HASH_LO_PART_UTF8 "74e592c2fa383d4a3960714caef0c4f2"
+#define EMBED_HASH_FULL_UTF8 (EMBED_HASH_HI_PART_UTF8 EMBED_HASH_LO_PART_UTF8)
+#define QT_DOTNET_HOST(appName) \
+constexpr int EMBED_SZ = sizeof(EMBED_HASH_FULL_UTF8) / sizeof(EMBED_HASH_FULL_UTF8[0]); \
+constexpr int EMBED_MAX = (EMBED_SZ > 1025 ? EMBED_SZ : 1025); \
+static char appName[EMBED_MAX] = EMBED_HASH_FULL_UTF8; \
+static const char hi_part[] = EMBED_HASH_HI_PART_UTF8; \
+static const char lo_part[] = EMBED_HASH_LO_PART_UTF8
diff --git a/src/Qt.DotNet.GenerationRules/Qt/DotNet/CodeGeneration/Rules/GenerateMainCpp.cs b/src/Qt.DotNet.GenerationRules/Qt/DotNet/CodeGeneration/Rules/GenerateMainCpp.cs
index d3219ca..53bef0d 100644
--- a/src/Qt.DotNet.GenerationRules/Qt/DotNet/CodeGeneration/Rules/GenerateMainCpp.cs
+++ b/src/Qt.DotNet.GenerationRules/Qt/DotNet/CodeGeneration/Rules/GenerateMainCpp.cs
@@ -45,14 +45,7 @@ namespace Qt.DotNet.CodeGeneration.Rules
}
]}
-#define EMBED_HASH_HI_PART_UTF8 ""c3ab8ff13720e8ad9047dd39466b3c89""
-#define EMBED_HASH_LO_PART_UTF8 ""74e592c2fa383d4a3960714caef0c4f2""
-#define EMBED_HASH_FULL_UTF8 (EMBED_HASH_HI_PART_UTF8 EMBED_HASH_LO_PART_UTF8)
-constexpr int EMBED_SZ = sizeof(EMBED_HASH_FULL_UTF8) / sizeof(EMBED_HASH_FULL_UTF8[0]);
-constexpr int EMBED_MAX = (EMBED_SZ > 1025 ? EMBED_SZ : 1025);
-static char appName[EMBED_MAX] = EMBED_HASH_FULL_UTF8;
-static const char hi_part[] = EMBED_HASH_HI_PART_UTF8;
-static const char lo_part[] = EMBED_HASH_LO_PART_UTF8;
+QT_DOTNET_HOST(appName);
int main(int argc, char *argv[])
{{