Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ file(GLOB plugdata_resources
${CMAKE_CURRENT_SOURCE_DIR}/Resources/Fonts/InterVariable.ttf
${CMAKE_CURRENT_SOURCE_DIR}/Resources/Fonts/InterRegular.ttf
${CMAKE_CURRENT_SOURCE_DIR}/Resources/Fonts/RobotoMono-Regular.ttf
${CMAKE_CURRENT_SOURCE_DIR}/Resources/Fonts/RobotoMono-Bold.ttf
${CMAKE_CURRENT_SOURCE_DIR}/Resources/Icons/plugdata_large_logo.png
${CMAKE_CURRENT_SOURCE_DIR}/Resources/Icons/plugdata_logo.png
# Generated resources
Expand Down
Binary file added Resources/Fonts/RobotoMono-Bold.ttf
Binary file not shown.
1 change: 1 addition & 0 deletions Resources/Scripts/package_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ def generate_binary_data(output_dir, file_list):
project_root + "/Resources/Fonts/InterVariable.ttf",
project_root + "/Resources/Fonts/InterRegular.ttf",
project_root + "/Resources/Fonts/RobotoMono-Regular.ttf",
project_root + "/Resources/Fonts/RobotoMono-Bold.ttf",
project_root + "/Resources/Icons/plugdata_large_logo.png",
project_root + "/Resources/Icons/plugdata_logo.png",
"Documentation.bin",
Expand Down
486 changes: 243 additions & 243 deletions Source/Constants.h

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions Source/Heavy/CppExporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ class CppExporter final : public ExporterBase {
return true;

auto const command = args.joinIntoString(" ");
exportingView->logToConsole("Command: " + command + "\n");
Toolchain::startShellScript(command, this);
startShellScript(command);

waitForProcessToFinish(-1);
exportingView->flushConsole();
Expand Down
29 changes: 14 additions & 15 deletions Source/Heavy/DPFExporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,7 @@ class DPFExporter final : public ExporterBase {
return true;

auto const command = args.joinIntoString(" ");
exportingView->logToConsole("Command: " + command + "\n");
Toolchain::startShellScript(command, this);
startShellScript(command);

waitForProcessToFinish(-1);
exportingView->flushConsole();
Expand All @@ -234,11 +233,11 @@ class DPFExporter final : public ExporterBase {
outputFile.getChildFile("hv").deleteRecursively();
outputFile.getChildFile("c").deleteRecursively();

auto const DPF = Toolchain::dir.getChildFile("lib").getChildFile("dpf");
auto const DPF = toolchainDir.getChildFile("lib").getChildFile("dpf");
DPF.copyDirectoryTo(outputFile.getChildFile("dpf"));

if (exportType == 2 || exportType == 4) {
auto const DPFGui = Toolchain::dir.getChildFile("lib").getChildFile("dpf-widgets");
auto const DPFGui = toolchainDir.getChildFile("lib").getChildFile("dpf-widgets");
DPFGui.copyDirectoryTo(outputFile.getChildFile("dpf-widgets"));
}

Expand All @@ -256,29 +255,29 @@ class DPFExporter final : public ExporterBase {

outputFile.setAsCurrentWorkingDirectory();

auto const bin = Toolchain::dir.getChildFile("bin");
auto const bin = toolchainDir.getChildFile("bin");
auto make = bin.getChildFile("make" + exeSuffix);
auto makefile = outputFile.getChildFile("Makefile");

#if JUCE_MAC
Toolchain::startShellScript("make -j4 -f " + makefile.getFullPathName(), this);
startShellScript("make -j4 -f " + makefile.getFullPathName());
#elif JUCE_WINDOWS
auto path = "export PATH=\"$PATH:" + pathToString(Toolchain::dir.getChildFile("bin")) + "\"\n";
auto cc = "CC=" + pathToString(Toolchain::dir.getChildFile("bin").getChildFile("gcc.exe")) + " ";
auto cxx = "CXX=" + pathToString(Toolchain::dir.getChildFile("bin").getChildFile("g++.exe")) + " ";
auto shell = " SHELL=" + pathToString(Toolchain::dir.getChildFile("bin").getChildFile("bash.exe")).quoted();
Toolchain::startShellScript(path + cc + cxx + pathToString(make) + " -j4 -f " + pathToString(makefile) + shell, this);
auto path = "export PATH=\"$PATH:" + pathToString(toolchainDir.getChildFile("bin")) + "\"\n";
auto cc = "CC=" + pathToString(toolchainDir.getChildFile("bin").getChildFile("gcc.exe")) + " ";
auto cxx = "CXX=" + pathToString(toolchainDir.getChildFile("bin").getChildFile("g++.exe")) + " ";
auto shell = " SHELL=" + pathToString(toolchainDir.getChildFile("bin").getChildFile("bash.exe")).quoted();
startShellScript(path + cc + cxx + pathToString(make) + " -j4 -f " + pathToString(makefile) + shell);
#else // Linux or BSD
auto prepareEnvironmentScript = pathToString(Toolchain::dir.getChildFile("scripts").getChildFile("anywhere-setup.sh")) + "\n";
auto prepareEnvironmentScript = pathToString(toolchainDir.getChildFile("scripts").getChildFile("anywhere-setup.sh")) + "\n";
auto buildScript = prepareEnvironmentScript
+ pathToString(make)
+ " -j4 -f " + pathToString(makefile);

// For some reason we need to do this again
outputFile.getChildFile("dpf").getChildFile("utils").getChildFile("generate-ttl.sh").setExecutePermission(true);
Toolchain::dir.getChildFile("scripts").getChildFile("anywhere-setup.sh").getChildFile("generate-ttl.sh").setExecutePermission(true);
toolchainDir.getChildFile("scripts").getChildFile("anywhere-setup.sh").getChildFile("generate-ttl.sh").setExecutePermission(true);

Toolchain::startShellScript(buildScript, this);
startShellScript(buildScript);
#endif

waitForProcessToFinish(-1);
Expand Down
38 changes: 21 additions & 17 deletions Source/Heavy/DaisyExporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class DaisyExporter final : public ExporterBase {

flashButton.onClick = [this] {
auto const tempFolder = File::getSpecialLocation(File::tempDirectory).getChildFile("Heavy-" + Uuid().toString().substring(10));
Toolchain::deleteTempFileLater(tempFolder);
deleteTempFileLater(tempFolder);
startExport(tempFolder);
};

Expand All @@ -82,10 +82,10 @@ class DaisyExporter final : public ExporterBase {
exportingView->monitorProcessOutput(this);
exportingView->showState(ExportingProgressView::Flashing);

auto const bin = Toolchain::dir.getChildFile("bin");
auto const bin = toolchainDir.getChildFile("bin");
auto const make = bin.getChildFile("make" + exeSuffix);
auto const& gccPath = bin.getFullPathName();
auto const sourceDir = Toolchain::dir.getChildFile("lib").getChildFile("libdaisy").getChildFile("core");
auto const sourceDir = toolchainDir.getChildFile("lib").getChildFile("libdaisy").getChildFile("core");

int const result = flashBootloader(bin, sourceDir, make, gccPath);

Expand Down Expand Up @@ -218,7 +218,7 @@ class DaisyExporter final : public ExporterBase {
+ pathToString(make) + " program-boot"
+ " GCC_PATH=" + gccPath;

Toolchain::startShellScript(bootloaderScript, this);
startShellScript(bootloaderScript);

waitForProcessToFinish(-1);
exportingView->flushConsole();
Expand Down Expand Up @@ -262,7 +262,7 @@ class DaisyExporter final : public ExporterBase {
if (board == "custom") {
metaDaisy.getDynamicObject()->setProperty("board_file", customBoardDefinition.getFullPathName());
} else if (extra_boards.contains(board)) {
metaDaisy.getDynamicObject()->setProperty("board_file", Toolchain::dir.getChildFile("etc").getChildFile(board + ".json").getFullPathName());
metaDaisy.getDynamicObject()->setProperty("board_file", toolchainDir.getChildFile("etc").getChildFile(board + ".json").getFullPathName());
} else {
metaDaisy.getDynamicObject()->setProperty("board", board);
}
Expand Down Expand Up @@ -301,15 +301,15 @@ class DaisyExporter final : public ExporterBase {
} else if (size == 3) {
metaDaisy.getDynamicObject()->setProperty(
"linker_script",
Toolchain::dir.getChildFile("etc").getChildFile("linkers").getChildFile("sram_linker_sdram.lds").getFullPathName());
toolchainDir.getChildFile("etc").getChildFile("linkers").getChildFile("sram_linker_sdram.lds").getFullPathName());
metaDaisy.getDynamicObject()->setProperty("bootloader", "BOOT_SRAM");
} else if (size == 4) {
metaDaisy.getDynamicObject()->setProperty("linker_script", "../../libdaisy/core/STM32H750IB_qspi.lds");
metaDaisy.getDynamicObject()->setProperty("bootloader", "BOOT_QSPI");
} else if (size == 5) {
metaDaisy.getDynamicObject()->setProperty(
"linker_script",
Toolchain::dir.getChildFile("etc").getChildFile("linkers").getChildFile("qspi_linker_sdram.lds").getFullPathName());
toolchainDir.getChildFile("etc").getChildFile("linkers").getChildFile("qspi_linker_sdram.lds").getFullPathName());
metaDaisy.getDynamicObject()->setProperty("bootloader", "BOOT_QSPI");
} else if (size == 6) {
metaDaisy.getDynamicObject()->setProperty("linker_script", customLinker.getFullPathName());
Expand All @@ -333,8 +333,8 @@ class DaisyExporter final : public ExporterBase {
}

auto const command = args.joinIntoString(" ");
exportingView->logToConsole("Command: " + command + "\n");
Toolchain::startShellScript(command, this);
startShellScript(command);

waitForProcessToFinish(-1);
exportingView->flushConsole();

Expand All @@ -353,8 +353,8 @@ class DaisyExporter final : public ExporterBase {
metaJsonFile.copyFileTo(outputFile.getChildFile("meta.json"));

if (compile) {
auto bin = Toolchain::dir.getChildFile("bin");
auto libDaisy = Toolchain::dir.getChildFile("lib").getChildFile("libdaisy");
auto bin = toolchainDir.getChildFile("bin");
auto libDaisy = toolchainDir.getChildFile("lib").getChildFile("libdaisy");
auto make = bin.getChildFile("make" + exeSuffix);
auto compiler = bin.getChildFile("arm-none-eabi-gcc" + exeSuffix);

Expand All @@ -371,17 +371,22 @@ class DaisyExporter final : public ExporterBase {
sourceDir.getChildFile("build").createDirectory();
auto const& gccPath = pathToString(bin);

// Bit hacky, but the only way to get colour coding on daisy builds for Windows
#if JUCE_WINDOWS
sourceDir.getChildFile("Makefile").appendText("\nCFLAGS += -fdiagnostics-color=always");
#endif

auto buildScript = pathToString(make)
+ " -j4 -f "
+ pathToString(sourceDir.getChildFile("Makefile")).quoted()
#if JUCE_WINDOWS
+ " SHELL=" + pathToString(Toolchain::dir.getChildFile("bin").getChildFile("bash.exe")).quoted()
+ " SHELL=" + pathToString(toolchainDir.getChildFile("bin").getChildFile("bash.exe")).quoted()
#endif
+ " GCC_PATH="
+ gccPath
+ " PROJECT_NAME=" + name;

Toolchain::startShellScript(buildScript, this);
startShellScript(buildScript);

waitForProcessToFinish(-1);
exportingView->flushConsole();
Expand Down Expand Up @@ -416,8 +421,7 @@ class DaisyExporter final : public ExporterBase {
String testBootloaderScript = "export PATH=\"" + bin.getFullPathName() + ":$PATH\"\n"
+ dfuUtil.getFullPathName() + " -l ";

Toolchain runTest;
auto output = runTest.startShellScriptWithOutput(testBootloaderScript);
auto output = startShellScriptWithOutput(testBootloaderScript);
if (output.contains("alt=1")) {
exportingView->logToConsole("Bootloader not found...\n");
bootloaderExitCode = flashBootloader(bin, sourceDir, make, gccPath);
Expand All @@ -434,7 +438,7 @@ class DaisyExporter final : public ExporterBase {
+ " GCC_PATH=" + gccPath
+ " PROJECT_NAME=" + name;

Toolchain::startShellScript(flashScript, this);
startShellScript(flashScript);

waitForProcessToFinish(-1);
exportingView->flushConsole();
Expand All @@ -456,7 +460,7 @@ class DaisyExporter final : public ExporterBase {
} else {
auto outputFile = File(outdir);

auto libDaisy = Toolchain::dir.getChildFile("lib").getChildFile("libdaisy");
auto libDaisy = toolchainDir.getChildFile("lib").getChildFile("libdaisy");
libDaisy.copyDirectoryTo(outputFile.getChildFile("libdaisy"));

outputFile.getChildFile("ir").deleteRecursively();
Expand Down
78 changes: 72 additions & 6 deletions Source/Heavy/ExporterBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ struct ExporterBase : public Component
bool blockDialog = false;

#if JUCE_WINDOWS
inline static String const exeSuffix = ".exe";
static inline File const toolchainDir = ProjectInfo::appDataDir.getChildFile("Toolchain").getChildFile("usr");
static inline String const exeSuffix = ".exe";
#else
inline static String const exeSuffix = "";
static inline File const toolchainDir = ProjectInfo::appDataDir.getChildFile("Toolchain");
static inline String const exeSuffix = "";
#endif

inline static File heavyExecutable = Toolchain::dir.getChildFile("bin").getChildFile("Heavy").getChildFile("Heavy" + exeSuffix);

static inline File heavyExecutable = toolchainDir.getChildFile("bin").getChildFile("Heavy").getChildFile("Heavy" + exeSuffix);
static inline SmallArray<File> tempFilesToDelete;

bool validPatchSelected = false;
bool canvasDirty = false;
bool isTempFile = false;
Expand All @@ -45,6 +48,8 @@ struct ExporterBase : public Component

Label unsavedLabel = Label("", "Warning: patch has unsaved changes");
PluginEditor* editor;



ExporterBase(PluginEditor* pluginEditor, ExportingProgressView* exportView)
: ThreadPool(1, Thread::osDefaultStackSize, Thread::Priority::highest)
Expand Down Expand Up @@ -86,7 +91,7 @@ struct ExporterBase : public Component

if (auto const* cnv = editor->getCurrentCanvas()) {
openedPatchFile = File::createTempFile(".pd");
Toolchain::deleteTempFileLater(openedPatchFile);
deleteTempFileLater(openedPatchFile);
patchFile = cnv->patch.getCurrentFile();
if (!patchFile.existsAsFile()) {
openedPatchFile.replaceWithText(cnv->patch.getCanvasContent(), false, false, "\n");
Expand Down Expand Up @@ -150,6 +155,67 @@ struct ExporterBase : public Component
return file.getFullPathName();
#endif
}

static void deleteTempFileLater(File const& script)
{
tempFilesToDelete.add(script);
}

static void deleteTempFiles()
{
for (auto& file : tempFilesToDelete) {
if (file.existsAsFile())
file.deleteFile();
if (file.isDirectory())
file.deleteRecursively();
}
}

String startShellScriptWithOutput(String const& scriptText)
{
exportingView->logToConsole("\n\x1b[1;92m> " + scriptText + " \x1b[0m \n\n");

File scriptFile = File::createTempFile(".sh");
deleteTempFileLater(scriptFile);

auto const bash = String("#!/bin/bash\n");
scriptFile.replaceWithText(bash + scriptText, false, false, "\n");

ChildProcess process;
#if JUCE_WINDOWS
auto sh = toolchainDir.getChildFile("bin").getChildFile("sh.exe");
auto arguments = StringArray { sh.getFullPathName(), "--login", scriptFile.getFullPathName().replaceCharacter('\\', '/') };
#else
scriptFile.setExecutePermission(true);
auto arguments = scriptFile.getFullPathName();
#endif
process.start(arguments, ChildProcess::wantStdOut | ChildProcess::wantStdErr);
return process.readAllProcessOutput();
}

void startShellScript(String const& scriptText)
{
exportingView->logToConsole("\n\x1b[1;92m> " + scriptText + " \x1b[0m \n\n");

File scriptFile = File::createTempFile(".sh");
deleteTempFileLater(scriptFile);

#if JUCE_WINDOWS
auto const gccColourFlags = String("export CFLAGS=\"-fdiagnostics-color=always\"\nexport CXXFLAGS=\"-fdiagnostics-color=always\"\n ");
#else
auto const gccColourFlags = String("export TERM=xterm-256color\nexport GCC_URLS=no\n");
#endif
auto const bash = String("#!/bin/bash\n");
scriptFile.replaceWithText(bash + gccColourFlags + scriptText, false, false, "\n");

#if JUCE_WINDOWS
auto sh = toolchainDir.getChildFile("bin").getChildFile("sh.exe");
start(StringArray { sh.getFullPathName(), "--login", scriptFile.getFullPathName().replaceCharacter('\\', '/') });
#else
scriptFile.setExecutePermission(true);
start(scriptFile.getFullPathName(), ChildProcess::wantStdOut | ChildProcess::wantStdErr | ChildProcess::wantTtyOut);
#endif
}

void startExport(File const& outDir)
{
Expand Down Expand Up @@ -245,7 +311,7 @@ struct ExporterBase : public Component
static File createMetaJson(DynamicObject::Ptr const& metaJson)
{
auto const metadata = File::createTempFile(".json");
Toolchain::deleteTempFileLater(metadata);
deleteTempFileLater(metadata);
String const metaString = JSON::toString(var(metaJson.get()));
metadata.replaceWithText(metaString, false, false, "\n");
return metadata;
Expand Down
Loading
Loading