Skip to content

Commit

Permalink
feat: support multi recipe builds
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy committed Feb 1, 2025
1 parent e83ffab commit 1a9e97e
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 42 deletions.
24 changes: 15 additions & 9 deletions Editor/EcsactBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,17 +295,23 @@ public static void Build(Options options) {
}

proc.StartInfo.Arguments += " ";
proc.StartInfo.Arguments += "--recipe=\"";

if(_settings.ecsactBuildEnabled) {
if(!string.IsNullOrEmpty(_settings.recipePath)) {
var recipeFullPath = Path.GetFullPath(_settings.recipePath);
proc.StartInfo.Arguments += recipeFullPath;
proc.StartInfo.Arguments += "\" ";
} else {
UnityEngine.Debug.LogError(
"A recipe path hasn't been given in Ecsact Build Settings"
);
foreach(var recipe in _settings.recipes) {
if(!string.IsNullOrEmpty(recipe)) {
proc.StartInfo.Arguments += " --recipe=\"";
var recipeFullPath = Path.GetFullPath(recipe);
if(File.Exists(recipeFullPath)) {
proc.StartInfo.Arguments += recipeFullPath;
} else {
proc.StartInfo.Arguments += recipe;
}
proc.StartInfo.Arguments += "\" ";
} else {
UnityEngine.Debug.LogError(
"A recipe path hasn't been given in Ecsact Build Settings"
);
}
}
}

Expand Down
54 changes: 27 additions & 27 deletions Editor/EcsactBuildSettings.uxml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
<ui:VisualElement>
<ui:TextField picking-mode="Ignore" label="Runtime Output Path" value="Assets/Plugins/EcsactRuntime" text="Assets/Plugins/EcsactRuntime" multiline="false" binding-path="runtimeBuilderOutputPath" />
<ui:VisualElement tooltip="Generated runtime dynamic library for Windows" style="flex-direction: row;">
<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;" />
<ui:Label text=".dll" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
</ui:VisualElement>
<ui:VisualElement tooltip="Generated runtime dynamic library for macOS" style="flex-direction: row;">
<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;" />
<ui:Label text=".dylib" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
</ui:VisualElement>
<ui:VisualElement tooltip="Generated runtime dynamic library for Linux" style="flex-direction: row;">
<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;" />
<ui:Label text=".so" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
</ui:VisualElement>
<ui:VisualElement tooltip="Generated runtime dynamic library for WebAssembly platforms" style="flex-direction: row;">
<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;" />
<ui:Label text=".wasm" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
</ui:VisualElement>
<ui:Toggle label="Debug" binding-path="runtimeBuilderDebugBuild" />
<ui:Toggle label="Log Stderr" binding-path="runtimeBuilderPrintSubcommandStderr" />
<ui:Toggle label="Log Stdout" binding-path="runtimeBuilderPrintSubcommandStdout" />
<ui:TextField picking-mode="Ignore" label="Compiler Path" multiline="false" binding-path="runtimeBuilderCompilerPath" />
<ui:DropdownField label="Recipes" index="0" name="Recipes" binding-path="recipePath" />
<ui:TextField picking-mode="Ignore" label="Temp Directory" multiline="false" binding-path="runtimeBuilderTempDirectory" />
</ui:VisualElement>
</ui:UXML>
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
<ui:VisualElement>
<ui:TextField picking-mode="Ignore" label="Runtime Output Path" value="Assets/Plugins/EcsactRuntime" text="Assets/Plugins/EcsactRuntime" multiline="false" binding-path="runtimeBuilderOutputPath" />
<ui:VisualElement tooltip="Generated runtime dynamic library for Windows" style="flex-direction: row;">
<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;" />
<ui:Label text=".dll" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
</ui:VisualElement>
<ui:VisualElement tooltip="Generated runtime dynamic library for macOS" style="flex-direction: row;">
<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;" />
<ui:Label text=".dylib" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
</ui:VisualElement>
<ui:VisualElement tooltip="Generated runtime dynamic library for Linux" style="flex-direction: row;">
<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;" />
<ui:Label text=".so" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
</ui:VisualElement>
<ui:VisualElement tooltip="Generated runtime dynamic library for WebAssembly platforms" style="flex-direction: row;">
<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;" />
<ui:Label text=".wasm" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
</ui:VisualElement>
<ui:Toggle label="Debug" binding-path="runtimeBuilderDebugBuild" />
<ui:Toggle label="Log Stderr" binding-path="runtimeBuilderPrintSubcommandStderr" />
<ui:Toggle label="Log Stdout" binding-path="runtimeBuilderPrintSubcommandStdout" />
<ui:TextField picking-mode="Ignore" label="Compiler Path" multiline="false" binding-path="runtimeBuilderCompilerPath" />
<ui:ListView focusable="true" header-title="Recipes" show-border="true" show-foldout-header="true" name="Recipes" />
<ui:TextField picking-mode="Ignore" label="Temp Directory" multiline="false" binding-path="runtimeBuilderTempDirectory" />
</ui:VisualElement>
</ui:UXML>
47 changes: 41 additions & 6 deletions Editor/EcsactSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class EcsactSettings : ScriptableObject {
public bool runtimeBuilderDebugBuild = false;
public bool runtimeBuilderPrintSubcommandStdout = false;
public bool runtimeBuilderPrintSubcommandStderr = false;
public string recipePath = "rt_entt";

public List<string> recipes = new();

public string runtimeBuilderCompilerPath = "";

Expand Down Expand Up @@ -85,6 +86,7 @@ class EcsactMethodUIBindings : ScriptableObject {

class EcsactSettingsSettingsProvider : SettingsProvider {
private static bool showMissingMethods;
private static List<string> cachedRecipeList = new();

Editor? runtimeSettingsEditor = null;
Editor? wasmRuntimeSettingsEditor = null;
Expand Down Expand Up @@ -328,12 +330,17 @@ VisualElement rootElement
}
};

EcsactSdk.GetRecipeBundles((recipeList) => {
var dropdownField = ui.Q<DropdownField>("Recipes");
var recipesList = ui.Q<ListView>("Recipes");
recipesList.makeItem = MakeRecipeElement;
recipesList.bindItem = BindRecipeElement;
recipesList.itemsSource = cachedRecipeList;
recipesList.selectionType = SelectionType.None;
recipesList.RefreshItems();

foreach(var recipe in recipeList) {
dropdownField.choices.Add(recipe);
}
EcsactSdk.GetRecipeBundles((recipeList) => {
cachedRecipeList = recipeList;
recipesList.itemsSource = cachedRecipeList;
recipesList.RefreshItems();
});
}

Expand All @@ -343,6 +350,34 @@ public override void OnDeactivate() {
runtimeSettingsEditor = null;
}
}

private VisualElement MakeRecipeElement() {
var toggle = new Toggle();
toggle.RegisterCallback<ChangeEvent<bool>>((evt) => {
var settings = EcsactSettings.GetOrCreateSettings();
if(evt.newValue) {
settings.recipes.Add(toggle.text);
} else {
settings.recipes.Remove(toggle.text);
}
EditorUtility.SetDirty(settings);
});
return toggle;
}

private void BindRecipeElement(VisualElement element, int index) {
var toggle = element as Toggle;
var recipe = cachedRecipeList[index];
if(recipe != null) {
toggle.text = recipe;
toggle.SetValueWithoutNotify(IsUsingRecipe(recipe));
}
}

private bool IsUsingRecipe(string name) {
var settings = EcsactSettings.GetOrCreateSettings();
return settings.recipes.Contains(name);
}
}

static class EcsactSettingsUIElementsRegister {
Expand Down

0 comments on commit 1a9e97e

Please sign in to comment.