Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions server/envs/generate_user_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated changes. Just add commented lines to result user.env for future debugging.

echo ";DYNAMO_HOME=" >> $OUTPUT_FILE
echo ";DM_DEBUG_KEEP_JOB_FOLDER=1" >> $OUTPUT_FILE

echo "Generation completed."
28 changes: 17 additions & 11 deletions server/src/main/java/com/defold/extender/ExtenderUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -560,26 +560,32 @@ private static class PruneMapping {
}
};

private static List<PruneMapping> MAPPINGS = List.of(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create list once instead of every call of mergeContexts

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"),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added reverse mapping because we need to exclude symbols from excludeSymbols list in case if next manifest contains values in symbols list.

new PruneMapping("frameworks", "includeFrameworks", "excludeFrameworks")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added missed definition for frameworks

);

// Copies the original context, and appends the extra context's elements, if the keys and types are valid
static public Map<String, Object> mergeContexts(Map<String, Object> a, Map<String, Object> b) throws ExtenderException {
Map<String, Object> context = mergeMaps(a, b);

List<PruneMapping> 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<String> 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),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main fix: apply prune mappings only from applied context, not from merged and accumulated context.

ExtenderUtil.getStringList(b, mapping.excludeName)) );
}
return context;
}
Expand Down
28 changes: 28 additions & 0 deletions server/src/test/java/com/defold/extender/ExtenderUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, Object> res = ExtenderUtil.mergeContexts(ext1.platforms.get("linux").context, ext2.platforms.get("linux").context);
res = ExtenderUtil.mergeContexts(res, appManifest.platforms.get("linux").context);
List<String> libs = (List<String>)res.get("libs");
List<String> symbols = (List<String>)res.get("symbols");
List<String> excludeSymbols = (List<String>)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"));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

}
6 changes: 6 additions & 0 deletions server/test-data/appmanifests/app.appmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
platforms:
linux:
context:
excludeLibs: ["profile_null", "profilerext_null", "record_null"]
libs: ["profile", "profilerext", "profiler_remotery"]
symbols: ['ProfilerExt', 'ProfilerBasic', 'ProfilerRemotery']
5 changes: 5 additions & 0 deletions server/test-data/appmanifests/ext1.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
platforms:
linux:
context:
libs: ["profile", "profilerext", "profiler_remotery"]
symbols: ['ProfilerExt', 'ProfilerBasic', 'ProfilerRemotery']
10 changes: 10 additions & 0 deletions server/test-data/appmanifests/ext2.manifest
Original file line number Diff line number Diff line change
@@ -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']