diff --git a/source/dub/commandline.d b/source/dub/commandline.d index a5bba0a..8540826 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -157,15 +157,19 @@ return 1; } - // initialize DUB - auto package_suppliers = registry_urls.map!(url => cast(PackageSupplier)new RegistryPackageSupplier(Url(url))).array; - Dub dub = new Dub(package_suppliers, root_path); - dub.dryRun = annotate; + Dub dub; + + if (!cmd.skipDubInitialization) { + // initialize DUB + auto package_suppliers = registry_urls.map!(url => cast(PackageSupplier)new RegistryPackageSupplier(Url(url))).array; + dub = new Dub(package_suppliers, root_path); + dub.dryRun = annotate; - // make the CWD package available so that for example sub packages can reference their - // parent package. - try dub.packageManager.getTemporaryPackage(Path(root_path)); - catch (Exception e) { logDiagnostic("No package found in current working directory."); } + // make the CWD package available so that for example sub packages can reference their + // parent package. + try dub.packageManager.getTemporaryPackage(Path(root_path)); + catch (Exception e) { logDiagnostic("No package found in current working directory."); } + } try return cmd.execute(dub, remaining_args, app_args); catch (UsageException e) { @@ -243,6 +247,7 @@ string[] helpText; bool acceptsAppArgs; bool hidden = false; // used for deprecated commands + bool skipDubInitialization = false; abstract void prepare(scope CommandArgs args); abstract int execute(Dub dub, string[] free_args, string[] app_args); @@ -968,12 +973,15 @@ args.getopt("test-package", &m_testPackage, ["Perform a test run - usually only used internally"]); args.getopt("combined", &m_combined, ["Builds multiple packages with one compiler run"]); super.prepare(args); + + // speed up loading when in test mode + if (m_testPackage.length) skipDubInitialization = true; } override int execute(Dub dub, string[] free_args, string[] app_args) { if (m_testPackage.length) { - dub.overrideSearchPath(Path(getcwd())); + dub = new Dub(Path(getcwd())); setupPackage(dub, m_testPackage); m_defaultConfig = dub.project.getDefaultConfiguration(m_buildPlatform); diff --git a/source/dub/dub.d b/source/dub/dub.d index a9af064..fa207a7 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -94,7 +94,15 @@ ps ~= defaultPackageSuppliers(); m_packageSuppliers = ps; - m_packageManager = new PackageManager(m_userDubPath, m_systemDubPath); + m_packageManager = new PackageManager(m_userDubPath, m_systemDubPath, false); + updatePackageSearchPath(); + } + + /// Initializes DUB with only a single search path + this(Path override_path) + { + m_overrideSearchPath = override_path; + m_packageManager = new PackageManager(Path(), Path(), false); updatePackageSearchPath(); } diff --git a/source/dub/packagemanager.d b/source/dub/packagemanager.d index f9adf14..216ed6a 100644 --- a/source/dub/packagemanager.d +++ b/source/dub/packagemanager.d @@ -59,11 +59,11 @@ bool m_disableDefaultSearchPaths = false; } - this(Path user_path, Path system_path) + this(Path user_path, Path system_path, bool refresh_packages = true) { m_repositories[LocalPackageType.user] = Repository(user_path); m_repositories[LocalPackageType.system] = Repository(system_path); - refresh(true); + if (refresh_packages) refresh(true); } @property void searchPath(Path[] paths) { m_searchPath = paths.dup; refresh(false); }