-
Notifications
You must be signed in to change notification settings - Fork 24
Change how contexts are merged #811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -560,26 +560,32 @@ private static class PruneMapping { | |
| } | ||
| }; | ||
|
|
||
| private static List<PruneMapping> MAPPINGS = List.of( | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create list once instead of every call 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"), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added reverse mapping because we need to exclude symbols from |
||
| new PruneMapping("frameworks", "includeFrameworks", "excludeFrameworks") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added missed definition for |
||
| ); | ||
|
|
||
| // 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), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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<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")); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❤️ |
||
| } | ||
| 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'] |
| 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'] |
| 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'] |
There was a problem hiding this comment.
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.envfor future debugging.