|
1 | 1 | package processing.app; |
2 | 2 |
|
3 | | -import cc.arduino.Compiler; |
4 | 3 | import cc.arduino.Constants; |
5 | | -import cc.arduino.UploaderUtils; |
6 | 4 | import cc.arduino.contributions.GPGDetachedSignatureVerifier; |
7 | 5 | import cc.arduino.contributions.SignatureVerificationFailedException; |
8 | 6 | import cc.arduino.contributions.VersionComparator; |
9 | 7 | import cc.arduino.contributions.libraries.LibrariesIndexer; |
10 | 8 | import cc.arduino.contributions.packages.ContributedPlatform; |
11 | 9 | import cc.arduino.contributions.packages.ContributedTool; |
12 | 10 | import cc.arduino.contributions.packages.ContributionsIndexer; |
13 | | -import cc.arduino.files.DeleteFilesOnShutdown; |
14 | 11 | import cc.arduino.packages.DiscoveryManager; |
15 | | -import cc.arduino.packages.Uploader; |
16 | 12 | import com.fasterxml.jackson.core.JsonProcessingException; |
17 | 13 | import org.apache.commons.compress.utils.IOUtils; |
18 | 14 | import org.apache.commons.logging.impl.LogFactoryImpl; |
@@ -437,156 +433,6 @@ static public String[] headerListFromIncludePath(File path) throws IOException { |
437 | 433 | return list; |
438 | 434 | } |
439 | 435 |
|
440 | | - static public void init(String[] args) throws Exception { |
441 | | - CommandlineParser parser = new CommandlineParser(args); |
442 | | - parser.parseArgumentsPhase1(); |
443 | | - |
444 | | - String sketchbookPath = getSketchbookPath(); |
445 | | - |
446 | | - // If no path is set, get the default sketchbook folder for this platform |
447 | | - if (sketchbookPath == null) { |
448 | | - if (BaseNoGui.getPortableFolder() != null) |
449 | | - PreferencesData.set("sketchbook.path", getPortableSketchbookFolder()); |
450 | | - else |
451 | | - showError(tr("No sketchbook"), tr("Sketchbook path not defined"), null); |
452 | | - } |
453 | | - |
454 | | - BaseNoGui.initPackages(); |
455 | | - |
456 | | - parser.parseArgumentsPhase2(); |
457 | | - |
458 | | - for (String path: parser.getFilenames()) { |
459 | | - // Correctly resolve relative paths |
460 | | - File file = absoluteFile(path); |
461 | | - |
462 | | - // Fix a problem with systems that use a non-ASCII languages. Paths are |
463 | | - // being passed in with 8.3 syntax, which makes the sketch loader code |
464 | | - // unhappy, since the sketch folder naming doesn't match up correctly. |
465 | | - // http://dev.processing.org/bugs/show_bug.cgi?id=1089 |
466 | | - if (OSUtils.isWindows()) { |
467 | | - try { |
468 | | - file = file.getCanonicalFile(); |
469 | | - } catch (IOException e) { |
470 | | - e.printStackTrace(); |
471 | | - } |
472 | | - } |
473 | | - |
474 | | - if (!parser.isVerifyOrUploadMode() && !parser.isGetPrefMode()) |
475 | | - showError(tr("Mode not supported"), tr("Only --verify, --upload or --get-pref are supported"), null); |
476 | | - |
477 | | - if (!parser.isForceSavePrefs()) |
478 | | - PreferencesData.setDoSave(false); |
479 | | - if (!file.exists()) { |
480 | | - String mess = I18n.format(tr("Failed to open sketch: \"{0}\""), path); |
481 | | - // Open failure is fatal in upload/verify mode |
482 | | - showError(null, mess, 2); |
483 | | - } |
484 | | - } |
485 | | - |
486 | | - // Setup board-dependent variables. |
487 | | - onBoardOrPortChange(); |
488 | | - |
489 | | - // Save the preferences. For GUI mode, this happens in the quit |
490 | | - // handler, but for other modes we should also make sure to save |
491 | | - // them. |
492 | | - PreferencesData.save(); |
493 | | - |
494 | | - if (parser.isVerifyOrUploadMode()) { |
495 | | - // Set verbosity for command line build |
496 | | - PreferencesData.set("build.verbose", "" + parser.isDoVerboseBuild()); |
497 | | - PreferencesData.set("upload.verbose", "" + parser.isDoVerboseUpload()); |
498 | | - |
499 | | - // Make sure these verbosity preferences are only for the |
500 | | - // current session |
501 | | - PreferencesData.setDoSave(false); |
502 | | - |
503 | | - if (parser.isUploadMode()) { |
504 | | - |
505 | | - if (parser.getFilenames().size() != 1) |
506 | | - { |
507 | | - showError(tr("Multiple files not supported"), tr("The --upload option supports only one file at a time"), null); |
508 | | - } |
509 | | - |
510 | | - List<String> warningsAccumulator = new LinkedList<>(); |
511 | | - boolean success = false; |
512 | | - try { |
513 | | - // Editor constructor loads the sketch with handleOpenInternal() that |
514 | | - // creates a new Sketch that, in turn, builds a SketchData |
515 | | - // inside its constructor. |
516 | | - // This translates here as: |
517 | | - // SketchData data = new SketchData(file); |
518 | | - // File tempBuildFolder = getBuildFolder(); |
519 | | - Sketch data = new Sketch(absoluteFile(parser.getFilenames().get(0))); |
520 | | - |
521 | | - // Sketch.exportApplet() |
522 | | - // - calls Sketch.prepare() that calls Sketch.ensureExistence() |
523 | | - // - calls Sketch.build(verbose=false) that calls Sketch.ensureExistence(), set progressListener and calls Compiler.build() |
524 | | - // - calls Sketch.upload() (see later...) |
525 | | - if (!data.getFolder().exists()) { |
526 | | - showError(tr("No sketch"), tr("Can't find the sketch in the specified path"), null); |
527 | | - } |
528 | | - String suggestedClassName = new Compiler(data).build(null, false); |
529 | | - if (suggestedClassName == null) { |
530 | | - showError(tr("Error while verifying"), tr("An error occurred while verifying the sketch"), null); |
531 | | - } |
532 | | - showMessage(tr("Done compiling"), tr("Done compiling")); |
533 | | - |
534 | | - Uploader uploader = new UploaderUtils().getUploaderByPreferences(parser.isNoUploadPort()); |
535 | | - if (uploader.requiresAuthorization() && !PreferencesData.has(uploader.getAuthorizationKey())) showError("...", "...", null); |
536 | | - try { |
537 | | - success = new UploaderUtils().upload(data, uploader, suggestedClassName, parser.isDoUseProgrammer(), parser.isNoUploadPort(), warningsAccumulator); |
538 | | - showMessage(tr("Done uploading"), tr("Done uploading")); |
539 | | - } finally { |
540 | | - if (uploader.requiresAuthorization() && !success) { |
541 | | - PreferencesData.remove(uploader.getAuthorizationKey()); |
542 | | - } |
543 | | - } |
544 | | - } catch (Exception e) { |
545 | | - showError(tr("Error while verifying/uploading"), tr("An error occurred while verifying/uploading the sketch"), e); |
546 | | - } |
547 | | - for (String warning : warningsAccumulator) { |
548 | | - System.out.print(tr("Warning")); |
549 | | - System.out.print(": "); |
550 | | - System.out.println(warning); |
551 | | - } |
552 | | - if (!success) showError(tr("Error while uploading"), tr("An error occurred while uploading the sketch"), null); |
553 | | - } else { |
554 | | - |
555 | | - for (String path : parser.getFilenames()) |
556 | | - { |
557 | | - try { |
558 | | - // Editor constructor loads sketch with handleOpenInternal() that |
559 | | - // creates a new Sketch that calls load() in its constructor |
560 | | - // This translates here as: |
561 | | - // SketchData data = new SketchData(file); |
562 | | - // File tempBuildFolder = getBuildFolder(); |
563 | | - // data.load(); |
564 | | - Sketch data = new Sketch(absoluteFile(path)); |
565 | | - |
566 | | - // Sketch.prepare() calls Sketch.ensureExistence() |
567 | | - // Sketch.build(verbose) calls Sketch.ensureExistence() and set progressListener and, finally, calls Compiler.build() |
568 | | - // This translates here as: |
569 | | - // if (!data.getFolder().exists()) showError(...); |
570 | | - // String ... = Compiler.build(data, tempBuildFolder.getAbsolutePath(), tempBuildFolder, null, verbose); |
571 | | - if (!data.getFolder().exists()) showError(tr("No sketch"), tr("Can't find the sketch in the specified path"), null); |
572 | | - String suggestedClassName = new Compiler(data).build(null, false); |
573 | | - if (suggestedClassName == null) showError(tr("Error while verifying"), tr("An error occurred while verifying the sketch"), null); |
574 | | - showMessage(tr("Done compiling"), tr("Done compiling")); |
575 | | - } catch (Exception e) { |
576 | | - showError(tr("Error while verifying"), tr("An error occurred while verifying the sketch"), e); |
577 | | - } |
578 | | - } |
579 | | - |
580 | | - } |
581 | | - |
582 | | - // No errors exit gracefully |
583 | | - System.exit(0); |
584 | | - } |
585 | | - else if (parser.isGetPrefMode()) { |
586 | | - dumpPrefs(parser); |
587 | | - } |
588 | | - } |
589 | | - |
590 | 436 | protected static void dumpPrefs(CommandlineParser parser) { |
591 | 437 | if (parser.getGetPref() != null) { |
592 | 438 | String value = PreferencesData.get(parser.getGetPref(), null); |
@@ -756,29 +602,6 @@ static public String loadFile(File file) throws IOException { |
756 | 602 | return PApplet.join(contents, "\n"); |
757 | 603 | } |
758 | 604 |
|
759 | | - static public void main(String args[]) throws Exception { |
760 | | - if (args.length == 0) { |
761 | | - showError(tr("No parameters"), tr("No command line parameters found"), null); |
762 | | - } |
763 | | - System.setProperty("java.net.useSystemProxies", "true"); |
764 | | - |
765 | | - Thread deleteFilesOnShutdownThread = new Thread(DeleteFilesOnShutdown.INSTANCE); |
766 | | - deleteFilesOnShutdownThread.setName("DeleteFilesOnShutdown"); |
767 | | - Runtime.getRuntime().addShutdownHook(deleteFilesOnShutdownThread); |
768 | | - |
769 | | - initPlatform(); |
770 | | - |
771 | | - getPlatform().init(); |
772 | | - |
773 | | - initPortableFolder(); |
774 | | - |
775 | | - initParameters(args); |
776 | | - |
777 | | - checkInstallationFolder(); |
778 | | - |
779 | | - init(args); |
780 | | - } |
781 | | - |
782 | 605 | public static void checkInstallationFolder() { |
783 | 606 | if (isIDEInstalledIntoSettingsFolder()) { |
784 | 607 | showError(tr("Incorrect IDE installation folder"), tr("Your copy of the IDE is installed in a subfolder of your settings folder.\nPlease move the IDE to another folder."), 10); |
|
0 commit comments