diff --git a/source/dub/commandline.d b/source/dub/commandline.d index d93ad4d..117b390 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -72,6 +72,7 @@ common_args.getopt("vverbose", &vverbose, ["Print debug output"]); common_args.getopt("q|quiet", &quiet, ["Only print warnings and errors"]); common_args.getopt("vquiet", &vquiet, ["Print no messages"]); + common_args.getopt("cache", &defaultPlacementLocation, ["Puts any fetched packages in the specified location [local|system|user]."]); if( vverbose ) loglevel = LogLevel.debug_; else if( verbose ) loglevel = LogLevel.diagnostic; @@ -185,7 +186,7 @@ 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)); @@ -501,7 +502,7 @@ } setupPackage(dub, package_name); - + if (m_printBuilds) { // FIXME: use actual package data logInfo("Available build types:"); foreach (tp; ["debug", "release", "unittest", "profile"]) @@ -697,7 +698,7 @@ m_defaultConfig = dub.project.getDefaultConfiguration(m_buildPlatform); - dub.describeProject(m_buildPlatform, m_buildConfig.length ? m_buildConfig : m_defaultConfig); + dub.describeProject(m_buildPlatform, m_buildConfig.length ? m_buildConfig : m_defaultConfig); return 0; } } @@ -807,9 +808,9 @@ class FetchRemoveCommand : Command { protected { string m_version; + bool m_forceRemove = false; bool m_system = false; bool m_local = false; - bool m_forceRemove = false; } override void prepare(scope CommandArgs args) @@ -819,8 +820,8 @@ "The remove command also accepts \"*\" here as a wildcard to remove all versions of the package from the specified location" ]); - args.getopt("system", &m_system, ["Puts the package into the system wide package cache instead of the user local one."]); - args.getopt("local", &m_local, ["Puts the package into a sub folder of the current working directory. Cannot be mixed with --system."]); + args.getopt("system", &m_system, ["Deprecated: Puts the package into the system wide package cache instead of the user local one."]); + args.getopt("local", &m_local, ["Deprecated: Puts the package into a sub folder of the current working directory. Cannot be mixed with --system."]); args.getopt("force-remove", &m_forceRemove, [ "Force deletion of fetched packages with untracked files" ]); @@ -864,9 +865,17 @@ enforceUsage(free_args.length == 1, "Expecting exactly one argument."); enforceUsage(app_args.length == 0, "Unexpected application arguments."); - auto location = PlacementLocation.userWide; - if (m_local) location = PlacementLocation.local; - else if (m_system) location = PlacementLocation.systemWide; + auto location = defaultPlacementLocation; + if (m_local) + { + logWarn("--local is deprecated. Use --cache=local instead."); + location = PlacementLocation.local; + } + else if (m_system) + { + logWarn("--system is deprecated. Use --cache=system instead."); + location = PlacementLocation.system; + } auto name = free_args[0]; @@ -878,7 +887,7 @@ try { dub.fetch(name, Dependency(">=0.0.0"), location, fetchOpts); logInfo( - "Please note that you need to use `dub run ` " ~ + "Please note that you need to use `dub run ` " ~ "or add it to dependencies of your package to actually use/run it. " ~ "dub does not do actual installation of packages outside of its own ecosystem."); } @@ -920,14 +929,21 @@ override int execute(Dub dub, string[] free_args, string[] app_args) { - enforceUsage(!m_local || !m_system, "--local and --system are exclusive to each other."); enforceUsage(free_args.length == 1, "Expecting exactly one argument."); enforceUsage(app_args.length == 0, "Unexpected application arguments."); auto package_id = free_args[0]; - auto location = PlacementLocation.userWide; - if (m_local) location = PlacementLocation.local; - else if (m_system) location = PlacementLocation.systemWide; + auto location = defaultPlacementLocation; + if (m_local) + { + logWarn("--local is deprecated. Use --cache=local instead."); + location = PlacementLocation.local; + } + else if (m_system) + { + logWarn("--system is deprecated. Use --cache=system instead."); + location = PlacementLocation.system; + } dub.remove(package_id, m_version, location, m_forceRemove); return 0; @@ -1360,7 +1376,7 @@ Manages the DUB project in the current directory. If the command is omitted, DUB will default to "run". When running an application, "--" can be used to -separate DUB options from options passed to the application. +separate DUB options from options passed to the application. Run "dub --help" to get help for a specific command. @@ -1408,7 +1424,7 @@ writeln(); foreach (ln; cmd.helpText) ln.writeWrapped(); - + if (args.recognizedArgs.length) { writeln(); writeln(); @@ -1417,7 +1433,7 @@ writeln(); writeOptions(args); } - + writeln(); writeln(); writeln("Common options"); diff --git a/source/dub/dub.d b/source/dub/dub.d index 7d0b2c7..436f604 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -90,7 +90,7 @@ m_userDubPath = Path(getcwd()) ~ m_userDubPath; m_tempPath = Path("/tmp"); } - + m_userConfig = jsonFromFile(m_userDubPath ~ "settings.json", true); m_systemConfig = jsonFromFile(m_systemDubPath ~ "settings.json", true); @@ -214,7 +214,7 @@ FetchOptions fetchOpts; fetchOpts |= (options & UpgradeOptions.preRelease) != 0 ? FetchOptions.usePrerelease : FetchOptions.none; fetchOpts |= (options & UpgradeOptions.forceRemove) != 0 ? FetchOptions.forceRemove : FetchOptions.none; - if (!pack) fetch(p, ver, PlacementLocation.userWide, fetchOpts); + if (!pack) fetch(p, ver, defaultPlacementLocation, fetchOpts); if ((options & UpgradeOptions.select) && ver.path.empty && p != m_project.rootPackage.name) m_project.selections.selectVersion(p, ver.version_); } @@ -233,7 +233,7 @@ generator.generate(settings); } - /// Executes tests on the current project. Throws an exception, if + /// Executes tests on the current project. Throws an exception, if /// unittests failed. void testProject(GeneratorSettings settings, string config, Path custom_main_file) { @@ -260,7 +260,7 @@ logInfo(`Configuration '%s' has target type "none". Skipping test.`, config); return; } - + if (lbuildsettings.targetType == TargetType.executable) { if (config == "unittest") logInfo("Running custom 'unittest' configuration.", config); else logInfo(`Configuration '%s' does not output a library. Falling back to "dub -b unittest -c %s".`, config, config); @@ -357,7 +357,7 @@ { logInfo("Cleaning package at %s...", path.toNativeString()); enforce(Package.isPackageAt(path), "No package found.", path.toNativeString()); - + // TODO: clear target files and copy files if (existsFile(path ~ ".dub/build")) rmdirRecurse((path ~ ".dub/build").toNativeString()); @@ -389,8 +389,8 @@ Path placement; final switch (location) { case PlacementLocation.local: placement = m_rootPath; break; - case PlacementLocation.userWide: placement = m_userDubPath ~ "packages/"; break; - case PlacementLocation.systemWide: placement = m_systemDubPath ~ "packages/"; break; + case PlacementLocation.user: placement = m_userDubPath ~ "packages/"; break; + case PlacementLocation.system: placement = m_systemDubPath ~ "packages/"; break; } // always upgrade branch based versions - TODO: actually check if there is a new commit available @@ -444,10 +444,10 @@ /// @see remove(string, string, RemoveLocation) enum RemoveVersionWildcard = "*"; - /// This will remove a given package with a specified version from the + /// This will remove a given package with a specified version from the /// location. - /// It will remove at most one package, unless @param version_ is - /// specified as wildcard "*". + /// It will remove at most one package, unless @param version_ is + /// specified as wildcard "*". /// @param package_id Package to be removed /// @param version_ Identifying a version or a wild card. An empty string /// may be passed into. In this case the package will be removed from the @@ -482,7 +482,7 @@ logError("Cannot remove package '" ~ package_id ~ "', there are multiple possibilities at location\n" ~ "'" ~ to!string(location_) ~ "'."); logError("Available versions:"); - foreach(pack; packages) + foreach(pack; packages) logError(" %s", pack.vers); throw new Exception("Please specify a individual version using --version=... or use the" ~ " wildcard --version=" ~ RemoveVersionWildcard ~ " to remove all versions."); @@ -545,7 +545,7 @@ if (!ddox_pack) ddox_pack = m_packageManager.getBestPackage("ddox", "~master"); if (!ddox_pack) { logInfo("DDOX is not present, getting it and storing user wide"); - ddox_pack = fetch("ddox", Dependency(">=0.0.0"), PlacementLocation.userWide, FetchOptions.none); + ddox_pack = fetch("ddox", Dependency(">=0.0.0"), defaultPlacementLocation, FetchOptions.none); } version(Windows) auto ddox_exe = "ddox.exe"; @@ -790,7 +790,7 @@ FetchOptions fetchOpts; fetchOpts |= prerelease ? FetchOptions.usePrerelease : FetchOptions.none; fetchOpts |= (m_options & UpgradeOptions.forceRemove) != 0 ? FetchOptions.forceRemove : FetchOptions.none; - m_dub.fetch(rootpack, dep, PlacementLocation.userWide, fetchOpts); + m_dub.fetch(rootpack, dep, defaultPlacementLocation, fetchOpts); 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/internal/vibecompat/inet/path.d b/source/dub/internal/vibecompat/inet/path.d index 7525a10..c88e8c3 100644 --- a/source/dub/internal/vibecompat/inet/path.d +++ b/source/dub/internal/vibecompat/inet/path.d @@ -84,7 +84,19 @@ Appender!string ret; // for absolute paths start with / - if( absolute ) ret.put('/'); + version(Windows) + { + // Make sure windows path isn't "DRIVE:" + if( absolute && !m_nodes[0].toString().endsWith(':') ) + ret.put('/'); + } + else + { + if( absolute ) + { + ret.put('/'); + } + } foreach( i, f; m_nodes ){ if( i > 0 ) ret.put('/'); diff --git a/source/dub/project.d b/source/dub/project.d index 4e63ce4..6dd0a03 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -53,7 +53,7 @@ json.name = "unknown"; pack = new Package(json, project_path); } else { - pack = package_manager.getOrLoadPackage(project_path); + pack = package_manager.getOrLoadPackage(project_path); } this(package_manager, pack); @@ -103,7 +103,7 @@ /// List of retrieved dependency Packages @property const(Package[]) dependencies() const { return m_dependencies; } - + /// Main package. @property inout(Package) rootPackage() inout { return m_rootPackage; } @@ -115,7 +115,7 @@ int delegate(int delegate(ref const Package)) getTopologicalPackageList(bool children_first = false, in Package root_package = null, string[string] configs = null) const { const(Package) rootpack = root_package ? root_package : m_rootPackage; - + int iterator(int delegate(ref const Package) del) { int ret = 0; @@ -147,7 +147,7 @@ perform_rec(rootpack); return ret; } - + return &iterator; } @@ -256,7 +256,7 @@ @property string[] configurations() const { return m_rootPackage.configurations; } - /// Returns a map with the configuration for all packages in the dependency tree. + /// Returns a map with the configuration for all packages in the dependency tree. string[string] getPackageConfigs(in BuildPlatform platform, string config, bool allow_non_library = true) const { struct Vertex { string pack, config; } @@ -431,7 +431,7 @@ /** * Fills dst with values from this project. * - * dst gets initialized according to the given platform and config. + * dst gets initialized according to the given platform and config. * * Params: * dst = The BuildSettings struct to fill with data. @@ -450,7 +450,7 @@ assert(pkg.name in configs, "Missing configuration for "~pkg.name); logDebug("Gathering build settings for %s (%s)", pkg.name, configs[pkg.name]); - + auto psettings = pkg.getBuildSettings(platform, configs[pkg.name]); if (psettings.targetType != TargetType.none) { if (shallow && pkg !is m_rootPackage) @@ -564,7 +564,7 @@ } catch(Exception t) return true; } else return false; } - + private void markUpToDate(string packageId) { logDebug("markUpToDate(%s)", packageId); Json create(ref Json json, string object) { @@ -626,12 +626,12 @@ static Action conflict(string pkg, in Dependency dep, Dependency[string] context) { - return Action(Type.conflict, pkg, PlacementLocation.userWide, dep, context); + return Action(Type.conflict, pkg, PlacementLocation.user, dep, context); } static Action failure(string pkg, in Dependency dep, Dependency[string] context) { - return Action(Type.failure, pkg, PlacementLocation.userWide, dep, context); + return Action(Type.failure, pkg, PlacementLocation.user, dep, context); } private this(Type id, string pkg, PlacementLocation location, in Dependency d, Dependency[string] issue, Version existing_version = Version.UNKNOWN) @@ -661,18 +661,22 @@ /// Indicates where a package has been or should be placed to. enum PlacementLocation { - /// Packages retrived with 'local' will be placed in the current folder + /// Packages retrived with 'local' will be placed in the current folder /// using the package name as destination. local, /// Packages with 'userWide' will be placed in a folder accessible by /// all of the applications from the current user. - userWide, + user, /// Packages retrieved with 'systemWide' will be placed in a shared folder, /// which can be accessed by all users of the system. - systemWide + system } +/// The default placement location of fetched packages. Can be changed by --local or --system. +auto defaultPlacementLocation = PlacementLocation.user; + void processVars(ref BuildSettings dst, in Project project, in Package pack, BuildSettings settings, bool include_target_settings = false) + { dst.addDFlags(processVars(project, pack, settings.dflags)); dst.addLFlags(processVars(project, pack, settings.lflags)); @@ -761,7 +765,7 @@ if (prj.name.toUpper().replace("-", "_") == pname) return prj.path.toNativeString(); } - + if (auto envvar = environment.get(name)) return envvar; throw new Exception("Invalid variable: "~name); @@ -772,7 +776,7 @@ return ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z' || ch >= '0' && ch <= '9' || ch == '_'; } -string stripDlangSpecialChars(string s) +string stripDlangSpecialChars(string s) { import std.array; import std.uni; @@ -785,7 +789,7 @@ final class SelectedVersions { private struct Selected { Dependency dep; - //Dependency[string] packages; + //Dependency[string] packages; } private { enum FileVersion = 1;