diff --git a/server/envs/generate_user_env.sh b/server/envs/generate_user_env.sh index be844d9a..de89f16b 100755 --- a/server/envs/generate_user_env.sh +++ b/server/envs/generate_user_env.sh @@ -67,4 +67,8 @@ echo "XCTOOLCHAIN_PATH=${PLATFORMSDK_DIR}/XcodeDefault${XCODE_16_VERSION}.xctool echo "PATH=\"${APPENDED_PATH}\"" >> $OUTPUT_FILE +echo ";DM_DEBUG_COMMANDS=1" >> $OUTPUT_FILE +echo ";DYNAMO_HOME=" >> $OUTPUT_FILE +echo ";DM_DEBUG_KEEP_JOB_FOLDER=1" >> $OUTPUT_FILE + echo "Generation completed." diff --git a/server/src/main/java/com/defold/extender/ExtenderUtil.java b/server/src/main/java/com/defold/extender/ExtenderUtil.java index 50dfa8f4..7d7ea5f9 100644 --- a/server/src/main/java/com/defold/extender/ExtenderUtil.java +++ b/server/src/main/java/com/defold/extender/ExtenderUtil.java @@ -560,26 +560,32 @@ private static class PruneMapping { } }; + private static List MAPPINGS = List.of( + new PruneMapping("libs", "includeLibs", "excludeLibs"), + new PruneMapping("engineLibs", "includeLibs", "excludeLibs"), + new PruneMapping("engineJsLibs", "includeJsLibs", "excludeJsLibs"), + new PruneMapping("objectFiles", "includeObjectFiles", "excludeObjectFiles"), + new PruneMapping("dynamicLibs", "includeDynamicLibs", "excludeDynamicLibs"), + new PruneMapping("symbols", "includeSymbols", "excludeSymbols"), + // if applied manifest contains 'symbols' which were excluded before - need update 'excludeSymbols' list + // because depends on that list we defined which extension to build and which symbols should be included into + // result binary + new PruneMapping("excludeSymbols", "", "symbols"), + new PruneMapping("frameworks", "includeFrameworks", "excludeFrameworks") + ); + // Copies the original context, and appends the extra context's elements, if the keys and types are valid static public Map mergeContexts(Map a, Map b) throws ExtenderException { Map context = mergeMaps(a, b); - List mappings = new ArrayList<>(); - mappings.add(new PruneMapping("libs", "includeLibs", "excludeLibs")); - mappings.add(new PruneMapping("engineLibs", "includeLibs", "excludeLibs")); - mappings.add(new PruneMapping("engineJsLibs", "includeJsLibs", "excludeJsLibs")); - mappings.add(new PruneMapping("objectFiles", "includeObjectFiles", "excludeObjectFiles")); - mappings.add(new PruneMapping("dynamicLibs", "includeDynamicLibs", "excludeDynamicLibs")); - mappings.add(new PruneMapping("symbols", "includeSymbols", "excludeSymbols")); - - for (PruneMapping mapping : mappings) { + for (PruneMapping mapping : MAPPINGS) { List srcList = ExtenderUtil.getStringList(context, mapping.targetName); if (srcList.isEmpty()) continue; context.put(mapping.targetName, ExtenderUtil.pruneItems(srcList, - ExtenderUtil.getStringList(context, mapping.includeName), - ExtenderUtil.getStringList(context, mapping.excludeName)) ); + ExtenderUtil.getStringList(b, mapping.includeName), + ExtenderUtil.getStringList(b, mapping.excludeName)) ); } return context; } diff --git a/server/src/test/java/com/defold/extender/ExtenderUtilTest.java b/server/src/test/java/com/defold/extender/ExtenderUtilTest.java index 1e37a605..a547270a 100644 --- a/server/src/test/java/com/defold/extender/ExtenderUtilTest.java +++ b/server/src/test/java/com/defold/extender/ExtenderUtilTest.java @@ -7,6 +7,7 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -320,4 +321,31 @@ public void testWriteSourceListToTempFile() throws IOException { assertTrue(expected.containsAll(writtenLines)); assertTrue(writtenLines.containsAll(expected)); } + + @Test + public void testMergeManifests() throws IOException, ExtenderException { + AppManifestConfiguration appManifest = Extender.loadYaml(null, new File("test-data/appmanifests/app.appmanifest"), AppManifestConfiguration.class); + ManifestConfiguration ext1 = Extender.loadYaml(null, new File("test-data/appmanifests/ext1.manifest"), ManifestConfiguration.class); + ManifestConfiguration ext2 = Extender.loadYaml(null, new File("test-data/appmanifests/ext2.manifest"), ManifestConfiguration.class); + Map res = ExtenderUtil.mergeContexts(ext1.platforms.get("linux").context, ext2.platforms.get("linux").context); + res = ExtenderUtil.mergeContexts(res, appManifest.platforms.get("linux").context); + List libs = (List)res.get("libs"); + List symbols = (List)res.get("symbols"); + List excludeSymbols = (List)res.get("excludeSymbols"); + assertTrue(libs.contains("profile")); + assertTrue(libs.contains("profilerext")); + assertTrue(libs.contains("profiler_remotery")); + + assertFalse(libs.contains("profile_null")); + assertFalse(libs.contains("profilerext_null")); + assertFalse(libs.contains("record_null")); + + assertTrue(symbols.contains("ProfilerExt")); + assertTrue(symbols.contains("ProfilerBasic")); + assertTrue(symbols.contains("ProfilerRemotery")); + + assertFalse(excludeSymbols.contains("ProfilerExt")); + assertFalse(excludeSymbols.contains("ProfilerBasic")); + assertFalse(excludeSymbols.contains("ProfilerRemotery")); + } } diff --git a/server/test-data/appmanifests/app.appmanifest b/server/test-data/appmanifests/app.appmanifest new file mode 100644 index 00000000..c5f728f7 --- /dev/null +++ b/server/test-data/appmanifests/app.appmanifest @@ -0,0 +1,6 @@ +platforms: + linux: + context: + excludeLibs: ["profile_null", "profilerext_null", "record_null"] + libs: ["profile", "profilerext", "profiler_remotery"] + symbols: ['ProfilerExt', 'ProfilerBasic', 'ProfilerRemotery'] diff --git a/server/test-data/appmanifests/ext1.manifest b/server/test-data/appmanifests/ext1.manifest new file mode 100644 index 00000000..12cb63e4 --- /dev/null +++ b/server/test-data/appmanifests/ext1.manifest @@ -0,0 +1,5 @@ +platforms: + linux: + context: + libs: ["profile", "profilerext", "profiler_remotery"] + symbols: ['ProfilerExt', 'ProfilerBasic', 'ProfilerRemotery'] diff --git a/server/test-data/appmanifests/ext2.manifest b/server/test-data/appmanifests/ext2.manifest new file mode 100644 index 00000000..35adab5c --- /dev/null +++ b/server/test-data/appmanifests/ext2.manifest @@ -0,0 +1,10 @@ +platforms: + common: + context: + defines: ["DM_RELEASE"] + + linux: + context: + excludeLibs: ["engine", "engine_service", "profile", "profilerext", "profiler_remotery", "record", "vpx"] + libs: ["engine_release", "engine_service_null", "profile_null", "profilerext_null", "record_null"] + excludeSymbols: ['ProfilerExt', 'ProfilerBasic', 'ProfilerRemotery']