Skip to content

Commit

Permalink
directly pass the remaining properties of Context in the builder cons…
Browse files Browse the repository at this point in the history
…tructor

The remaning fields is used only by legacy tests
  • Loading branch information
alessio-perugini committed Sep 13, 2023
1 parent ab166b4 commit af86c0f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
22 changes: 8 additions & 14 deletions commands/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,10 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
}

builderCtx := &types.Context{}
builderCtx.PackageManager = pme
actualPlatform := buildPlatform

// FIXME: This will be redundant when arduino-builder will be part of the cli
builderCtx.HardwareDirs = configuration.HardwareDirectories(configuration.Settings)
builderCtx.BuiltInToolsDirs = configuration.BuiltinToolsDirectories(configuration.Settings)
builderCtx.OtherLibrariesDirs = paths.NewPathList(req.GetLibraries()...)
builderCtx.OtherLibrariesDirs.Add(configuration.LibrariesDir(configuration.Settings))

builderCtx.BuiltInLibrariesDirs = configuration.IDEBuiltinLibrariesDir(configuration.Settings)
builtinLibrariesDir := configuration.IDEBuiltinLibrariesDir(configuration.Settings)
otherLibrariesDirs := paths.NewPathList(req.GetLibraries()...)
otherLibrariesDirs.Add(configuration.LibrariesDir(configuration.Settings))

builderLogger := logger.New(outStream, errStream, req.GetVerbose(), req.GetWarnings())
builderCtx.BuilderLogger = builderLogger
Expand All @@ -197,10 +191,10 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
coreBuildCachePath,
int(req.GetJobs()),
req.GetBuildProperties(),
builderCtx.HardwareDirs,
builderCtx.BuiltInToolsDirs,
builderCtx.OtherLibrariesDirs,
builderCtx.BuiltInLibrariesDirs,
configuration.HardwareDirectories(configuration.Settings),
configuration.BuiltinToolsDirectories(configuration.Settings),
otherLibrariesDirs,
builtinLibrariesDir,
fqbn,
req.GetClean(),
req.GetSourceOverride(),
Expand Down Expand Up @@ -230,7 +224,7 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
libraryDir := paths.NewPathList(req.Library...)
libsManager, libsResolver, verboseOut, err := detector.LibrariesLoader(
useCachedLibrariesResolution, libsManager,
builderCtx.BuiltInLibrariesDirs, libraryDir, builderCtx.OtherLibrariesDirs,
builtinLibrariesDir, libraryDir, otherLibrariesDirs,
actualPlatform, targetPlatform,
)
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions legacy/builder/types/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ type Context struct {
SketchLibrariesDetector *detector.SketchLibrariesDetector
BuilderLogger *logger.BuilderLogger

// Build options
// Used only by legacy tests
HardwareDirs paths.PathList
BuiltInToolsDirs paths.PathList
BuiltInLibrariesDirs *paths.Path
OtherLibrariesDirs paths.PathList

PackageManager *packagemanager.Explorer
PackageManager *packagemanager.Explorer
}

0 comments on commit af86c0f

Please sign in to comment.