From c696a2bdf30cc50bdde825863dba9a3060d84ecd Mon Sep 17 00:00:00 2001 From: Christoph Hart <> Date: Thu, 23 Jan 2025 16:53:13 +0100 Subject: [PATCH] - fixed new compile dialog on macOS --- hi_backend/backend/BackendComponents.cpp | 2 + hi_backend/backend/CompileExporter.cpp | 10 +-- hi_backend/backend/CompileExporter.h | 2 +- .../backend/dialog_library/dialog_library.cpp | 64 ++++++++++++++++--- .../backend/dialog_library/dialog_library.h | 47 +++++++++++--- .../scripting/api/ScriptingApiContent.cpp | 1 + hi_tools/hi_neural/hi_neural.cpp | 4 +- 7 files changed, 104 insertions(+), 26 deletions(-) diff --git a/hi_backend/backend/BackendComponents.cpp b/hi_backend/backend/BackendComponents.cpp index d37d2db98..cd082e93f 100644 --- a/hi_backend/backend/BackendComponents.cpp +++ b/hi_backend/backend/BackendComponents.cpp @@ -369,6 +369,8 @@ multipage::EncodedDialogBase::EncodedDialogBase(BackendRootWindow* bpe_, bool ad addChildComponent(minimizeButton); + minimizeButton.setTooltip("Minimize this task to the status bar"); + minimizeButton.onClick = [this]() { findParentComponentOfClass()->minimizeModalComponent(true, state.get()); diff --git a/hi_backend/backend/CompileExporter.cpp b/hi_backend/backend/CompileExporter.cpp index d54a414e9..501efce91 100644 --- a/hi_backend/backend/CompileExporter.cpp +++ b/hi_backend/backend/CompileExporter.cpp @@ -818,7 +818,7 @@ CompileExporter::ErrorCodes CompileExporter::exportInternal(TargetTypes type, Bu setProgress(0.5); - logMessage("> Launch system compi"); + logMessage("> Launch system compiler..."); result = compileSolution(option, type, manager); @@ -1175,7 +1175,7 @@ CompileExporter::BuildOption CompileExporter::showCompilePopup(TargetTypes type) CompileExporter::ErrorCodes CompileExporter::compileSolution(BuildOption buildOption, TargetTypes types, ChildProcessManager* manager) { - BatchFileCreator::createBatchFile(this, buildOption, types, manager != nullptr); + BatchFileCreator::createBatchFile(this, buildOption, types, manager); File batchFile = BatchFileCreator::getBatchFile(this, manager); @@ -2480,13 +2480,15 @@ int CppBuilder::exportValueTreeAsCpp(const File &sourceDirectory, const File &de #define ADD_LINE(x) (batchContent << x << NewLine::getDefault()) -void CompileExporter::BatchFileCreator::createBatchFile(CompileExporter* exporter, BuildOption buildOption, TargetTypes types, bool hasChildProcessManager) +void CompileExporter::BatchFileCreator::createBatchFile(CompileExporter* exporter, BuildOption buildOption, TargetTypes types, ChildProcessManager* manager) { ModulatorSynthChain* chainToExport = exporter->chainToExport; ignoreUnused(chainToExport); - File batchFile = getBatchFile(exporter); + File batchFile = getBatchFile(exporter, manager); + auto hasChildProcessManager = manager != nullptr; + if (!exporter->shouldBeSilent() && batchFile.existsAsFile()) { if (!PresetHandler::showYesNoWindow("Batch File already found", "Do you want to rewrite the batch file for the compile process?")) diff --git a/hi_backend/backend/CompileExporter.h b/hi_backend/backend/CompileExporter.h index 20e03337c..7e57b55b8 100644 --- a/hi_backend/backend/CompileExporter.h +++ b/hi_backend/backend/CompileExporter.h @@ -257,7 +257,7 @@ class CompileExporter: public BaseExporter struct BatchFileCreator { - static void createBatchFile(CompileExporter* exporter, BuildOption buildOption, TargetTypes types, bool hasChildProcessManager=false); + static void createBatchFile(CompileExporter* exporter, BuildOption buildOption, TargetTypes types, ChildProcessManager* m=nullptr); static File getBatchFile(CompileExporter* exporter, ChildProcessManager* m=nullptr); }; diff --git a/hi_backend/backend/dialog_library/dialog_library.cpp b/hi_backend/backend/dialog_library/dialog_library.cpp index 3a67508da..bad78a5a7 100644 --- a/hi_backend/backend/dialog_library/dialog_library.cpp +++ b/hi_backend/backend/dialog_library/dialog_library.cpp @@ -926,6 +926,8 @@ CompileProjectDialog::~CompileProjectDialog() if(killFunction) killFunction(); + dialog = nullptr; + state->clearCompletedJobs(); } @@ -1025,7 +1027,7 @@ var CompileProjectDialog::onInit(const var::NativeFunctionArgs& args) if(type.isNotEmpty()) writeState("projectType", type); - setElementProperty("OutputFile", mpid::Text, getTargetFile().getFullPathName()); + refreshOutputFile(); return var(); } @@ -1062,7 +1064,7 @@ var CompileProjectDialog::onPluginType(const var::NativeFunctionArgs& args) { auto flags = getBuildFlag(); - setElementProperty("OutputFile", mpid::Text, getTargetFile().getFullPathName()); + refreshOutputFile(); if(IS_FLAG(isAAX)) { @@ -1097,29 +1099,45 @@ var CompileProjectDialog::onShowPluginFolder(const var::NativeFunctionArgs& args { auto flags = getBuildFlag(); - File folder; + +#if JUCE_WINDOWS + File folder = File::getSpecialLocation(File::SpecialLocationType::globalApplicationsDirectory); +#elif JUCE_MAC + File folder = File::getSpecialLocation(File::SpecialLocationType::commonApplicationDataDirectory).getChildFile("Audio/Plug-Ins"); +#endif + if(IS_FLAG(isVST)) { auto isVST3 = (bool)GET_HISE_SETTING(getMainController()->getMainSynthChain(), HiseSettings::Project::VST3Support); - folder = File::getSpecialLocation(File::SpecialLocationType::globalApplicationsDirectory); - +#if JUCE_WINDOWS if(isVST3) - { folder = folder.getChildFile("Common Files").getChildFile("VST3"); - } else { // not a real default folder, but hey... folder = folder.getChildFile("VSTPlugins"); } +#elif JUCE_MAC + folder = folder.getChildFile(isVST3 ? "VST3" : "VST"); +#else + // DAVID... + jassertfalse; +#endif } if(IS_FLAG(isAAX)) { - folder = File::getSpecialLocation(File::SpecialLocationType::globalApplicationsDirectory); +#if JUCE_WINDOWS folder = folder.getChildFile("Common Files").getChildFile("Avid").getChildFile("Audio").getChildFile("Plug-Ins"); +#elif JUCE_MAC + folder = File("/Library/Application Support/Avid/Audio/Plug-Ins"); +#endif } + if(IS_FLAG(isAU)) + { + folder = folder.getChildFile("Components"); + } if(folder.isDirectory()) { @@ -1166,20 +1184,46 @@ File CompileProjectDialog::getTargetFile() const if(IS_FLAG(isStandalone)) { +#if JUCE_WINDOWS auto compiledFile = binaries.getChildFile("Compiled").getChildFile("App"); return compiledFile.getChildFile(filename).withFileExtension(".exe"); +#elif JUCE_MAC + auto compiledFile = binaries.getChildFile("Compiled"); + return compiledFile.getChildFile(filename).withFileExtension(".app"); +#else + // David... + return File(); +#endif } if(IS_FLAG(isVST)) - { + { auto isVST3 = (bool)GET_HISE_SETTING(getMainController()->getMainSynthChain(), HiseSettings::Project::VST3Support); +#if JUCE_WINDOWS auto compiledFile = binaries.getChildFile("Compiled").getChildFile(isVST3 ? "VST3" : "VST"); return compiledFile.getChildFile(filename).withFileExtension(isVST3 ? ".vst3" : ".dll"); +#elif JUCE_MAC + auto compiledFile = binaries.getChildFile("Builds/MacOSX/build/Release"); + return compiledFile.getChildFile(filename).withFileExtension(isVST3 ? ".vst3" : ".vst"); +#else + // David... + return File(); +#endif } + if(IS_FLAG(isAU)) + { + auto compiledFile = binaries.getChildFile("Builds/MacOSX/build/Release"); + return compiledFile.getChildFile(filename).withFileExtension(".component"); + } if(IS_FLAG(isAAX)) { +#if JUCE_WINDOWS auto compiledFile = binaries.getChildFile("Compiled").getChildFile("AAX"); return compiledFile.getChildFile(filename).withFileExtension(".aaxplugin"); +#elif JUCE_MAC + auto compiledFile = binaries.getChildFile("Builds/MacOSX/build/Release"); + return compiledFile.getChildFile(filename).withFileExtension(".aaxplugin"); +#endif } return File(); @@ -1196,7 +1240,7 @@ var CompileProjectDialog::onExportType(const var::NativeFunctionArgs& args) setElementProperty("projectType", mpid::Enabled, !enabled); setElementProperty("pluginType", mpid::Enabled, !enabled); - setElementProperty("OutputFile", mpid::Text, getTargetFile().getFullPathName()); + refreshOutputFile(); return var(); } diff --git a/hi_backend/backend/dialog_library/dialog_library.h b/hi_backend/backend/dialog_library/dialog_library.h index 51393a851..ef9c51d21 100644 --- a/hi_backend/backend/dialog_library/dialog_library.h +++ b/hi_backend/backend/dialog_library/dialog_library.h @@ -27,15 +27,31 @@ class ChildProcessManager: public AsyncUpdater currentMessage = {}; } - void logMessage(const String& message) + void logMessage(String message) { { SimpleReadWriteLock::ScopedWriteLock sl(logLock); - if(message.contains("error")) - currentMessage << "!"; - - auto isLinkerMessage = message.contains("Generating code") || +#if JUCE_MAC + if(message.contains("[!]")) + { + message = message.fromFirstOccurrenceOf("[!]", false, false); + + auto isWarning = message.contains("[-W") || + message.contains("was built for newer macOS version"); // AAX linker warning + + if(isWarning) + currentMessage << "\t"; + else + currentMessage << "!"; + } +#elif JUCE_WINDOWS + if(message.contains("warning")) + currentMessage << "\t"; + if((message.contains("error")) + currentMessage << "!"; +#endif + auto isLinkerMessage = message.contains("Generating code") || message.contains("Linking "); if(isLinkerMessage) @@ -43,10 +59,7 @@ class ChildProcessManager: public AsyncUpdater currentMessage << "> "; setProgress(0.8); } - - if(message.contains("warning")) - currentMessage << "\t"; - + currentMessage << message; if(!message.containsChar('\n')) currentMessage << '\n'; @@ -441,6 +454,22 @@ struct CompileProjectDialog: public EncodedDialogBase, } } + void refreshOutputFile() + { + auto targetFile = getTargetFile(); + auto content = targetFile.getFullPathName(); + + auto w = GLOBAL_BOLD_FONT().getStringWidth(content); + + if(w > 480) + { + auto root = getMainController()->getActiveFileHandler()->getRootFolder(); + content = targetFile.getRelativePathFrom(root); + } + + setElementProperty("OutputFile", mpid::Text, content); + } + var onInit(const var::NativeFunctionArgs& args); var compileTask(const var::NativeFunctionArgs& args); var onExportType(const var::NativeFunctionArgs& args); diff --git a/hi_scripting/scripting/api/ScriptingApiContent.cpp b/hi_scripting/scripting/api/ScriptingApiContent.cpp index cfcc3c56a..182df2697 100644 --- a/hi_scripting/scripting/api/ScriptingApiContent.cpp +++ b/hi_scripting/scripting/api/ScriptingApiContent.cpp @@ -6171,6 +6171,7 @@ void ScriptingApi::Content::ScriptMultipageDialog::onMultipageLog(ScriptMultipag { auto p = m.getScriptProcessor()->getMainController_()->getMainSynthChain(); debugToConsole(p, message); + ignoreUnused(p); } } diff --git a/hi_tools/hi_neural/hi_neural.cpp b/hi_tools/hi_neural/hi_neural.cpp index 695728fc0..c4554b13b 100644 --- a/hi_tools/hi_neural/hi_neural.cpp +++ b/hi_tools/hi_neural/hi_neural.cpp @@ -516,8 +516,6 @@ struct NAMModel: public NeuralNetwork::ModelBase #endif }; - using Dilations = wavenet::Dilations<1, 2, 4, 8, 16, 32, 64, 128, 256, 512>; - NAMModel(const var& data_): ModelBase(), jsonData(data_) @@ -564,6 +562,8 @@ struct NAMModel: public NeuralNetwork::ModelBase { return Result::fail(e.what()); } + + return Result::ok(); }; wavenet::Wavenet_Model