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