@@ -1368,17 +1368,17 @@ prepare_build(bool print_fingerprint,
13681368 }
13691369
13701370 // Set up project-level .mcpp/ directory for custom indices.
1371- // This creates .mcpp/.xlings.json with non-builtin, non-local index
1371+ // This creates .mcpp/.xlings.json with custom non-builtin index
13721372 // entries so xlings can clone them into the project-scoped data dir.
13731373 if (!m->indices .empty ()) {
13741374 auto cfg2 = get_cfg ();
13751375 if (cfg2) {
13761376 mcpp::config::ensure_project_index_dir (**cfg2, *root, m->indices );
13771377
1378- // On first build, .mcpp/ data/ may be empty because
1378+ // On first build, the project xlings data root may be empty because
13791379 // ensure_project_index_dir only writes .xlings.json but doesn't
13801380 // trigger clone/link creation. Check whether there are any custom
1381- // non-builtin indices and whether .mcpp/ data/ has index content.
1381+ // non-builtin indices and whether the project data roots have index content.
13821382 // If not, run xlings update before dependency resolution.
13831383 bool hasCustomIndices = false ;
13841384 for (auto & [idxName, spec] : m->indices ) {
@@ -1388,22 +1388,7 @@ prepare_build(bool print_fingerprint,
13881388 }
13891389 }
13901390 if (hasCustomIndices) {
1391- auto dataDir = *root / " .mcpp" / " data" ;
1392- bool needsClone = !std::filesystem::exists (dataDir);
1393- if (!needsClone) {
1394- // Check if data/ has any index directories (dirs with pkgs/ subdir)
1395- std::error_code ec;
1396- bool hasIndexRepo = false ;
1397- if (std::filesystem::is_directory (dataDir, ec)) {
1398- for (auto & entry : std::filesystem::directory_iterator (dataDir, ec)) {
1399- if (entry.is_directory () && std::filesystem::exists (entry.path () / " pkgs" )) {
1400- hasIndexRepo = true ;
1401- break ;
1402- }
1403- }
1404- }
1405- needsClone = !hasIndexRepo;
1406- }
1391+ bool needsClone = !mcpp::config::project_index_data_initialized (*root);
14071392 if (needsClone) {
14081393 mcpp::ui::status (" Fetching" , " custom index repos (first use)" );
14091394 auto projEnv = mcpp::config::make_project_xlings_env (**cfg2, *root);
@@ -1513,17 +1498,18 @@ prepare_build(bool print_fingerprint,
15131498 // validate the lua exists, then fall through to the normal install
15141499 // flow below.
15151500 if (idxSpec && idxSpec->is_local ()) {
1501+ auto indexPath = mcpp::config::resolve_project_index_path (*root, *idxSpec);
15161502 auto luaCheck = mcpp::fetcher::Fetcher::read_xpkg_lua_from_path (
1517- idxSpec-> path , shortName);
1503+ indexPath , shortName);
15181504 if (!luaCheck) return std::unexpected (std::format (
15191505 " dependency '{}': not found in local index at '{}'" ,
1520- depName, idxSpec-> path .string ()));
1506+ depName, indexPath .string ()));
15211507 // lua found — fall through to normal install path resolution.
15221508 }
15231509
15241510 const bool useProjectEnv = idxSpec && !idxSpec->is_builtin ();
15251511
1526- // For custom indices, try project-level .mcpp/ data/ first.
1512+ // For custom indices, try project-level xlings data roots first.
15271513 std::optional<std::filesystem::path> installed;
15281514 if (useProjectEnv) {
15291515 installed = mcpp::fetcher::Fetcher::install_path_from_project_data (
@@ -1798,7 +1784,7 @@ prepare_build(bool print_fingerprint,
17981784 auto & spec = item.spec ;
17991785
18001786 mcpp::pm::compat::normalize_nested_namespace (
1801- spec.namespace_ , spec.shortName );
1787+ spec.namespace_ , spec.shortName , spec. legacyDottedKey );
18021788
18031789 // Pin SemVer constraint before dedup/fetch.
18041790 if (auto r = resolveSemver (spec, name); !r) {
@@ -2965,7 +2951,7 @@ int cmd_index_update(const mcpplibs::cmdline::ParsedArgs& parsed) {
29652951 } else {
29662952 mcpp::ui::status (" Updated" , std::format (" project index `{}`" , idxName));
29672953 }
2968- break ; // ensure_project_index_dir handles all non-local indices at once
2954+ break ; // ensure_project_index_dir handles all custom indices at once
29692955 }
29702956 }
29712957 }
0 commit comments