A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/arduino/arduino-cli/commit/863c1ec365af2cf90ee41f6fcadfa675e5d61704 below:

Fixed `build_cache.path` behaviour / The `--build-path` dir now produ… · arduino/arduino-cli@863c1ec · GitHub

@@ -160,7 +160,7 @@ func (s *arduinoCoreServerImpl) Compile(req *rpc.CompileRequest, stream rpc.Ardu

160 160

return errors.New(i18n.Tr("Firmware encryption/signing requires all the following properties to be defined: %s", "build.keys.keychain, build.keys.sign_key, build.keys.encrypt_key"))

161 161

}

162 162 163 -

// Generate or retrieve build path

163 +

// Retrieve build path from user arguments

164 164

var buildPath *paths.Path

165 165

if buildPathArg := req.GetBuildPath(); buildPathArg != "" {

166 166

buildPath = paths.New(req.GetBuildPath()).Canonical()

@@ -170,44 +170,46 @@ func (s *arduinoCoreServerImpl) Compile(req *rpc.CompileRequest, stream rpc.Ardu

170 170

}

171 171

}

172 172

}

173 -

if buildPath == nil {

174 -

buildPath = sk.DefaultBuildPath()

175 -

}

176 -

if err = buildPath.MkdirAll(); err != nil {

177 -

return &cmderrors.PermissionDeniedError{Message: i18n.Tr("Cannot create build directory"), Cause: err}

178 -

}

179 -

buildcache.New(buildPath.Parent()).GetOrCreate(buildPath.Base())

180 -

// cache is purged after compilation to not remove entries that might be required

181 - 182 -

defer maybePurgeBuildCache(

183 -

s.settings.GetCompilationsBeforeBuildCachePurge(),

184 -

s.settings.GetBuildCacheTTL().Abs())

185 173 186 -

var buildCachePath *paths.Path

187 -

if req.GetBuildCachePath() != "" {

188 -

p, err := paths.New(req.GetBuildCachePath()).Abs()

189 -

if err != nil {

174 +

// If no build path has been set by the user:

175 +

// - set up the build cache directory

176 +

// - set the sketch build path inside the build cache directory.

177 +

var coreBuildCachePath *paths.Path

178 +

var extraCoreBuildCachePaths paths.PathList

179 +

if buildPath == nil {

180 +

var buildCachePath *paths.Path

181 +

if p := req.GetBuildCachePath(); p != "" { //nolint:staticcheck

182 +

buildCachePath = paths.New(p)

183 +

} else {

184 +

buildCachePath = s.settings.GetBuildCachePath()

185 +

}

186 +

if err := buildCachePath.ToAbs(); err != nil {

190 187

return &cmderrors.PermissionDeniedError{Message: i18n.Tr("Cannot create build cache directory"), Cause: err}

191 188

}

192 -

buildCachePath = p

193 -

} else if p, ok := s.settings.GetBuildCachePath(); ok {

194 -

buildCachePath = p

195 -

} else {

196 -

buildCachePath = paths.TempDir().Join("arduino")

197 -

}

198 -

if err := buildCachePath.MkdirAll(); err != nil {

199 -

return &cmderrors.PermissionDeniedError{Message: i18n.Tr("Cannot create build cache directory"), Cause: err}

200 -

}

201 -

coreBuildCachePath := buildCachePath.Join("cores")

189 +

if err := buildCachePath.MkdirAll(); err != nil {

190 +

return &cmderrors.PermissionDeniedError{Message: i18n.Tr("Cannot create build cache directory"), Cause: err}

191 +

}

192 +

coreBuildCachePath = buildCachePath.Join("cores")

202 193 203 -

var extraCoreBuildCachePaths paths.PathList

204 -

if len(req.GetBuildCacheExtraPaths()) == 0 {

205 -

extraCoreBuildCachePaths = s.settings.GetBuildCacheExtraPaths()

206 -

} else {

207 -

extraCoreBuildCachePaths = paths.NewPathList(req.GetBuildCacheExtraPaths()...)

194 +

if len(req.GetBuildCacheExtraPaths()) == 0 {

195 +

extraCoreBuildCachePaths = s.settings.GetBuildCacheExtraPaths()

196 +

} else {

197 +

extraCoreBuildCachePaths = paths.NewPathList(req.GetBuildCacheExtraPaths()...)

198 +

}

199 +

for i, p := range extraCoreBuildCachePaths {

200 +

extraCoreBuildCachePaths[i] = p.Join("cores")

201 +

}

202 + 203 +

buildPath = s.getDefaultSketchBuildPath(sk, buildCachePath)

204 +

buildcache.New(buildPath.Parent()).GetOrCreate(buildPath.Base())

205 + 206 +

// cache is purged after compilation to not remove entries that might be required

207 +

defer maybePurgeBuildCache(

208 +

s.settings.GetCompilationsBeforeBuildCachePurge(),

209 +

s.settings.GetBuildCacheTTL().Abs())

208 210

}

209 -

for i, p := range extraCoreBuildCachePaths {

210 -

extraCoreBuildCachePaths[i] = p.Join("cores")

211 +

if err = buildPath.MkdirAll(); err != nil {

212 +

return &cmderrors.PermissionDeniedError{Message: i18n.Tr("Cannot create build directory"), Cause: err}

211 213

}

212 214 213 215

if _, err := pme.FindToolsRequiredForBuild(targetPlatform, buildPlatform); err != nil {

@@ -416,6 +418,16 @@ func (s *arduinoCoreServerImpl) Compile(req *rpc.CompileRequest, stream rpc.Ardu

416 418

return nil

417 419

}

418 420 421 +

// getDefaultSketchBuildPath generates the default build directory for a given sketch.

422 +

// The sketch build path is inside the build cache path and is unique for each sketch.

423 +

// If overriddenBuildCachePath is nil the build cache path is taken from the settings.

424 +

func (s *arduinoCoreServerImpl) getDefaultSketchBuildPath(sk *sketch.Sketch, overriddenBuildCachePath *paths.Path) *paths.Path {

425 +

if overriddenBuildCachePath == nil {

426 +

overriddenBuildCachePath = s.settings.GetBuildCachePath()

427 +

}

428 +

return overriddenBuildCachePath.Join("sketches", sk.Hash())

429 +

}

430 + 419 431

// maybePurgeBuildCache runs the build files cache purge if the policy conditions are met.

420 432

func maybePurgeBuildCache(compilationsBeforePurge uint, cacheTTL time.Duration) {

421 433

// 0 means never purge


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4