Skip to content

fix path resolution in extension info - #11796

Closed
Richard Knoll (riknoll) wants to merge 1 commit into
masterfrom
dev/riknoll/refactor-ext-util2
Closed

Richard Knoll (riknoll) wants to merge 1 commit into
masterfrom
dev/riknoll/refactor-ext-util2

Conversation

@riknoll

Copy link
Copy Markdown
Member

fixing a couple issues around dependency resolution for extension files inside getExtensionInfo. we have a rather complex system of excluding certain files if another package is present and flattening those paths was causing guards to be ignored for native builds.

@riknoll
Richard Knoll (riknoll) requested a review from a team December 1, 2026 18:59

@aznhassan Hassan Sufi (aznhassan) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Required core and dependency Makefiles can be dropped, breaking clean native builds, while omitted sdkconfig.defaults can crash local ESP-IDF builds.

6 open issues
What changed in this PR

Updates native extension generation so dependency-based build-file exclusions survive compile-request flattening.

Changes:

  • Preserves selected build-file names in reduced requests and resolves their contents from target bundles.
  • Centralizes build-file classification and validates paths emitted into Makefile.inc.
  • Expands CLI tests for dependency guards, bundle resolution, cache invalidation, and portable native paths.
File Description
tests/​cli-test/​clirunner.ts Adds regression coverage for build-file selection, resolution, caching, and path validation.
pxtlib/​shared/​packageutils.ts Adds a shared native build-file classifier.
pxtlib/​shared/​extensionrequest.ts Retains selected build-file names while omitting their contents from reduced requests.
pxtlib/​shared/​extensioninfo.ts Uses bundle-backed build-file contents, respects file selection, and validates Makefile paths.

Review effort: Max

Comment thread pxtlib/shared/extensioninfo.ts Resolved
Comment thread pxtlib/shared/extensioninfo.ts Resolved
Comment thread pxtlib/shared/extensioninfo.ts Resolved
Comment thread pxtlib/shared/extensioninfo.ts Resolved
Comment thread pxtlib/shared/extensioninfo.ts Resolved
Comment thread pxtlib/shared/extensioninfo.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread cli/buildengine.ts Resolved
Comment thread cli/buildengine.ts Resolved
Comment thread cli/buildengine.ts Resolved
Comment thread cli/cli.ts Resolved
Comment thread pxtlib/shared/extensioninfo.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical build regressions remain: cache writes can fail before the build directory exists, and root-package renaming breaks Arcade VM source exclusions.

3 open issues
2 previously missed issues

In code that hasn't changed since last review

High severity Preserve native root paths when canonicalizing project names

pxtlib/​shared/​extensioninfo.ts:1015

Arcade's hw---vm root package supplies sdlmain.cpp, and the bundled VM Makefile excludes pxtapp/hw---vm/sdlmain.o. Renaming that root to this makes the exclusion miss, so the regular build tries to compile the SDL source without its SDL flags. Preserve native paths for root libraries while canonicalizing user project display names, and keep prepared requests consistent.

Medium severity Record incoming build files before writing them

cli/​buildengine.ts:290

The new build-file list is persisted only after every file has been written. If a write fails or the process is interrupted after creating a new .mk file, the cache still lists only the previous files; a later build that omits that fragment will never remove it and may consume stale build settings. Persist the union of old and incoming build-file names before writing, then replace it with the final list after a successful write.

5 resolved since last review

Review effort: Max

Comment thread cli/buildengine.ts Resolved
Comment thread cli/cli.ts Resolved
Comment thread pxtlib/shared/packageutils.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical regressions silently omit non-bundled extension build fragments and mishandle project root identities, causing native build failures and dependency source overwrites.

1 open issue
3 resolved since last review

Review effort: Max

Comment thread pxtlib/shared/extensioninfo.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical bundle initialization and resolution defects can break builds or select the wrong board files, while incomplete cache cleanup can execute stale Makefiles.

5 open issues

Review effort: Max

Comment thread cli/buildengine.ts Resolved
Comment thread cli/cli.ts Resolved
Comment thread cli/cli.ts Resolved
Comment thread pxtlib/shared/packageutils.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The CLI defaults to cloud compilation, but refreshed local root-library .mk contents are omitted from cloud requests and leave projectCompileSha unchanged. Builds can therefore return an older cached HEX or compile the published bundle instead of the edited local files.

6 open issues
5 resolved since last review

Review effort: Max

Comment thread pxtlib/package.ts Outdated
Comment on lines +1211 to +1212
const files = this.host().getRootBundleFiles(this);
extensionTarget.bundledpkgs = { ...extensionTarget.bundledpkgs, [rootBundleId]: files };
Comment thread cli/cli.ts Resolved
Comment thread cli/cli.ts Resolved
Comment thread pxtlib/package.ts Resolved
Comment thread pxtlib/shared/extensioninfo.ts Resolved
Comment thread pxtlib/shared/extensioninfo.ts Outdated
Comment on lines +193 to +197
const bundleId = pkg.path && packageUtils.getBundledPackageId(
bundledPackages, pkg.id, pkg.config.name, pkg.version
);
const bundledFiles = pkg.path ? bundleId && U.lookup(bundledPackages, bundleId) : rootBundledFiles;
return bundledFiles && U.lookup(bundledFiles, name);

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Native builds can silently use incorrect scripts: dependency traversal can ignore an explicit board-specific core version after encountering a wildcard, while an unverified file-path basename can select another library’s bundled scripts. Separately, cloud builds cache output from published scripts under the local-content SHA, so a later --localbuild can reuse a binary that ignores local changes; legacy SHA cache hits also bypass migration cleanup, preserving stale scripts and binaries.

9 open issues
4 resolved since last review

Review effort: Max

Comment thread cli/buildengine.ts Outdated
const isBuildFile = (filename: string): boolean =>
filename == "/Makefile.inc" || pxt.packageUtils.isBuildFile(filename.slice(1));
const previousBuildFiles = buildCache.generatedBuildFiles || [];
if (!buildCache.generatedBuildFiles && buildCache.sha != null) {
Comment thread cli/cli.ts Outdated
Comment on lines 3587 to 3589
if (extInfo.localBuildFiles?.length)
pxt.warn(`Cloud compilation uses the target's published build files and will ignore local changes to: ${extInfo.localBuildFiles.join(", ")}. Use --localbuild to compile with these local files.`);
return pxt.hexloader.getHexInfoAsync(this, extInfo)
Comment thread pxtlib/shared/extensioninfo.ts Outdated
Comment on lines 228 to 229
for (const dep of Object.keys(deps).sort())
visit(dep, deps[dep], runtime);
Comment thread pxtlib/shared/packageutils.ts Outdated
Comment on lines +45 to +46
const bundleId = parts.pop();
if (bundleId && U.lookup(bundledPackages, bundleId)) return bundleId;
Comment thread cli/buildengine.ts Outdated
Comment on lines +282 to +284
for (const bundledFiles of U.values(pxt.appTarget.bundledpkgs || {})) {
for (const filename of Object.keys(bundledFiles).filter(pxt.packageUtils.isBuildFile))
previousBuildFiles.push("/" + filename);
Comment thread pxtlib/package.ts Outdated
Comment on lines +1188 to +1191
dep => {
const dependency = this.resolveDep(dep);
return !!dependency && !dependency.cppOnly;
},
Comment thread pxtlib/package.ts
}
if (target.isNative) {
cpp.injectProjectCompileData(einfo, extensionFiles, extensionTarget, compileVariant);
cpp.injectProjectCompileData(einfo, extensionFiles, extensionTarget, compileVariant, rootBundleId);
Share package preparation between extension generation and project requests.
Align target-library handling and generated-file tracking, and add an
opt-in native-build bypass for target CI.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e5d3cd25-3179-40c4-a283-1469f3dcc50e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants