diff --git a/Source/Heavy/CppExporter.h b/Source/Heavy/CppExporter.h index a6cc5933e5..7de7c76e0e 100644 --- a/Source/Heavy/CppExporter.h +++ b/Source/Heavy/CppExporter.h @@ -29,35 +29,37 @@ class CppExporter final : public ExporterBase { projectCopyrightValue = tree.getProperty("projectCopyrightValue"); } - bool performExport(String pdPatch, String const outdir, String name, String const copyright, StringArray searchPaths) override + bool performExport(String const& pdPatch, String const& outdir, String const& name, String const& copyright, StringArray const& searchPaths) override { exportingView->showState(ExportingProgressView::Exporting); - StringArray args = { heavyExecutable.getFullPathName(), pdPatch, "-o" + outdir }; +#if JUCE_WINDOWS + auto const heavyPath = heavyExecutable.getFullPathName().replaceCharacter('\\', '/'); +#else + auto const heavyPath = heavyExecutable.getFullPathName(); +#endif + StringArray args = { heavyPath.quoted(), pdPatch.quoted(), "-o", outdir.quoted() }; - name = name.replaceCharacter('-', '_'); args.add("-n" + name); if (copyright.isNotEmpty()) { args.add("--copyright"); - args.add("\"" + copyright + "\""); + args.add(copyright.quoted()); } args.add("-v"); - String paths = "-p"; + args.add("-p"); for (auto& path : searchPaths) { - paths += " " + path; + args.add(path); } - args.add(paths); - if (shouldQuit) return true; - auto compileString = args.joinIntoString(" "); - exportingView->logToConsole("Command: " + compileString + "\n"); - start(compileString); + auto const command = args.joinIntoString(" "); + exportingView->logToConsole("Command: " + command + "\n"); + Toolchain::startShellScript(command, this); waitForProcessToFinish(-1); exportingView->flushConsole(); diff --git a/Source/Heavy/DPFExporter.h b/Source/Heavy/DPFExporter.h index d1811995a4..4c0abcf597 100644 --- a/Source/Heavy/DPFExporter.h +++ b/Source/Heavy/DPFExporter.h @@ -132,18 +132,22 @@ class DPFExporter final : public ExporterBase { } } - bool performExport(String pdPatch, String outdir, String name, String copyright, StringArray searchPaths) override + bool performExport(String const& pdPatch, String const& outdir, String const& name, String const& copyright, StringArray const& searchPaths) override { exportingView->showState(ExportingProgressView::Exporting); - StringArray args = { heavyExecutable.getFullPathName(), pdPatch, "-o" + outdir }; +#if JUCE_WINDOWS + auto const heavyPath = heavyExecutable.getFullPathName().replaceCharacter('\\', '/'); +#else + auto const heavyPath = heavyExecutable.getFullPathName(); +#endif + StringArray args = { heavyPath.quoted(), pdPatch.quoted(), "-o", outdir.quoted() }; - name = name.replaceCharacter('-', '_'); args.add("-n" + name); if (copyright.isNotEmpty()) { args.add("--copyright"); - args.add("\"" + copyright + "\""); + args.add(copyright.quoted()); } auto makerName = getValue(makerNameValue); @@ -211,19 +215,17 @@ class DPFExporter final : public ExporterBase { args.add("-v"); args.add("-gdpf"); - String paths = "-p"; + args.add("-p"); for (auto& path : searchPaths) { - paths += " " + path; + args.add(path); } - args.add(paths); - if (shouldQuit) return true; - auto compileString = args.joinIntoString(" "); - exportingView->logToConsole("Command: " + compileString + "\n"); - start(compileString); + auto const command = args.joinIntoString(" "); + exportingView->logToConsole("Command: " + command + "\n"); + Toolchain::startShellScript(command, this); waitForProcessToFinish(-1); exportingView->flushConsole(); @@ -268,8 +270,8 @@ class DPFExporter final : public ExporterBase { auto path = "export PATH=\"$PATH:" + Toolchain::dir.getChildFile("bin").getFullPathName().replaceCharacter('\\', '/') + "\"\n"; auto cc = "CC=" + Toolchain::dir.getChildFile("bin").getChildFile("gcc.exe").getFullPathName().replaceCharacter('\\', '/') + " "; auto cxx = "CXX=" + Toolchain::dir.getChildFile("bin").getChildFile("g++.exe").getFullPathName().replaceCharacter('\\', '/') + " "; - - Toolchain::startShellScript(path + cc + cxx + make.getFullPathName().replaceCharacter('\\', '/') + " -j4 -f " + makefile.getFullPathName().replaceCharacter('\\', '/'), this); + auto shell = " SHELL=" + Toolchain::dir.getChildFile("bin").getChildFile("bash.exe").getFullPathName().replaceCharacter('\\', '/').quoted(); + Toolchain::startShellScript(path + cc + cxx + make.getFullPathName().replaceCharacter('\\', '/') + " -j4 -f " + makefile.getFullPathName().replaceCharacter('\\', '/') + shell, this); #else // Linux or BSD auto prepareEnvironmentScript = Toolchain::dir.getChildFile("scripts").getChildFile("anywhere-setup.sh").getFullPathName() + "\n"; diff --git a/Source/Heavy/DaisyExporter.h b/Source/Heavy/DaisyExporter.h index e740ced55f..4e1731f9a5 100644 --- a/Source/Heavy/DaisyExporter.h +++ b/Source/Heavy/DaisyExporter.h @@ -237,7 +237,7 @@ class DaisyExporter final : public ExporterBase { return getExitCode(); } - bool performExport(String pdPatch, String outdir, String name, String copyright, StringArray searchPaths) override + bool performExport(String const& pdPatch, String const& outdir, String const& name, String const& copyright, StringArray const& searchPaths) override { auto target = getValue(targetBoardValue) - 1; bool compile = getValue(exportTypeValue) - 1; @@ -248,15 +248,19 @@ class DaisyExporter final : public ExporterBase { auto rate = getValue(samplerateValue) - 1; auto size = getValue(patchSizeValue); auto appType = getValue(appTypeValue); + +#if JUCE_WINDOWS + auto const heavyPath = heavyExecutable.getFullPathName().replaceCharacter('\\', '/'); +#else + auto const heavyPath = heavyExecutable.getFullPathName(); +#endif + StringArray args = { heavyPath.quoted(), pdPatch.quoted(), "-o", outdir.quoted() }; - StringArray args = { heavyExecutable.getFullPathName(), pdPatch, "-o" + outdir }; - - name = name.replaceCharacter('-', '_'); args.add("-n" + name); if (copyright.isNotEmpty()) { args.add("--copyright"); - args.add("\"" + copyright + "\""); + args.add(copyright.quoted()); } // set board definition @@ -331,21 +335,19 @@ class DaisyExporter final : public ExporterBase { metaJson->setProperty("daisy", metaDaisy); auto metaJsonFile = createMetaJson(metaJson); - args.add("-m" + metaJsonFile.getFullPathName()); + args.add("-m" + metaJsonFile.getFullPathName().quoted()); args.add("-v"); args.add("-gdaisy"); - String paths = "-p"; + args.add("-p"); for (auto& path : searchPaths) { - paths += " " + path; + args.add(path); } - args.add(paths); - - auto compileString = args.joinIntoString(" "); - exportingView->logToConsole("Command: " + compileString + "\n"); - start(compileString); + auto const command = args.joinIntoString(" "); + exportingView->logToConsole("Command: " + command + "\n"); + Toolchain::startShellScript(command, this); waitForProcessToFinish(-1); exportingView->flushConsole(); @@ -385,7 +387,8 @@ class DaisyExporter final : public ExporterBase { #if JUCE_WINDOWS auto buildScript = make.getFullPathName().replaceCharacter('\\', '/') + " -j4 -f " - + sourceDir.getChildFile("Makefile").getFullPathName().replaceCharacter('\\', '/') + + sourceDir.getChildFile("Makefile").getFullPathName().replaceCharacter('\\', '/').quoted() + + " SHELL=" + Toolchain::dir.getChildFile("bin").getChildFile("bash.exe").getFullPathName().replaceCharacter('\\', '/').quoted() + " GCC_PATH=" + gccPath.replaceCharacter('\\', '/') + " PROJECT_NAME=" + name; @@ -393,7 +396,7 @@ class DaisyExporter final : public ExporterBase { Toolchain::startShellScript(buildScript, this); #else String buildScript = make.getFullPathName() - + " -j4 -f " + sourceDir.getChildFile("Makefile").getFullPathName() + + " -j4 -f " + sourceDir.getChildFile("Makefile").getFullPathName().quoted() + " GCC_PATH=" + gccPath + " PROJECT_NAME=" + name; diff --git a/Source/Heavy/ExporterBase.h b/Source/Heavy/ExporterBase.h index aecf878ed3..3bd2b82bc5 100644 --- a/Source/Heavy/ExporterBase.h +++ b/Source/Heavy/ExporterBase.h @@ -127,8 +127,14 @@ struct ExporterBase : public Component void startExport(File const& outDir) { +#if JUCE_WINDOWS + auto const patchPath = patchFile.getFullPathName().replaceCharacter('\\', '/'); + auto const& outPath = outDir.getFullPathName().replaceCharacter('\\', '/'); +#else auto patchPath = patchFile.getFullPathName(); auto const& outPath = outDir.getFullPathName(); +#endif + auto projectTitle = projectNameValue.toString(); auto projectCopyright = projectCopyrightValue.toString(); @@ -138,10 +144,18 @@ struct ExporterBase : public Component else projectTitle = "Untitled"; } + projectTitle = projectTitle.replaceCharacter('-', '_'); // Add original file location to search paths - auto searchPaths = StringArray { realPatchFile.getParentDirectory().getFullPathName() }; - + auto searchPaths = StringArray {}; + if (realPatchFile.existsAsFile() && !realPatchFile.isRoot()) // Make sure file actually exists + { +#if JUCE_WINDOWS + searchPaths.add(realPatchFile.getParentDirectory().getFullPathName().replaceCharacter('\\', '/').quoted()); +#else + searchPaths.add(realPatchFile.getParentDirectory().getFullPathName().quoted()); +#endif + } editor->pd->setThis(); // Get pd's search paths @@ -149,22 +163,16 @@ struct ExporterBase : public Component int numItems; pd::Interface::getSearchPaths(paths, &numItems); - if (realPatchFile.existsAsFile()) { - searchPaths.add(realPatchFile.getParentDirectory().getFullPathName()); - } - for (int i = 0; i < numItems; i++) { - searchPaths.add(paths[i]); + searchPaths.add(String(paths[i]).quoted()); } // Make sure we don't add the file location twice searchPaths.removeDuplicates(false); - addJob([this, patchPath, outPath, projectTitle, projectCopyright, searchPaths]() mutable { exportingView->monitorProcessOutput(this); - exportingView->showState(ExportingProgressView::Exporting); - + auto const result = performExport(patchPath, outPath, projectTitle, projectCopyright, searchPaths); if (shouldQuit) @@ -223,5 +231,5 @@ struct ExporterBase : public Component } private: - virtual bool performExport(String pdPatch, String outdir, String name, String copyright, StringArray searchPaths) = 0; + virtual bool performExport(String const& pdPatch, String const& outdir, String const& name, String const& copyright, StringArray const& searchPaths) = 0; }; diff --git a/Source/Heavy/OWLExporter.h b/Source/Heavy/OWLExporter.h index 11ac73ea63..63bb1b7ac6 100644 --- a/Source/Heavy/OWLExporter.h +++ b/Source/Heavy/OWLExporter.h @@ -86,7 +86,7 @@ class OWLExporter : public ExporterBase { storeSlotProperty->setEnabled(exportType == 4); } - bool performExport(String pdPatch, String outdir, String name, String copyright, StringArray searchPaths) override + bool performExport(String const& pdPatch, String const& outdir, String const& name, String const& copyright, StringArray const& searchPaths) override { auto target = getValue(targetBoardValue); bool compile = getValue(exportTypeValue) - 1; @@ -94,29 +94,30 @@ class OWLExporter : public ExporterBase { bool store = getValue(exportTypeValue) == 4; int slot = getValue(storeSlotValue); - StringArray args = { heavyExecutable.getFullPathName(), pdPatch, "-o" + outdir }; +#if JUCE_WINDOWS + auto const heavyPath = heavyExecutable.getFullPathName().replaceCharacter('\\', '/'); +#else + auto const heavyPath = heavyExecutable.getFullPathName(); +#endif + StringArray args = { heavyPath.quoted(), pdPatch.quoted(), "-o", outdir.quoted() }; - name = name.replaceCharacter('-', '_'); args.add("-n" + name); if (copyright.isNotEmpty()) { args.add("--copyright"); - args.add("\"" + copyright + "\""); + args.add(copyright.quoted()); } args.add("-v"); args.add("-gOWL"); - String paths = "-p"; + args.add("-p"); for (auto& path : searchPaths) { - paths += " " + path; + args.add(path); } - args.add(paths); - - auto compileString = args.joinIntoString(" "); - exportingView->logToConsole("Command: " + compileString + "\n"); - start(compileString); + exportingView->logToConsole("Command: " + args.joinIntoString(" ") + "\n"); + start(args); waitForProcessToFinish(-1); exportingView->flushConsole(); @@ -164,7 +165,8 @@ class OWLExporter : public ExporterBase { + " BUILD=../" + " PATCHNAME=" + name + " PATCHCLASS=HeavyPatch" - + " PATCHFILE=HeavyOWL_" + name + ".hpp"; + + " PATCHFILE=HeavyOWL_" + name + ".hpp" + + " SHELL=" + Toolchain::dir.getChildFile("bin").getChildFile("bash.exe").getFullPathName().replaceCharacter('\\', '/').quoted(); #else buildScript += make.getFullPathName() + " -j4" diff --git a/Source/Heavy/PdExporter.h b/Source/Heavy/PdExporter.h index 08fa7bdb2d..1eafb6486f 100644 --- a/Source/Heavy/PdExporter.h +++ b/Source/Heavy/PdExporter.h @@ -61,36 +61,38 @@ class PdExporter final : public ExporterBase { } } - bool performExport(String pdPatch, String const outdir, String name, String const copyright, StringArray searchPaths) override + bool performExport(String const& pdPatch, String const& outdir, String const &name, String const& copyright, StringArray const& searchPaths) override { exportingView->showState(ExportingProgressView::Exporting); - StringArray args = { heavyExecutable.getFullPathName(), pdPatch, "-o" + outdir }; +#if JUCE_WINDOWS + auto const heavyPath = heavyExecutable.getFullPathName().replaceCharacter('\\', '/'); +#else + auto const heavyPath = heavyExecutable.getFullPathName(); +#endif + StringArray args = { heavyPath.quoted(), pdPatch.quoted(), "-o", outdir.quoted() }; - name = name.replaceCharacter('-', '_'); args.add("-n" + name); if (copyright.isNotEmpty()) { args.add("--copyright"); - args.add("\"" + copyright + "\""); + args.add(copyright.quoted()); } args.add("-v"); args.add("-gpdext"); - String paths = "-p"; + args.add("-p"); for (auto& path : searchPaths) { - paths += " " + path; + args.add(path); } - args.add(paths); - if (shouldQuit) return true; - auto compileString = args.joinIntoString(" "); - exportingView->logToConsole("Command: " + compileString + "\n"); - start(compileString); + auto const command = args.joinIntoString(" "); + exportingView->logToConsole("Command: " + command + "\n"); + Toolchain::startShellScript(command, this); waitForProcessToFinish(-1); exportingView->flushConsole(); @@ -130,8 +132,9 @@ class PdExporter final : public ExporterBase { auto cc = "CC=" + Toolchain::dir.getChildFile("bin").getChildFile("gcc.exe").getFullPathName().replaceCharacter('\\', '/') + " "; auto cxx = "CXX=" + Toolchain::dir.getChildFile("bin").getChildFile("g++.exe").getFullPathName().replaceCharacter('\\', '/') + " "; auto pdbindir = "PDBINDIR=\"" + pdDll.getFullPathName().replaceCharacter('\\', '/') + "\" "; + auto shell = " SHELL=" + Toolchain::dir.getChildFile("bin").getChildFile("bash.exe").getFullPathName().replaceCharacter('\\', '/').quoted(); - Toolchain::startShellScript(path + cc + cxx + pdbindir + make.getFullPathName().replaceCharacter('\\', '/') + " -j4", this); + Toolchain::startShellScript(path + cc + cxx + pdbindir + make.getFullPathName().replaceCharacter('\\', '/') + " -j4" + shell, this); #else // Linux or BSD auto prepareEnvironmentScript = Toolchain::dir.getChildFile("scripts").getChildFile("anywhere-setup.sh").getFullPathName() + "\n"; diff --git a/Source/Heavy/Toolchain.h b/Source/Heavy/Toolchain.h index 203bab1248..28767609d4 100644 --- a/Source/Heavy/Toolchain.h +++ b/Source/Heavy/Toolchain.h @@ -326,11 +326,11 @@ class ToolchainInstaller final : public Component int statusCode = 0; #if JUCE_WINDOWS - String downloadSize = "1.2 GB"; + String downloadSize = "1.13 GB"; #elif JUCE_MAC - String downloadSize = "457 MB"; + String downloadSize = "460 MB"; #else - String downloadSize = "1.1 GB"; + String downloadSize = "799 MB"; #endif class ToolchainInstallerButton final : public Component { diff --git a/Source/Heavy/WASMExporter.h b/Source/Heavy/WASMExporter.h index c2e08cbe67..b37e488536 100644 --- a/Source/Heavy/WASMExporter.h +++ b/Source/Heavy/WASMExporter.h @@ -58,22 +58,21 @@ class WASMExporter : public ExporterBase { } } - bool performExport(String pdPatch, String outdir, String name, String copyright, StringArray searchPaths) override + bool performExport(String const& pdPatch, String const& outdir, String const& name, String const& copyright, StringArray const& searchPaths) override { exportingView->showState(ExportingProgressView::Exporting); -#if JUCE_WINDOWS - StringArray args = { heavyExecutable.getFullPathName().replaceCharacter('\\', '/'), pdPatch.replaceCharacter('\\', '/'), "-o" + outdir.replaceCharacter('\\', '/') }; + #if JUCE_WINDOWS + auto const heavyPath = heavyExecutable.getFullPathName().replaceCharacter('\\', '/'); #else - StringArray args = { heavyExecutable.getFullPathName(), pdPatch, "-o" + outdir }; + auto const heavyPath = heavyExecutable.getFullPathName(); #endif - - name = name.replaceCharacter('-', '_'); + StringArray args = { heavyPath.quoted(), pdPatch.quoted(), "-o", outdir.quoted() }; args.add("-n" + name); if (copyright.isNotEmpty()) { args.add("--copyright"); - args.add("\"" + copyright + "\""); + args.add(copyright.quoted()); } auto emsdkPath = getValue(emsdkPathValue); @@ -81,17 +80,11 @@ class WASMExporter : public ExporterBase { args.add("-v"); args.add("-gjs"); - String paths = "-p"; + args.add("-p"); for (auto& path : searchPaths) { -#if JUCE_WINDOWS - paths += " " + path.replaceCharacter('\\', '/'); -#else - paths += " " + path; -#endif + args.add(path); } - args.add(paths); - if (shouldQuit) return true; diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 2c0b9e65e9..01f2cafa34 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -1437,23 +1437,25 @@ void PluginProcessor::runBackupLoop() backupRunLoopInterval *= 2; // Increase the interval so we get correct timing } - if(backupLoopLock.tryEnter()) { - if(isProcessingAudio) - { - backupRunLoop.stopTimer(); - backupLoopLock.exit(); + { + ScopedTryLock const scopedTimerLock(backupLoopLock); + if(scopedTimerLock.isLocked()) { + if(isProcessingAudio) + { + backupRunLoop.stopTimer(); + return; + } + + backupRunLoop.startTimer(backupRunLoopInterval); + } + else { return; } - - backupRunLoop.startTimer(backupRunLoopInterval); - backupLoopLock.exit(); - } - else { - return; } setThis(); - if(audioLock.tryEnter()) { + ScopedTryLock const scopedAudioLock(backupLoopLock); + if(scopedAudioLock.isLocked()) { sendMessagesFromQueue(); sendParameters(); for(int i = 0; i < blocksToProcess; i++) { @@ -1461,7 +1463,6 @@ void PluginProcessor::runBackupLoop() sys_pollgui(); sched_tick_nodsp(); } - audioLock.exit(); } }