@@ -8,16 +8,20 @@ class OWLExporter : public ExporterBase {
88public:
99 // Value targetBoardValue = Value(var(1));
1010 Value exportTypeValue = SynchronousValue(var(3 ));
11+ Value storeSlotValue = SynchronousValue(var(1 ));
1112
1213 TextButton flashButton = TextButton(" Flash" );
1314
15+ PropertiesPanelProperty* storeSlotProperty;
16+
1417 OWLExporter (PluginEditor* editor, ExportingProgressView* exportingView)
1518 : ExporterBase(editor, exportingView)
1619 {
1720 Array<PropertiesPanelProperty*> properties;
1821 // properties.add(new PropertiesPanel::ComboComponent("Target board", targetBoardValue, { "OWL2", "OWL3" }));
19- properties.add (new PropertiesPanel::ComboComponent (" Export type" , exportTypeValue, { " Source code" , " Binary" , " Flash" }));
20-
22+ properties.add (new PropertiesPanel::ComboComponent (" Export type" , exportTypeValue, { " Source code" , " Binary" , " Load" , " Store" }));
23+ storeSlotProperty = new PropertiesPanel::ComboComponent (" Store slot" , storeSlotValue, { " 1" , " 2" , " 3" , " 4" , " 5" , " 6" , " 7" , " 8" });
24+ properties.add (storeSlotProperty);
2125
2226 for (auto * property : properties) {
2327 property->setPreferredHeight (28 );
@@ -28,13 +32,17 @@ class OWLExporter : public ExporterBase {
2832 exportButton.setVisible (false );
2933 addAndMakeVisible (flashButton);
3034
31- flashButton.setColour (TextButton::textColourOnId, findColour (TextButton::textColourOffId));
35+ auto const backgroundColour = findColour (PlugDataColour::panelBackgroundColourId);
36+ flashButton.setColour (TextButton::buttonColourId, backgroundColour.contrasting (0 .05f ));
37+ flashButton.setColour (TextButton::buttonOnColourId, backgroundColour.contrasting (0 .1f ));
38+ flashButton.setColour (ComboBox::outlineColourId, Colours::transparentBlack);
3239
33- exportTypeValue.addListener (this );
3440 // targetBoardValue.addListener(this);
41+ exportTypeValue.addListener (this );
42+ storeSlotValue.addListener (this );
3543
36- flashButton.onClick = [this ]() {
37- auto tempFolder = File::getSpecialLocation (File::tempDirectory).getChildFile (" Heavy-" + Uuid ().toString ().substring (10 ));
44+ flashButton.onClick = [this , exportingView] {
45+ auto const tempFolder = File::getSpecialLocation (File::tempDirectory).getChildFile (" Heavy-" + Uuid ().toString ().substring (10 ));
3846 Toolchain::deleteTempFileLater (tempFolder);
3947 startExport (tempFolder);
4048 };
@@ -44,13 +52,15 @@ class OWLExporter : public ExporterBase {
4452 {
4553 ValueTree stateTree (" OWL" );
4654 stateTree.setProperty (" exportTypeValue" , getValue<int >(exportTypeValue), nullptr );
55+ stateTree.setProperty (" storeSlotValue" , getValue<int >(storeSlotValue), nullptr );
4756 return stateTree;
4857 }
4958
5059 void setState (ValueTree& stateTree) override
5160 {
5261 auto tree = stateTree.getChildWithName (" OWL" );
5362 exportTypeValue = tree.getProperty (" exportTypeValue" );
63+ storeSlotValue = tree.getProperty (" storeSlotValue" );
5464 }
5565
5666 void resized () override
@@ -65,21 +75,26 @@ class OWLExporter : public ExporterBase {
6575
6676 flashButton.setEnabled (validPatchSelected);
6777
68- bool flash = getValue<int >(exportTypeValue) == 3 ;
78+ int const exportType = getValue<int >(exportTypeValue);
79+ bool flash = exportType == 3 || exportType == 4 ;
6980 exportButton.setVisible (!flash);
7081 flashButton.setVisible (flash);
82+
83+ storeSlotProperty->setEnabled (exportType == 4 );
7184 }
7285
7386 bool performExport (String pdPatch, String outdir, String name, String copyright, StringArray searchPaths) override
7487 {
7588 // auto target = getValue<int>(targetBoardValue) - 1;
7689 bool compile = getValue<int >(exportTypeValue) - 1 ;
77- bool flash = getValue<int >(exportTypeValue) == 3 ;
90+ bool load = getValue<int >(exportTypeValue) == 3 ;
91+ bool store = getValue<int >(exportTypeValue) == 4 ;
92+ int slot = getValue<int >(storeSlotValue);
7893
7994 StringArray args = { heavyExecutable.getFullPathName (), pdPatch, " -o" + outdir };
8095
8196 name = name.replaceCharacter (' -' , ' _' );
82- args.add (" -n owl " );
97+ args.add (" -n" + name );
8398
8499 if (copyright.isNotEmpty ()) {
85100 args.add (" --copyright" );
@@ -105,57 +120,68 @@ class OWLExporter : public ExporterBase {
105120 if (shouldQuit)
106121 return true ;
107122
108- // Delay to get correct exit code
109- Time::waitForMillisecondCounter (Time::getMillisecondCounter () + 300 );
110-
111123 auto outputFile = File (outdir);
112124 auto sourceDir = outputFile.getChildFile (" Source" );
113125
114126 bool heavyExitCode = getExitCode ();
115127
128+ outputFile.getChildFile (" ir" ).deleteRecursively ();
129+ outputFile.getChildFile (" hv" ).deleteRecursively ();
130+ outputFile.getChildFile (" c" ).deleteRecursively ();
131+
132+ auto OWL = Toolchain::dir.getChildFile (" lib" ).getChildFile (" OwlProgram" );
133+ OWL.copyDirectoryTo (outputFile.getChildFile (" OwlProgram" ));
134+
135+ // Delay to get correct exit code
136+ Time::waitForMillisecondCounter (Time::getMillisecondCounter () + 300 );
137+
116138 if (compile) {
139+ auto workingDir = File::getCurrentWorkingDirectory ();
117140
118141 auto bin = Toolchain::dir.getChildFile (" bin" );
119- auto OWL = Toolchain::dir.getChildFile (" lib" ).getChildFile (" OwlProgram" );
120142 auto make = bin.getChildFile (" make" + exeSuffix);
121143 auto compiler = bin.getChildFile (" arm-none-eabi-gcc" + exeSuffix);
122144
123- OWL.copyDirectoryTo (outputFile.getChildFile (" OwlProgram" ));
124-
125- outputFile.getChildFile (" ir" ).deleteRecursively ();
126- outputFile.getChildFile (" hv" ).deleteRecursively ();
127- outputFile.getChildFile (" c" ).deleteRecursively ();
128-
129- auto workingDir = File::getCurrentWorkingDirectory ();
130-
131145 auto OwlDir = outputFile.getChildFile (" OwlProgram" );
132146 OwlDir.setAsCurrentWorkingDirectory ();
133147 OwlDir.getChildFile (" Tools/FirmwareSender" ).setExecutePermission (1 );
134148
135149 auto const & gccPath = bin.getFullPathName ();
136150
137- #if JUCE_WINDOWS
138- auto buildScript = make.getFullPathName ().replaceCharacter (' \\ ' , ' /' )
139- + " -j4 -f "
140- + sourceDir.getChildFile (" Makefile" ).getFullPathName ().replaceCharacter (' \\ ' , ' /' )
141- + " GCC_PATH="
142- + gccPath.replaceCharacter (' \\ ' , ' /' )
143- + " PROJECT_NAME=" + name;
151+ String buildScript;
144152
145- Toolchain::startShellScript (buildScript, this );
153+ #if JUCE_WINDOWS
154+ buildScript += make.getFullPathName ().replaceCharacter (' \\ ' , ' /' )
155+ + " -j4"
156+ + " TOOLROOT=" + gccPath.replaceCharacter (' \\ ' , ' /' ) + " /"
157+ + " BUILD=../"
158+ + " PATCHNAME=" + name
159+ + " PATCHCLASS=HeavyPatch"
160+ + " PATCHFILE=HeavyOWL_" + name + " .hpp"
161+ + " PLATFORM=OWL2" ;
146162#else
147- String buildScript = make.getFullPathName ()
163+ buildScript + = make.getFullPathName ()
148164 + " -j4"
149165 + " TOOLROOT=" + gccPath + " /"
150166 + " BUILD=../"
151167 + " PATCHNAME=" + name
152168 + " PATCHCLASS=HeavyPatch"
153- + " PATCHFILE=HeavyOWL_owl.hpp"
154- + " PLATFORM=OWL2"
155- + " load" ;
169+ + " PATCHFILE=HeavyOWL_" + name + " .hpp"
170+ + " PLATFORM=OWL2" ;
171+ #endif
172+ if (load) {
173+ // load into flash memore
174+ buildScript += " load" ;
175+ } else if (store) {
176+ // store into specific slot
177+ buildScript += " store" ;
178+ buildScript += " SLOT=" + String (slot);
179+ } else {
180+ // only build a binary
181+ buildScript += " patch" ;
182+ }
156183
157184 Toolchain::startShellScript (buildScript, this );
158- #endif
159185
160186 waitForProcessToFinish (-1 );
161187 exportingView->flushConsole ();
@@ -167,56 +193,32 @@ class OWLExporter : public ExporterBase {
167193 Time::waitForMillisecondCounter (Time::getMillisecondCounter () + 300 );
168194
169195 auto compileExitCode = getExitCode ();
170- // if (flash && !compileExitCode) {
171-
172- // auto dfuUtil = bin.getChildFile("dfu-util" + exeSuffix);
173196
197+ // cleanup
198+ outputFile.getChildFile (" OwlProgram" ).deleteRecursively ();
199+ outputFile.getChildFile (" web" ).deleteRecursively ();
200+ outputFile.getChildFile (" Test" ).deleteRecursively ();
201+ outputFile.getChildFile (" Source" ).deleteRecursively ();
202+ outputFile.getChildFile (" patch.elf" ).deleteRecursively ();
174203
175- // exportingView->logToConsole("Flashing...\n");
204+ Array<String> file_ext = { " h" , " cpp" , " o" , " d" };
205+ for (int i = 0 ; i < file_ext.size (); i++)
206+ {
207+ auto files = outputFile.findChildFiles (2 , false , " *." + file_ext[i]);
208+ for (int j = 0 ; j < files.size (); j++)
209+ files[j].deleteRecursively ();
210+ }
176211
177- // #if JUCE_WINDOWS
178- // String flashScript = "export PATH=\"" + bin.getFullPathName().replaceCharacter('\\', '/') + ":$PATH\"\n"
179- // + "cd " + sourceDir.getFullPathName().replaceCharacter('\\', '/') + "\n"
180- // + make.getFullPathName().replaceCharacter('\\', '/') + " program-dfu"
181- // + " GCC_PATH=" + gccPath.replaceCharacter('\\', '/')
182- // + " PROJECT_NAME=" + name;
183- // #else
184- // String flashScript = "export PATH=\"" + bin.getFullPathName() + ":$PATH\"\n"
185- // + "cd " + sourceDir.getFullPathName() + "\n"
186- // + make.getFullPathName() + " program-dfu"
187- // + " GCC_PATH=" + gccPath
188- // + " PROJECT_NAME=" + name;
189- // #endif
190-
191- // Toolchain::startShellScript(flashScript, this);
192-
193- // waitForProcessToFinish(-1);
194- // exportingView->flushConsole();
195-
196- // // Delay to get correct exit code
197- // Time::waitForMillisecondCounter(Time::getMillisecondCounter() + 300);
198-
199- // auto flashExitCode = getExitCode();
200-
201- // return heavyExitCode && flashExitCode;
202- // } else {
203- // auto binLocation = outputFile.getChildFile(name + ".bin");
204- // sourceDir.getChildFile("build").getChildFile("HeavyOWL_" + name + ".bin").moveFileTo(binLocation);
205- // }
206-
207- // outputFile.getChildFile("OWL").deleteRecursively();
208- // outputFile.getChildFile("libOWL").deleteRecursively();
212+ // rename binary
213+ outputFile.getChildFile (" patch.bin" ).moveFileTo (outputFile.getChildFile (name + " .bin" ));
209214
210215 return heavyExitCode && compileExitCode;
211216 } else {
212217 auto outputFile = File (outdir);
213218
214- auto libOWL = Toolchain::dir.getChildFile (" lib" ).getChildFile (" libOWL" );
215- libOWL.copyDirectoryTo (outputFile.getChildFile (" libOWL" ));
216-
217- // outputFile.getChildFile("ir").deleteRecursively();
218- // outputFile.getChildFile("hv").deleteRecursively();
219- // outputFile.getChildFile("c").deleteRecursively();
219+ outputFile.getChildFile (" ir" ).deleteRecursively ();
220+ outputFile.getChildFile (" hv" ).deleteRecursively ();
221+ outputFile.getChildFile (" c" ).deleteRecursively ();
220222 return heavyExitCode;
221223 }
222224 }
0 commit comments