1. 15 Sep, 2023 6 commits
    • Alessio Perugini's avatar
      55fc5aa7
    • Alessio Perugini's avatar
      [skip-changelog] bye bye legacy (#2317) · 4c0d72e5
      Alessio Perugini authored
      * Move Preprocess and Build in arduino/builder
      
      * Move the detector inside arduino/builder
      
      * remove legacy targets from TaskFile
      
      * inline some variable declaration
      
      * remove no longer used builder getters
      
      * make only necessary function public in the new builder
      
      * fix CR: avoid mutating internal state
      
      * fix CR: only print normaloutput when is not verbose
      4c0d72e5
    • Alessio Perugini's avatar
      Porting `legacy` tests to new integration-test infra (part 4...) (#2315) · 6d57ce69
      Alessio Perugini authored
      * ported SketchThatIncludesArduinoH from legacy into integration test
      
      * ported SketchWithStaticAsserts from legacy into integration test
      
      * ported SketchWithEnumClass from legacy into integration test
      
      * ported SketchWithExternC from legacy into integration test
      
      * ported testBuilderSketchWithMultilinePrototypes from legacy into integration test
      
      * ported SketchWithExternCMultiline from legacy into integration test
      
      * ported SketchWithMultilineTemplate from legacy into integration test
      
      * ported SketchWithFakeFunctionPointer from legacy into integration test
      
      * fix wrong templating
      
      * ported SketchWithMinMaxDefinitions from legacy into integration test
      
      * ported SketchWithFastledsLibrary from legacy into integration test
      
      * ported sketch with merged sketch and bootloader from legacy into integration test
      
      * temporary disable legacy test, before porting them to the new infra
      
      * update .gitignore
      
      * ported CheckBuildOptionsFile from legacy into integration test
      
      * ported SketchClassFunction from legacy into integration test
      
      * ported SketchThatChecksIfSPIHasTransactionsAndIncludesMissingEthernet from legacy into integration test
      
      * remove legacy builder test folder
      
      * remove unsued fields from context
      6d57ce69
    • Alessio Perugini's avatar
      legacy: Builder refactorization (part 5...) (#2312) · 9c073c14
      Alessio Perugini authored
      * move customBuildProperties to arduino/builder
      
      * remove BuildProperties from context
      
      * remove BuildPath from context
      
      * remove sketch,libraries,core build path from Context
      
      * remove buildPath parameter to PrepareSketchBuildPath func
      
      * Make CoreBuilder a method recevier of arduino/builder
      
      * Add BuilderLogger in arduino/builder
      
      * Remove BuilderLogger from CoreBuild parameter
      
      * Make getCachedCoreArchiveDirName unexported
      
      * heavily refactored the ContainerBuildOptions
      
      * remove fqbn from Context
      
      * remove clean from Context
      
      * remove unsued properties in Context
      
      * remove sourceOverrides from Context
      
      * make SketchBuilder a method recevier of arduino/builder
      
      * make BuildLibraries a method recevier of arduino/builder
      
      * make RunRecipe a method recevier of arduino/builder
      
      * make RemoveUnusedCompiledLibraries a method recevier of arduino/builder
      
      * make MergeSketchWithBootloader a method recevier of arduino/builder
      
      * make WarnAboutArchIncompatibleLibraries a method recevier of arduino/builder
      
      * make PrintUsedLibraries a method recevier of arduino/builder
      
      * make ExportCmake and PreprocessorSketch a method recevier of arduino/builder
      
      * remove legacy/constans pkg
      
      * make Linker a method recevier of arduino/builder
      
      * make Size a method recevier of arduino/builder
      
      * remove onlyUpdateCompilationDatabase from Context
      
      * remove Progress from Context
      
      * remove ExecutableSectionSize from Context
      
      * remove CompilationDatabase from Context
      
      * remove LineOffset from Context
      
      * introduce BuilderArtifacts to better isolate write operations
      
      * remove ActualPlatform and TargetPlatform from Context
      
      * directly pass the remaining properties of Context in the builder constructor
      
      The remaning fields is used only by legacy tests
      
      * polish legacy test
      9c073c14
    • Akos Kitta's avatar
      feat: log `Required tool` with `debug` severity (#2314) · 8c81d2cb
      Akos Kitta authored
      Logging with `info` generates too much noise.
      
      Closes arduino/arduino-cli#2313
      Signed-off-by: default avatarAkos Kitta <a.kitta@arduino.cc>
      8c81d2cb
    • github-actions[bot]'s avatar
  2. 11 Sep, 2023 3 commits
    • Alessio Perugini's avatar
      [skip-changelog] legacy: refactor (part 4) (#2310) · 3f5c0eb2
      Alessio Perugini authored
      * move CoreBuilder in arduino/builder and move CompilationDatabase in compilation pkg
      
      * rename CompilationDatabse in Database
      
      * move libraries phases in arduino/builder
      
      * move linker phases in arduino/builder
      
      * move sketch_builder phases in arduino/builder
      
      * move sizer phases in arduino/builder/sizer
      
      * create bulder logger
      
      * use builder logger in the sketLibrariesDetector
      
      * replace context Info logger with BuilderLogger
      
      * replace context Warn logger with BuilderLogger
      
      * replace context WriteStdout logger with BuilderLogger
      
      * replace context WriteStderr logger with BuilderLogger
      
      * directly pass the BuilderLogger to RecipeByPrefixSuffixRunner func
      
      * directly pass the BuilderLogger to part2
      
      * directly pass the BuilderLogger to Linker func
      
      * directly pass the BuilderLogger to sizer.Size func
      
      * remove Stdout, Stderr and stdlock from Context
      
      * appease golint
      
      * add missinig license headers
      
      * remove WarningsLevel from context
      
      * remove Verbose from context
      3f5c0eb2
    • Cristian Maglie's avatar
      Fixed weird error message in `core install` if invalid platform is spcified (#2309) · cf5db1b8
      Cristian Maglie authored
      * Fixed weird error message in 'core install' if invalid platform is specified
      
      * Fixed integration test
      cf5db1b8
    • Alessio Perugini's avatar
      [skip-changelog] legacy: refactor (part 3) (#2302) · 5e01a2ea
      Alessio Perugini authored
      * refactor RecipeRunner in a function
      
      * refactor CreateBuildOptionsMap in a function
      
      * refactor LoadPreviousBuildOptionsMap in a function
      
      * refactor StoreBuildOptionsMap in a function
      
      * refactor WipeoutBuildPathIfBuildOptionsChanged in a function
      
      * refactor ContainerBuildOptions in a function
      
      * refactor MergeSketchWithBootloader in a function
      
      * refactor PrintUsedLibrariesIfVerbose in a function
      
      * refactor UnusedCompiledLibrariesRemover in a function
      
      * refactor WarnAboutArchIncompatibleLibraries in a function
      
      * refactor CreateMakeRule in a function
      
      * move include finder with regex tests under detector
      
      * move jobs properites in arduino/builder component
      
      * remove sketch property from context
      
      * apply CR suggestion
      5e01a2ea
  3. 08 Sep, 2023 3 commits
    • Cristian Maglie's avatar
      [skip-changelog] legacy: refacored `makeSourceFile` / other minor code moved (#2303) · 65915d8a
      Cristian Maglie authored
      * Slightly de-entangled makeSourceFile
      
      * Moved some initializations directly into NewBuilder
      
      * Pruned constants
      
      * Pruned more constants
      
      * Fixed lint warnings
      65915d8a
    • Alessio Perugini's avatar
      [skip-changelog] legacy: Builder refactorization (part 2) (#2298) · b8024c31
      Alessio Perugini authored
      * remove unused LibraryDir from legacy context
      
      * remove unused WatchedLocation from legacy context
      
      * remove unused IgnoreSketchFolderNameErrors from legacy context
      
      * remove CanUseCachedTools from legacy context
      
      * remove UseArduinoPreprocessor from legacy context
      
      * make the CoreBuilder command a function
      
      * remove the use of context from builder_utils
      
      * mvoe types.ProgressStruct in a dedicated pkg
      
      * move ExecCommand under arduino/utils
      
      * move LogIfVerbose from utils to legacy builder
      
      * move some legacy constans in builder package
      
      * move builder_utils under arduino/builder/utils pkg
      
      * appease golint
      
      * move coreBuildCachePath in the arduino Builder
      
      * refactor Linker command in a function
      
      * refactor SketchBuilder in a function
      
      * refactor LibrariesBuilder in a function
      
      * refactor Sizer in a function
      
      * remove empty file
      
      * remove unused struct FailIfBuildPathEqualsSketchPath
      b8024c31
    • Cristian Maglie's avatar
      [skip-changelog] Porting `legacy` tests to new integration-test infra (part 3...) (#2300) · 1c110e9c
      Cristian Maglie authored
      * Ported TestCoreCaching to current integration test infra
      
      * Removed useless TestBuilderEmptySketch
      
      The same features are already tested in a number of other integration tests.
      
      * Ported TestBuilderWithBuildPathInSketchDir to current integration test infra
      
      * Ported TestLoadHardware to current integration test infra
      
      * Moved user_hardware testdata resources
      
      * Ported TestLoadHardwareMixingUserHardwareFolder to current integration test infra
      
      * Removed redundant legacy tests
      
      * Removed useless 'sleep' helper function
      
      * Removed unused LoadAndInterpolate function
      
      * Removed useless NoError helper function
      
      * Grouped tests inside the same correct sub-group
      
      * Ported TestFailIfBuildPathEqualsSketchPath and TestFailIfBuildPathEqualsSketchPathSketchPathDiffers to current integration test infra
      1c110e9c
  4. 06 Sep, 2023 5 commits
  5. 05 Sep, 2023 1 commit
  6. 04 Sep, 2023 3 commits
    • dependabot[bot]'s avatar
      Bump actions/checkout from 3 to 4 (#2293) · 8ba101c8
      dependabot[bot] authored
      Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
      - [Release notes](https://github.com/actions/checkout/releases)
      - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
      - [Commits](https://github.com/actions/checkout/compare/v3...v4)
      
      ---
      updated-dependencies:
      - dependency-name: actions/checkout
        dependency-type: direct:production
        update-type: version-update:semver-major
      ...
      Signed-off-by: default avatardependabot[bot] <support@github.com>
      Co-authored-by: default avatardependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
      8ba101c8
    • Cristian Maglie's avatar
      Text output: removed trailing spaces for right-padding of tables (#2290) · 74547f36
      Cristian Maglie authored
      * Simplified table.Render method
      
      * Removed right padding from tables
      74547f36
    • Cristian Maglie's avatar
      [skip-changelog] Porting `legacy` tests to new integration-test infra (part 1...) (#2294) · 0af0b44e
      Cristian Maglie authored
      * Moved out from legacy some TryBuild* integration tests
      
      * Ported sketch_with_config integration tests out of legacy
      
      * Ported sketch_no_functions integration tests out of legacy
      
      * Ported sketch_with_backup_files integration tests out of legacy
      
      * Ported sketch_with_old_lib integration tests out of legacy
      
      * Ported sketch_with_subfolders integration tests out of legacy
      
      * Ported sketch_with_class integration tests out of legacy
      
      * Simplified integrationtest of preprocessor
      
      * Ported sketch_with_typename integration tests out of legacy
      
      * Ported sketch_with_namespace integration tests out of legacy
      
      * Ported sketch_with_default_args integration tests out of legacy
      
      * Ported sketch_with_inline_function_args integration tests out of legacy
      
      * Ported sketch_with_function_signature_inside_ifdef integration tests out of legacy
      
      * Ported sketch_with_usbcon integration tests out of legacy
      
      * Ported sketch_with_const integration tests out of legacy
      
      * Ported sketch_with_templates_and_shift integration tests out of legacy
      
      * Ported sketch eol_processing integration tests out of legacy
      
      * Ported SketchWithIfdef integration tests out of legacy
      
      * Ported sketch_with_ifdef integration tests out of legacy
      
      * Ported Bridge integration tests out of legacy
      
      * Ported more Bridge integration tests out of legacy
      
      * Ported even more Bridge integration tests out of legacy
      
      * Better subtesting categorization
      
      * Ported yet another Bridge integration tests out of legacy
      
      * Ported Balanduino integration tests out of legacy
      
      * Ported CharWithEscapedDoubleQuote integration tests out of legacy
      
      * Ported IncludeBetweenMultilineComment integration tests out of legacy
      
      * Ported LineContinuations integration tests out of legacy
      
      * Ported StringWithComment integration tests out of legacy
      
      * Ported SketchWithStruct integration tests out of legacy
      
      * Ported SketchNoFunctionsTwoFiles integration tests out of legacy
      
      * Ported SketchWithClassAndMethodSubstring integration tests out of legacy
      
      * Ported SketchThatChecksIfSPIHasTransactions integration tests out of legacy
      
      * Ported sketch_with_dependend_libraries integration tests out of legacy
      
      * Ported sketch_with_function_pointer integration tests out of legacy
      
      * Ported sketch_usbhost integration tests out of legacy
      
      * Removed sketch1 from try_build* test
      
      It's already compiled many times in other tests.
      
      * Ported sketch9 integration tests out of legacy
      
      * Removing no more used functions
      
      * Ported USBHost test
      
      * Removed no more useful test from legacy
      
      * Removed no more needed tests
      0af0b44e
  7. 29 Aug, 2023 1 commit
    • Cristian Maglie's avatar
      [skip-changelog] legacy: removing a lot of duplicated/dead code (#2282) · 3f9373a1
      Cristian Maglie authored
      * Replaced copyRecursive with go-paths library calls
      
      * Simplified download functions
      
      * Removed no more needed functions
      
      * Replaced some calls with go-paths library
      
      * Replaced some calls with go-paths library
      
      * Isolated some function into the (soon-to-be-removed) CMake generator
      
      This change will not break the CMake generator but will remove the
      CopyDir implementation from the public API space.
      
      * Removed now dead code
      
      * Moved md5 function to proper place
      
      * Refactor findAllFilesInFolder to use more go-paths function
      
      * Refactor findAllFilesInFolder to use more go-paths function
      
      * Made FilesAreOlderThan function to rationalize code
      
      * Yet another code-factorization of findAllFilesInFolder
      
      * Further simplified version of FilesAreOlderThan
      
      * Inlined CoreOrReferencedCoreHasChanged function
      
      * Inlined TXTBuildRulesHaveChanged function
      3f9373a1
  8. 25 Aug, 2023 2 commits
    • Cristian Maglie's avatar
      [skip-changelog] Relaxed test constraints (#2279) · f5a9b7c2
      Cristian Maglie authored
      I see an increase in trainsient CI failures for this test. Let's try
      to increase the timeout to see if solves the problem.
      f5a9b7c2
    • Cristian Maglie's avatar
      [skip-changelog] Some refactorings on library resolution code (#1766) · 4bf18d61
      Cristian Maglie authored
      * Transformed FailIfImportedLibraryIsWrong into a functon
      
      There was no need to have it encapsulated in a Command
      
      * Move variable near the place it belongs
      
      * Dramatically simplified SourceFile object
      
      Removed dependency from types.Context
      
      * Added comments about utility folder role in library discovery
      
      * Simplified if construct
      
      * Made RelativePath private
      
      * Skip includes detection of precompiled libraries early
      
      Instead of skipping include detection later, avoid to add the sources in
      the queue right from the beginning.
      
      * Keep extra-include dirs due to "utility" folder in SourceFile object
      
      Also remove the reference to the original Library object because it's no
      more needed.
      4bf18d61
  9. 23 Aug, 2023 2 commits
  10. 22 Aug, 2023 1 commit
  11. 21 Aug, 2023 1 commit
  12. 18 Aug, 2023 3 commits
    • Cristian Maglie's avatar
      feature: Detect board port change after upload (#2253) · 38479dc7
      Cristian Maglie authored
      * UploadResponse now has 'oneof' clause for better API design
      
      * Added scaffolding to return updated-port after upload
      
      * Upload port change detection (first draft)
      
      * Simplified port detection using a Future-style abstraction
      
      * Perform watcher-flush higher in the call tree
      
      * Do not infer upload port if 'upload.wait_for_upload_port' is false
      
      * Further simplified port detection subroutine structure
      
      * fixed linter issue
      
      * Always return an updatedUploadPort.
      
      Arduino CLI should always return the port after an upload, even in the case
      where no port change is expected. The consumer shouldn't be required to
      implement "if not updated_upload_port, use original port" logic.
      
      The whole point is that all the logic for determining which port should be
      selected after an upload should be implemented in Arduino CLI. The consumer
      should be able to simply select the port Arduino CLI tells it to select in
      all cases.
      
      * Updated docs
      
      * Perform a deep-copy of upload ports where needed.
      
      Previously only the pointer was copied, thus making changes in
      `actualPort` to be reflected also to `port`. This lead to some weird
      result in the `updatedUploadPort` result:
      
      {
        "stdout": "Verify 11344 bytes of flash with checksum.\nVerify successful\ndone in 0.010 seconds\nCPU reset.\n",
        "stderr": "",
        "updated_upload_port": {
          "address": "/dev/tty.usbmodem14101",     <------- this address...
          "label": "/dev/cu.usbmodem14101",        <------- ...is different from the label
          "protocol": "serial",
          "protocol_label": "Serial Port (USB)",
          "properties": {
            "pid": "0x804E",
            "serialNumber": "94A3397C5150435437202020FF150838",
            "vid": "0x2341"
          },
          "hardware_id": "94A3397C5150435437202020FF150838"
        }
      }
      
      * When updating `actualPort` address, update also the address label.
      
      * Fixed some potential nil pointer exceptions
      
      * Further simplified board watcher
      
      We must acesss the gRPC API only until we cross the `command` package
      border. Once we are inside the `command` package we should use the
      internal API only.
      
      * Before returning from upload, check if the port is still alive
      
      Now the upload detects cases when the upload port is "unstable", i.e.
      the port changes even if it shouldn't (because the wait_for_upload_port
      property in boards.txt is set to false).
      
      This change should make the upload process more resilient.
      
      * Apply suggestions from code review
      Co-authored-by: default avatarper1234 <accounts@perglass.com>
      
      * Fixed nil exception
      
      * Improved tracking algorithm for upload-port reconnection
      
      The new algorithm takes into account the case where a single board may
      expose multiple ports, in this case the selection will increase priority
      to ports that:
      
        1. have the same HW id as the user specified port for upload
        2. have the same protocol as the user specified port for upload
        3. have the same address as the user specified port for upload
      
      ---------
      Co-authored-by: default avatarper1234 <accounts@perglass.com>
      38479dc7
    • Cristian Maglie's avatar
      [skip-changelog] regression: hide include-not-found errors during library discovery (#2267) · b64876c7
      Cristian Maglie authored
      * regression: hide include-not-found errors during library discovery
      
      This regression was made during a refactoring of the Arduino preprocessor.
      In particular the wrong change was part of this commit:
      https://github.com/arduino/arduino-cli/commit/0585435f8b1d05e0117606f69bea42d3f3dfec79#diff-65ff16cbee816c0f443157444d99bcc144beee06c3329aec891894c8aeda7b27L372-R378
      
      -                       preproc_stderr, preproc_err = GCCPreprocRunner(ctx, sourcePath, targetFilePath, includes)
      +                       var preproc_stdout []byte
      +                       preproc_stdout, preproc_stderr, preproc_err = preprocessor.GCC(sourcePath, targetFilePath, includes, ctx.BuildProperties)
      +                       if ctx.Verbose {
      +                               ctx.WriteStdout(preproc_stdout)
      +                               ctx.WriteStdout(preproc_stderr)
      +                       }
      
      Previously GCCPreprocRunner, in verbose modem will show ONLY the stdout of
      the process, instead the "refactored" code wrongly added also stderr to the
      output.
      
      For reference this is the old GCCPreprocRunner implementation:
      https://github.com/arduino/arduino-cli/commit/0585435f8b1d05e0117606f69bea42d3f3dfec79#diff-371f93465ca5a66f01cbe876348f67990750091d27a827781c8633456b93ef3bL36
      
      -func GCCPreprocRunner(ctx *types.Context, sourceFilePath *paths.Path, targetFilePath *paths.Path, includes paths.PathList) ([]byte, error) {
      -       cmd, err := prepareGCCPreprocRecipeProperties(ctx, sourceFilePath, targetFilePath, includes)
      -       if err != nil {
      -               return nil, err
      -       }
      -       _, stderr, err := utils.ExecCommand(ctx, cmd, utils.ShowIfVerbose /* stdout */, utils.Capture /* stderr */)
      -       return stderr, err
      -}
      
      This commit fixes the regression.
      
      * Added integration test
      b64876c7
    • Cristian Maglie's avatar
      [skip-changelog] regression: Fix property expansion of "recipe.preproc.macros" (#2268) · 3bd60c6b
      Cristian Maglie authored
      Previously the undefined template placeholders in "recipe.preproc.macros"
      were silently replaced the empty string. This changed after a
      refactoring in 0585435f.
      
      Previously it was:
      
      https://github.com/arduino/arduino-cli/commit/0585435f8b1d05e0117606f69bea42d3f3dfec79#diff-371f93465ca5a66f01cbe876348f67990750091d27a827781c8633456b93ef3bL62
      -       cmd, err := builder_utils.PrepareCommandForRecipe(buildProperties, "recipe.preproc.macros", true, ctx.PackageManager.GetEnvVarsForSpawnedProcess())
      
      The `true` parameter in the call to `builder_utils.PrepareCommandForRecipe` is the parameter `removeUnsetProperties`.
      
      This behaviour has not been ported over after the "refactoring":
      https://github.com/arduino/arduino-cli/commit/0585435f8b1d05e0117606f69bea42d3f3dfec79#diff-733dda6759fe968eb8a8d7305c37c7a320a8df52764ca0cba8e88a6f1d077eb5R44-R65
      
      +       const gccPreprocRecipeProperty = "recipe.preproc.macros"
      +       if gccBuildProperties.Get(gccPreprocRecipeProperty) == "" {
      +               // autogenerate preprocess macros recipe from compile recipe
      +               preprocPattern := gccBuildProperties.Get("recipe.cpp.o.pattern")
      +               // add {preproc.macros.flags} to {compiler.cpp.flags}
      +               preprocPattern = strings.Replace(preprocPattern, "{compiler.cpp.flags}", "{compiler.cpp.flags} {preproc.macros.flags}", 1)
      +               // replace "{object_file}" with "{preprocessed_file_path}"
      +               preprocPattern = strings.Replace(preprocPattern, "{object_file}", "{preprocessed_file_path}", 1)
      +
      +               gccBuildProperties.Set(gccPreprocRecipeProperty, preprocPattern)
      +       }
      +
      +       pattern := gccBuildProperties.Get(gccPreprocRecipeProperty)
      +       if pattern == "" {
      +               return nil, nil, errors.Errorf(tr("%s pattern is missing"), gccPreprocRecipeProperty)
      +       }
      +
      +       commandLine := gccBuildProperties.ExpandPropsInString(pattern)
      +       args, err := properties.SplitQuotedString(commandLine, `"'`, false)
      +       if err != nil {
      +               return nil, nil, err
      +       }
      
      that is missing the call to `properties.DeleteUnexpandedPropsFromString`.
      3bd60c6b
  13. 17 Aug, 2023 1 commit
  14. 14 Aug, 2023 1 commit
  15. 12 Aug, 2023 1 commit
  16. 11 Aug, 2023 1 commit
  17. 04 Aug, 2023 1 commit
  18. 03 Aug, 2023 3 commits
  19. 02 Aug, 2023 1 commit