Skip to content

Commit 1a9e97e

Browse files
committed
feat: support multi recipe builds
1 parent e83ffab commit 1a9e97e

File tree

3 files changed

+83
-42
lines changed

3 files changed

+83
-42
lines changed

Editor/EcsactBuild.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -295,17 +295,23 @@ public static void Build(Options options) {
295295
}
296296

297297
proc.StartInfo.Arguments += " ";
298-
proc.StartInfo.Arguments += "--recipe=\"";
299298

300299
if(_settings.ecsactBuildEnabled) {
301-
if(!string.IsNullOrEmpty(_settings.recipePath)) {
302-
var recipeFullPath = Path.GetFullPath(_settings.recipePath);
303-
proc.StartInfo.Arguments += recipeFullPath;
304-
proc.StartInfo.Arguments += "\" ";
305-
} else {
306-
UnityEngine.Debug.LogError(
307-
"A recipe path hasn't been given in Ecsact Build Settings"
308-
);
300+
foreach(var recipe in _settings.recipes) {
301+
if(!string.IsNullOrEmpty(recipe)) {
302+
proc.StartInfo.Arguments += " --recipe=\"";
303+
var recipeFullPath = Path.GetFullPath(recipe);
304+
if(File.Exists(recipeFullPath)) {
305+
proc.StartInfo.Arguments += recipeFullPath;
306+
} else {
307+
proc.StartInfo.Arguments += recipe;
308+
}
309+
proc.StartInfo.Arguments += "\" ";
310+
} else {
311+
UnityEngine.Debug.LogError(
312+
"A recipe path hasn't been given in Ecsact Build Settings"
313+
);
314+
}
309315
}
310316
}
311317

Editor/EcsactBuildSettings.uxml

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
2-
<ui:VisualElement>
3-
<ui:TextField picking-mode="Ignore" label="Runtime Output Path" value="Assets/Plugins/EcsactRuntime" text="Assets/Plugins/EcsactRuntime" multiline="false" binding-path="runtimeBuilderOutputPath" />
4-
<ui:VisualElement tooltip="Generated runtime dynamic library for Windows" style="flex-direction: row;">
5-
<ui:Label text="Assets/Plugins/EcsactRuntime" display-tooltip-when-elided="true" binding-path="runtimeBuilderOutputPath" style="padding-left: 160px; font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-right: 0;" />
6-
<ui:Label text=".dll" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
7-
</ui:VisualElement>
8-
<ui:VisualElement tooltip="Generated runtime dynamic library for macOS" style="flex-direction: row;">
9-
<ui:Label text="Assets/Plugins/EcsactRuntime" display-tooltip-when-elided="true" binding-path="runtimeBuilderOutputPath" style="padding-left: 160px; font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-right: 0;" />
10-
<ui:Label text=".dylib" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
11-
</ui:VisualElement>
12-
<ui:VisualElement tooltip="Generated runtime dynamic library for Linux" style="flex-direction: row;">
13-
<ui:Label text="Assets/Plugins/EcsactRuntime" display-tooltip-when-elided="true" binding-path="runtimeBuilderOutputPath" style="padding-left: 160px; font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-right: 0;" />
14-
<ui:Label text=".so" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
15-
</ui:VisualElement>
16-
<ui:VisualElement tooltip="Generated runtime dynamic library for WebAssembly platforms" style="flex-direction: row;">
17-
<ui:Label text="Assets/Plugins/EcsactRuntime" display-tooltip-when-elided="true" binding-path="runtimeBuilderOutputPath" style="padding-left: 160px; font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-right: 0;" />
18-
<ui:Label text=".wasm" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
19-
</ui:VisualElement>
20-
<ui:Toggle label="Debug" binding-path="runtimeBuilderDebugBuild" />
21-
<ui:Toggle label="Log Stderr" binding-path="runtimeBuilderPrintSubcommandStderr" />
22-
<ui:Toggle label="Log Stdout" binding-path="runtimeBuilderPrintSubcommandStdout" />
23-
<ui:TextField picking-mode="Ignore" label="Compiler Path" multiline="false" binding-path="runtimeBuilderCompilerPath" />
24-
<ui:DropdownField label="Recipes" index="0" name="Recipes" binding-path="recipePath" />
25-
<ui:TextField picking-mode="Ignore" label="Temp Directory" multiline="false" binding-path="runtimeBuilderTempDirectory" />
26-
</ui:VisualElement>
27-
</ui:UXML>
1+
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
2+
<ui:VisualElement>
3+
<ui:TextField picking-mode="Ignore" label="Runtime Output Path" value="Assets/Plugins/EcsactRuntime" text="Assets/Plugins/EcsactRuntime" multiline="false" binding-path="runtimeBuilderOutputPath" />
4+
<ui:VisualElement tooltip="Generated runtime dynamic library for Windows" style="flex-direction: row;">
5+
<ui:Label text="Assets/Plugins/EcsactRuntime" display-tooltip-when-elided="true" binding-path="runtimeBuilderOutputPath" style="padding-left: 160px; font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-right: 0;" />
6+
<ui:Label text=".dll" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
7+
</ui:VisualElement>
8+
<ui:VisualElement tooltip="Generated runtime dynamic library for macOS" style="flex-direction: row;">
9+
<ui:Label text="Assets/Plugins/EcsactRuntime" display-tooltip-when-elided="true" binding-path="runtimeBuilderOutputPath" style="padding-left: 160px; font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-right: 0;" />
10+
<ui:Label text=".dylib" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
11+
</ui:VisualElement>
12+
<ui:VisualElement tooltip="Generated runtime dynamic library for Linux" style="flex-direction: row;">
13+
<ui:Label text="Assets/Plugins/EcsactRuntime" display-tooltip-when-elided="true" binding-path="runtimeBuilderOutputPath" style="padding-left: 160px; font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-right: 0;" />
14+
<ui:Label text=".so" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
15+
</ui:VisualElement>
16+
<ui:VisualElement tooltip="Generated runtime dynamic library for WebAssembly platforms" style="flex-direction: row;">
17+
<ui:Label text="Assets/Plugins/EcsactRuntime" display-tooltip-when-elided="true" binding-path="runtimeBuilderOutputPath" style="padding-left: 160px; font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-right: 0;" />
18+
<ui:Label text=".wasm" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
19+
</ui:VisualElement>
20+
<ui:Toggle label="Debug" binding-path="runtimeBuilderDebugBuild" />
21+
<ui:Toggle label="Log Stderr" binding-path="runtimeBuilderPrintSubcommandStderr" />
22+
<ui:Toggle label="Log Stdout" binding-path="runtimeBuilderPrintSubcommandStdout" />
23+
<ui:TextField picking-mode="Ignore" label="Compiler Path" multiline="false" binding-path="runtimeBuilderCompilerPath" />
24+
<ui:ListView focusable="true" header-title="Recipes" show-border="true" show-foldout-header="true" name="Recipes" />
25+
<ui:TextField picking-mode="Ignore" label="Temp Directory" multiline="false" binding-path="runtimeBuilderTempDirectory" />
26+
</ui:VisualElement>
27+
</ui:UXML>

Editor/EcsactSettings.cs

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ class EcsactSettings : ScriptableObject {
2121
public bool runtimeBuilderDebugBuild = false;
2222
public bool runtimeBuilderPrintSubcommandStdout = false;
2323
public bool runtimeBuilderPrintSubcommandStderr = false;
24-
public string recipePath = "rt_entt";
24+
25+
public List<string> recipes = new();
2526

2627
public string runtimeBuilderCompilerPath = "";
2728

@@ -85,6 +86,7 @@ class EcsactMethodUIBindings : ScriptableObject {
8586

8687
class EcsactSettingsSettingsProvider : SettingsProvider {
8788
private static bool showMissingMethods;
89+
private static List<string> cachedRecipeList = new();
8890

8991
Editor? runtimeSettingsEditor = null;
9092
Editor? wasmRuntimeSettingsEditor = null;
@@ -328,12 +330,17 @@ VisualElement rootElement
328330
}
329331
};
330332

331-
EcsactSdk.GetRecipeBundles((recipeList) => {
332-
var dropdownField = ui.Q<DropdownField>("Recipes");
333+
var recipesList = ui.Q<ListView>("Recipes");
334+
recipesList.makeItem = MakeRecipeElement;
335+
recipesList.bindItem = BindRecipeElement;
336+
recipesList.itemsSource = cachedRecipeList;
337+
recipesList.selectionType = SelectionType.None;
338+
recipesList.RefreshItems();
333339

334-
foreach(var recipe in recipeList) {
335-
dropdownField.choices.Add(recipe);
336-
}
340+
EcsactSdk.GetRecipeBundles((recipeList) => {
341+
cachedRecipeList = recipeList;
342+
recipesList.itemsSource = cachedRecipeList;
343+
recipesList.RefreshItems();
337344
});
338345
}
339346

@@ -343,6 +350,34 @@ public override void OnDeactivate() {
343350
runtimeSettingsEditor = null;
344351
}
345352
}
353+
354+
private VisualElement MakeRecipeElement() {
355+
var toggle = new Toggle();
356+
toggle.RegisterCallback<ChangeEvent<bool>>((evt) => {
357+
var settings = EcsactSettings.GetOrCreateSettings();
358+
if(evt.newValue) {
359+
settings.recipes.Add(toggle.text);
360+
} else {
361+
settings.recipes.Remove(toggle.text);
362+
}
363+
EditorUtility.SetDirty(settings);
364+
});
365+
return toggle;
366+
}
367+
368+
private void BindRecipeElement(VisualElement element, int index) {
369+
var toggle = element as Toggle;
370+
var recipe = cachedRecipeList[index];
371+
if(recipe != null) {
372+
toggle.text = recipe;
373+
toggle.SetValueWithoutNotify(IsUsingRecipe(recipe));
374+
}
375+
}
376+
377+
private bool IsUsingRecipe(string name) {
378+
var settings = EcsactSettings.GetOrCreateSettings();
379+
return settings.recipes.Contains(name);
380+
}
346381
}
347382

348383
static class EcsactSettingsUIElementsRegister {

0 commit comments

Comments
 (0)