diff --git a/source/dub/commandline.d b/source/dub/commandline.d index f21a6c0..9f371b8 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -207,11 +207,13 @@ if (!cmd.skipDubInitialization) { if (options.bare) { dub = new Dub(Path(getcwd())); + dub.defaultPlacementLocation = options.placementLocation; } else { // initialize DUB auto package_suppliers = options.registry_urls.map!(url => cast(PackageSupplier)new RegistryPackageSupplier(URL(url))).array; dub = new Dub(options.root_path, package_suppliers, options.skipRegistry); dub.dryRun = options.annotate; + dub.defaultPlacementLocation = options.placementLocation; // make the CWD package available so that for example sub packages can reference their // parent package. @@ -244,6 +246,7 @@ string[] registry_urls; string root_path; SkipPackageSuppliers skipRegistry = SkipPackageSuppliers.none; + PlacementLocation placementLocation = PlacementLocation.user; /// Parses all common options and stores the result in the struct instance. void prepare(CommandArgs args) @@ -263,7 +266,7 @@ args.getopt("vverbose", &vverbose, ["Print debug output"]); args.getopt("q|quiet", &quiet, ["Only print warnings and errors"]); args.getopt("vquiet", &vquiet, ["Print no messages"]); - args.getopt("cache", &defaultPlacementLocation, ["Puts any fetched packages in the specified location [local|system|user]."]); + args.getopt("cache", &placementLocation, ["Puts any fetched packages in the specified location [local|system|user]."]); } } @@ -1153,7 +1156,7 @@ enforceUsage(free_args.length == 1, "Expecting exactly one argument."); enforceUsage(app_args.length == 0, "Unexpected application arguments."); - auto location = defaultPlacementLocation; + auto location = dub.defaultPlacementLocation; if (m_local) { logWarn("--local is deprecated. Use --cache=local instead."); @@ -1221,7 +1224,7 @@ enforceUsage(app_args.length == 0, "Unexpected application arguments."); auto package_id = free_args[0]; - auto location = defaultPlacementLocation; + auto location = dub.defaultPlacementLocation; if (m_local) { logWarn("--local is deprecated. Use --cache=local instead."); diff --git a/source/dub/dub.d b/source/dub/dub.d index 35a5b12..7ccd7cd 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -90,6 +90,15 @@ Path m_overrideSearchPath; } + /** The default placement location of fetched packages. + + This property can be altered, so that packages which are downloaded as part + of the normal upgrade process are stored in a certain location. This is + how the "--local" and "--system" command line switches operate. + */ + PlacementLocation defaultPlacementLocation = PlacementLocation.user; + + /** Initializes the instance for use with a specific root package. Note that a package still has to be loaded using one of the @@ -1255,7 +1264,7 @@ FetchOptions fetchOpts; fetchOpts |= prerelease ? FetchOptions.usePrerelease : FetchOptions.none; fetchOpts |= (m_options & UpgradeOptions.forceRemove) != 0 ? FetchOptions.forceRemove : FetchOptions.none; - m_dub.fetch(rootpack, dep, defaultPlacementLocation, fetchOpts, "need sub package description"); + m_dub.fetch(rootpack, dep, m_dub.defaultPlacementLocation, fetchOpts, "need sub package description"); auto ret = m_dub.m_packageManager.getBestPackage(name, dep); if (!ret) { logWarn("Package %s %s doesn't have a sub package %s", rootpack, dep.version_, name); diff --git a/source/dub/project.d b/source/dub/project.d index 78d7153..22f0978 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -1188,14 +1188,6 @@ system } -/** The default placement location of fetched packages. - - This property can be altered, so that packages which are downloaded as part - of the normal upgrade process are stored in a certain location. This is - how the "--local" and "--system" command line switches operate. -*/ -PlacementLocation defaultPlacementLocation = PlacementLocation.user; - void processVars(ref BuildSettings dst, in Project project, in Package pack, BuildSettings settings, bool include_target_settings = false) {