diff --git a/CHANGELOG.md b/CHANGELOG.md index d6ac803..6789309 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,7 +58,7 @@ - Fixed using custom registries in the global DUB configuration file - [issue #186][issue186] - Fixed assertions triggering when `$HOME` is a relative path (by Ognjen Ivkovic) - [pull #192][issue192] - Fixed the VisualD project generator to enforce build requirements - - Fixed build requirements to also affect comipler options of the selected build + - Fixed build requirements to also affect comipler options of the selected build - Fixed configuration resolution for complex dependency graphs (it could happen that configurations were picked that can't work on the selected platform) - Fixed `dub build -b ddox` to only copy resource files from DDOX if they are newer than existing files on Posix - Fixed storing sub packages when the modified package description is written after fetching a package diff --git a/examples/app/source/app.d b/examples/app/source/app.d index ba308f1..1fa5bc3 100644 --- a/examples/app/source/app.d +++ b/examples/app/source/app.d @@ -1,6 +1,6 @@ import std.stdio; void main() -{ +{ writeln("Hello, World."); } diff --git a/examples/lib/source/lib.d b/examples/lib/source/lib.d index 345d027..a1bc27e 100644 --- a/examples/lib/source/lib.d +++ b/examples/lib/source/lib.d @@ -3,6 +3,6 @@ import std.stdio; void test() -{ +{ writeln("Hello, World."); } diff --git a/examples/mixed/source/app.d b/examples/mixed/source/app.d index c558c9e..3e95fb2 100644 --- a/examples/mixed/source/app.d +++ b/examples/mixed/source/app.d @@ -3,6 +3,6 @@ import lib; void main() -{ +{ test(); } diff --git a/installer/win/EnvVarUpdate.nsh b/installer/win/EnvVarUpdate.nsh index e684da8..b67e3ba 100644 --- a/installer/win/EnvVarUpdate.nsh +++ b/installer/win/EnvVarUpdate.nsh @@ -9,14 +9,14 @@ * ${EnvVarUpdate} "ResultVar" "EnvVarName" "Action" "RegLoc" "PathString" * * Credits: - * Version 1.0 + * Version 1.0 * * Cal Turney (turnec2) * * Amir Szekely (KiCHiK) and e-circ for developing the forerunners of this * function: AddToPath, un.RemoveFromPath, AddToEnvVar, un.RemoveFromEnvVar, * WriteEnvStr, and un.DeleteEnvStr * * Diego Pedroso (deguix) for StrTok * * Kevin English (kenglish_hi) for StrContains - * * Hendri Adriaens (Smile2Me), Diego Pedroso (deguix), and Dan Fuhry + * * Hendri Adriaens (Smile2Me), Diego Pedroso (deguix), and Dan Fuhry * (dandaman32) for StrReplace * * Version 1.1 (compatibility with StrFunc.nsh) @@ -25,8 +25,8 @@ * http://nsis.sourceforge.net/Environmental_Variables:_append%2C_prepend%2C_and_remove_entries * */ - - + + !ifndef ENVVARUPDATE_FUNCTION !define ENVVARUPDATE_FUNCTION !verbose push @@ -34,7 +34,7 @@ !include "LogicLib.nsh" !include "WinMessages.NSH" !include "StrFunc.nsh" - + ; ---- Fix for conflict if StrFunc.nsh is already includes in main file ----------------------- !macro _IncludeStrFunction StrFuncName !ifndef ${StrFuncName}_INCLUDED @@ -45,11 +45,11 @@ !endif !define un.${StrFuncName} "${Un${StrFuncName}}" !macroend - + !insertmacro _IncludeStrFunction StrTok !insertmacro _IncludeStrFunction StrStr !insertmacro _IncludeStrFunction StrRep - + ; ---------------------------------- Macro Definitions ---------------------------------------- !macro _EnvVarUpdateConstructor ResultVar EnvVarName Action Regloc PathString Push "${EnvVarName}" @@ -60,7 +60,7 @@ Pop "${ResultVar}" !macroend !define EnvVarUpdate '!insertmacro "_EnvVarUpdateConstructor"' - + !macro _unEnvVarUpdateConstructor ResultVar EnvVarName Action Regloc PathString Push "${EnvVarName}" Push "${Action}" @@ -71,15 +71,15 @@ !macroend !define un.EnvVarUpdate '!insertmacro "_unEnvVarUpdateConstructor"' ; ---------------------------------- Macro Definitions end------------------------------------- - + ;----------------------------------- EnvVarUpdate start---------------------------------------- !define hklm_all_users 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' !define hkcu_current_user 'HKCU "Environment"' - + !macro EnvVarUpdate UN - + Function ${UN}EnvVarUpdate - + Push $0 Exch 4 Exch $1 @@ -95,7 +95,7 @@ Push $8 Push $9 Push $R0 - + /* After this point: ------------------------- $0 = ResultVar (returned) @@ -109,7 +109,7 @@ $8 = Entry counter (temp) $9 = tempstr2 (temp) $R0 = tempChar (temp) */ - + ; Step 1: Read contents of EnvVarName from RegLoc ; ; Check for empty EnvVarName @@ -118,7 +118,7 @@ DetailPrint "ERROR: EnvVarName is blank" Goto EnvVarUpdate_Restore_Vars ${EndIf} - + ; Check for valid Action ${If} $2 != "A" ${AndIf} $2 != "P" @@ -127,7 +127,7 @@ DetailPrint "ERROR: Invalid Action - must be A, P, or R" Goto EnvVarUpdate_Restore_Vars ${EndIf} - + ${If} $3 == HKLM ReadRegStr $5 ${hklm_all_users} $1 ; Get EnvVarName from all users into $5 ${ElseIf} $3 == HKCU @@ -137,7 +137,7 @@ DetailPrint 'ERROR: Action is [$3] but must be "HKLM" or HKCU"' Goto EnvVarUpdate_Restore_Vars ${EndIf} - + ; Check for empty PathString ${If} $4 == "" SetErrors @@ -147,12 +147,12 @@ ;;khc - here check if length is going to be greater then max string length ;; and abort if so - also abort if original path empty - may mean - ;; it was too long as well- write message to say set it by hand + ;; it was too long as well- write message to say set it by hand Push $6 Push $7 Push $8 - StrLen $7 $4 + StrLen $7 $4 StrLen $6 $5 IntOp $8 $6 + $7 ${If} $5 == "" @@ -176,7 +176,7 @@ DetailPrint "$1 is empty - Nothing to remove" Goto EnvVarUpdate_Restore_Vars ${EndIf} - + ; Step 2: Scrub EnvVar ; StrCpy $0 $5 ; Copy the contents to $0 @@ -198,13 +198,13 @@ ${${UN}StrRep} $0 $0 "; " ";" ; Remove ';' ${Loop} ${Do} - ${${UN}StrStr} $7 $0 ";;" + ${${UN}StrStr} $7 $0 ";;" ${If} $7 == "" ${ExitDo} ${EndIf} ${${UN}StrRep} $0 $0 ";;" ";" ${Loop} - + ; Remove a leading or trailing semicolon from EnvVar StrCpy $7 $0 1 0 ${If} $7 == ";" @@ -218,27 +218,27 @@ ${EndIf} ; DetailPrint "Scrubbed $1: [$0]" ; Uncomment to debug ${EndIf} - + /* Step 3. Remove all instances of the target path/string (even if "A" or "P") $6 = bool flag (1 = found and removed PathString) $7 = a string (e.g. path) delimited by semicolon(s) $8 = entry counter starting at 0 $9 = copy of $0 $R0 = tempChar */ - + ${If} $5 != "" ; If EnvVar is not empty ... StrCpy $9 $0 StrCpy $0 "" StrCpy $8 0 StrCpy $6 0 - + ${Do} ${${UN}StrTok} $7 $9 ";" $8 "0" ; $7 = next entry, $8 = entry counter - + ${If} $7 == "" ; If we've run out of entries, ${ExitDo} ; were done ${EndIf} ; - + ; Remove leading and trailing spaces from this entry (critical step for Action=Remove) ${Do} StrCpy $R0 $7 1 @@ -263,11 +263,11 @@ ${AndIf} $0 != "" ; and this is NOT the 1st string to be added to $0, StrCpy $0 $0;$7 ; append path to $0 with a prepended semicolon ${EndIf} ; - + IntOp $8 $8 + 1 ; Bump counter ${Loop} ; Check for duplicates until we run out of paths ${EndIf} - + ; Step 4: Perform the requested Action ; ${If} $2 != "R" ; If Append or Prepend @@ -305,7 +305,7 @@ DetailPrint "$1 is now empty" ${EndIf} ${EndIf} - + ; Step 5: Update the registry at RegLoc with the updated EnvVar and announce the change ; ClearErrors @@ -314,15 +314,15 @@ ${ElseIf} $3 == HKCU WriteRegExpandStr ${hkcu_current_user} $1 $0 ; Write it to current user section ${EndIf} - + IfErrors 0 +4 MessageBox MB_OK|MB_ICONEXCLAMATION "Could not write updated $1 to $3" DetailPrint "Could not write updated $1 to $3" Goto EnvVarUpdate_Restore_Vars - + ; "Export" our change SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=1 - + EnvVarUpdate_Restore_Vars: ; ; Restore the user's variables and return ResultVar @@ -339,13 +339,13 @@ Push $0 ; Push my $0 (ResultVar) Exch Pop $0 ; Restore his $0 - + FunctionEnd - + !macroend ; EnvVarUpdate UN !insertmacro EnvVarUpdate "" !insertmacro EnvVarUpdate "un." ;----------------------------------- EnvVarUpdate end---------------------------------------- - + !verbose pop !endif diff --git a/installer/win/installer.nsi b/installer/win/installer.nsi index 09ec0db..6d880da 100644 --- a/installer/win/installer.nsi +++ b/installer/win/installer.nsi @@ -79,17 +79,17 @@ ; This section is mandatory SectionIn RO - + SetOutPath $INSTDIR - + ; Create installation directory CreateDirectory "$INSTDIR" - + File "${DubExecPath}\dub.exe" File "${DubExecPath}\libcurl.dll" File "${DubExecPath}\libeay32.dll" File "${DubExecPath}\ssleay32.dll" - + ; Create command line batch file FileOpen $0 "$INSTDIR\dubvars.bat" w FileWrite $0 "@echo.$\n" @@ -146,7 +146,7 @@ ; Remove the uninstaller Delete $INSTDIR\uninstall.exe - + ; Remove shortcuts Delete "$SMPROGRAMS\dub\dub Command Prompt.lnk" diff --git a/source/dub/compilers/compiler.d b/source/dub/compilers/compiler.d index 94f4767..44d4e08 100644 --- a/source/dub/compilers/compiler.d +++ b/source/dub/compilers/compiler.d @@ -41,7 +41,7 @@ if (name.canFind("dmd")) return getCompiler("dmd"); if (name.canFind("gdc")) return getCompiler("gdc"); if (name.canFind("ldc")) return getCompiler("ldc"); - + throw new Exception("Unknown compiler: "~name); } @@ -265,9 +265,9 @@ /// "-windows-dmd" /// /// Params: - /// specification = The specification being matched. It must be the empty string or start with a dash. + /// specification = The specification being matched. It must be the empty string or start with a dash. /// - /// Returns: + /// Returns: /// true if the given specification matches this BuildPlatform, false otherwise. (The empty string matches) /// bool matchesSpecification(const(char)[] specification) const { @@ -329,7 +329,7 @@ return settings.targetName ~ ".dll"; else return "lib" ~ settings.targetName ~ ".so"; } -} +} bool isLinkerFile(string f) @@ -355,7 +355,7 @@ import dub.internal.utils; auto path = getTempDir() ~ "dub_platform_probe.d"; - + auto fil = openFile(path, FileMode.CreateTrunc); scope (failure) { fil.close(); @@ -467,7 +467,7 @@ BuildPlatform readPlatformProbe(string output) { import std.string; - + // work around possible additional output of the compiler auto idx1 = output.indexOf("{"); auto idx2 = output.lastIndexOf("}"); diff --git a/source/dub/compilers/ldc.d b/source/dub/compilers/ldc.d index 45b51dd..dad1cf3 100644 --- a/source/dub/compilers/ldc.d +++ b/source/dub/compilers/ldc.d @@ -87,7 +87,7 @@ // since LDC always outputs multiple object files, avoid conflicts by default settings.addDFlags("-oq", "-od=.dub/obj"); - + if (!(fields & BuildSetting.versions)) { settings.addDFlags(settings.versions.map!(s => "-d-version="~s)().array()); settings.versions = null; diff --git a/source/dub/dependency.d b/source/dub/dependency.d index 26c01be..cef6935 100644 --- a/source/dub/dependency.d +++ b/source/dub/dependency.d @@ -25,7 +25,7 @@ /** - Representing a dependency, which is basically a version string and a + Representing a dependency, which is basically a version string and a compare methode, e.g. '>=1.0.0 <2.0.0' (i.e. a space separates the two version numbers) */ @@ -130,14 +130,14 @@ @property bool isExactVersion() const { return m_versA == m_versB; } @property Version version_() const { - enforce(m_versA == m_versB, "Dependency "~versionString()~" is no exact version."); - return m_versA; + enforce(m_versA == m_versB, "Dependency "~versionString()~" is no exact version."); + return m_versA; } @property string versionString() const { string r; - + if( m_versA == m_versB && m_cmpA == ">=" && m_cmpB == "<=" ){ // Special "==" case if (m_versA == Version.MASTER ) r = "~master"; @@ -235,8 +235,8 @@ bool opEquals(in Dependency o) const { // TODO(mdondorff): Check if not comparing the path is correct for all clients. - return o.m_cmpA == m_cmpA && o.m_cmpB == m_cmpB - && o.m_versA == m_versA && o.m_versB == m_versB + return o.m_cmpA == m_cmpA && o.m_cmpB == m_cmpB + && o.m_versA == m_versA && o.m_versB == m_versB && o.m_optional == m_optional; } @@ -257,12 +257,12 @@ return strhash(&str); } catch assert(false); } - + bool valid() const { return m_versA == m_versB // compare not important || (m_versA < m_versB && doCmp(m_cmpA, m_versB, m_versA) && doCmp(m_cmpB, m_versA, m_versB)); } - + bool matches(string vers) const { return matches(Version(vers)); } bool matches(const(Version) v) const { return matches(v); } bool matches(ref const(Version) v) const { @@ -281,7 +281,7 @@ return false; return true; } - + /// Merges to versions Dependency merge(ref const(Dependency) o) const { @@ -295,17 +295,17 @@ Version a = m_versA > o.m_versA ? m_versA : o.m_versA; Version b = m_versB < o.m_versB ? m_versB : o.m_versB; - + Dependency d = this; d.m_cmpA = !doCmp(m_cmpA, a,a)? m_cmpA : o.m_cmpA; d.m_versA = a; d.m_cmpB = !doCmp(m_cmpB, b,b)? m_cmpB : o.m_cmpB; d.m_versB = b; d.m_optional = m_optional && o.m_optional; - + return d; } - + private static bool isDigit(char ch) { return ch >= '0' && ch <= '9'; } private static string skipComp(ref string c) { size_t idx = 0; @@ -320,7 +320,7 @@ case "==": return cmp; } } - + private static bool doCmp(string mthd, ref const Version a, ref const Version b) { //logDebug("Calling %s%s%s", a, mthd, b); switch(mthd) { @@ -337,31 +337,31 @@ unittest { Dependency a = Dependency(">=1.1.0"), b = Dependency(">=1.3.0"); assert (a.merge(b).valid() && a.merge(b).versionString == ">=1.3.0", a.merge(b).toString()); - + a = Dependency("<=1.0.0 >=2.0.0"); assert (!a.valid(), a.toString()); - + a = Dependency(">=1.0.0 <=5.0.0"), b = Dependency(">=2.0.0"); assert (a.merge(b).valid() && a.merge(b).versionString == ">=2.0.0 <=5.0.0", a.merge(b).toString()); - + assertThrown(a = Dependency(">1.0.0 ==5.0.0"), "Construction is invalid"); - + a = Dependency(">1.0.0"), b = Dependency("<2.0.0"); assert (a.merge(b).valid(), a.merge(b).toString()); assert (a.merge(b).versionString == ">1.0.0 <2.0.0", a.merge(b).toString()); - + a = Dependency(">2.0.0"), b = Dependency("<1.0.0"); assert (!(a.merge(b)).valid(), a.merge(b).toString()); - + a = Dependency(">=2.0.0"), b = Dependency("<=1.0.0"); assert (!(a.merge(b)).valid(), a.merge(b).toString()); - + a = Dependency("==2.0.0"), b = Dependency("==1.0.0"); assert (!(a.merge(b)).valid(), a.merge(b).toString()); a = Dependency("1.0.0"), b = Dependency("==1.0.0"); assert (a == b); - + a = Dependency("<=2.0.0"), b = Dependency("==1.0.0"); Dependency m = a.merge(b); assert (m.valid(), m.toString()); @@ -472,7 +472,7 @@ This is subject to be removed soon. */ struct Version { - private { + private { enum MAX_VERS = "99999.0.0"; enum UNKNOWN_VERS = "unknown"; string m_version; @@ -484,7 +484,7 @@ static @property UNKNOWN() { return Version(UNKNOWN_VERS); } static @property MASTER_STRING() { return "~master"; } static @property BRANCH_IDENT() { return '~'; } - + this(string vers) { enforce(vers.length > 1, "Version strings must not be empty."); @@ -497,9 +497,9 @@ if (isUnknown || oth.isUnknown) { throw new Exception("Can't compare unknown versions! (this: %s, other: %s)".format(this, oth)); } - return m_version == oth.m_version; + return m_version == oth.m_version; } - + /// Returns true, if this version indicates a branch, which is not the trunk. @property bool isBranch() const { return !m_version.empty && m_version[0] == BRANCH_IDENT; } @property bool isMaster() const { return m_version == MASTER_STRING; } @@ -509,8 +509,8 @@ } @property bool isUnknown() const { return m_version == UNKNOWN_VERS; } - /** - Comparing Versions is generally possible, but comparing Versions + /** + Comparing Versions is generally possible, but comparing Versions identifying branches other than master will fail. Only equality can be tested for these. */ @@ -531,7 +531,7 @@ return compareVersions(isMaster ? MAX_VERS : m_version, other.isMaster ? MAX_VERS : other.m_version); } int opCmp(in Version other) const { return opCmp(other); } - + string toString() const { return m_version; } } @@ -566,16 +566,16 @@ assert(b < Version("0.0.0")); assert(a > Version("~Z")); assert(b < Version("~Z")); - + // SemVer 2.0.0-rc.2 a = Version("2.0.0-rc.2"); b = Version("2.0.0-rc.3"); assert(a < b, "Failed: 2.0.0-rc.2 < 2.0.0-rc.3"); - + a = Version("2.0.0-rc.2+build-metadata"); b = Version("2.0.0+build-metadata"); assert(a < b, "Failed: "~a.toString()~"<"~b.toString()); - + // 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0 Version[] versions; versions ~= Version("1.0.0-alpha"); diff --git a/source/dub/dependencyresolver.d b/source/dub/dependencyresolver.d index f8b5ac3..4fab2c9 100644 --- a/source/dub/dependencyresolver.d +++ b/source/dub/dependencyresolver.d @@ -71,7 +71,7 @@ { if (parent in visited) return; visited[parent] = true; - + foreach (ch; getChildren(parent)) { auto basepack = rootPackage(ch.pack); auto pidx = all_configs.length; diff --git a/source/dub/generators/build.d b/source/dub/generators/build.d index fbdcfcb..00bc4e6 100644 --- a/source/dub/generators/build.d +++ b/source/dub/generators/build.d @@ -1,6 +1,6 @@ /** Generator for direct compiler builds. - + Copyright: © 2013-2013 rejectedsoftware e.K. License: Subject to the terms of the MIT license, as written in the included LICENSE.txt file. Authors: Sönke Ludwig diff --git a/source/dub/generators/generator.d b/source/dub/generators/generator.d index 783bc13..081c67b 100644 --- a/source/dub/generators/generator.d +++ b/source/dub/generators/generator.d @@ -1,6 +1,6 @@ /** Generator for project files - + Copyright: © 2012-2013 Matthias Dondorff License: Subject to the terms of the MIT license, as written in the included LICENSE.txt file. Authors: Matthias Dondorff @@ -275,7 +275,7 @@ if (generate_binary) { if (!exists(buildsettings.targetPath)) mkdirRecurse(buildsettings.targetPath); - + if (buildsettings.copyFiles.length) { logInfo("Copying files for %s...", pack); foreach (f; buildsettings.copyFiles) { diff --git a/source/dub/generators/visuald.d b/source/dub/generators/visuald.d index db712af..86de079 100644 --- a/source/dub/generators/visuald.d +++ b/source/dub/generators/visuald.d @@ -1,6 +1,6 @@ /** Generator for VisualD project files - + Copyright: © 2012-2013 Matthias Dondorff License: Subject to the terms of the MIT license, as written in the included LICENSE.txt file. Authors: Matthias Dondorff @@ -36,13 +36,13 @@ PackageManager m_pkgMgr; string[string] m_projectUuids; } - + this(Project app, PackageManager mgr) { super(app); m_pkgMgr = mgr; } - + override void generateTargets(GeneratorSettings settings, in TargetInfo[string] targets) { auto bs = targets[m_project.name].buildSettings; @@ -58,7 +58,7 @@ auto ret = appender!(char[])(); auto configs = m_project.getPackageConfigs(settings.platform, settings.config); auto some_uuid = generateUUID(); - + // Solution header ret.put("Microsoft Visual Studio Solution File, Format Version 11.00\n"); ret.put("# Visual Studio 2010\n"); @@ -92,14 +92,14 @@ auto mainpack = m_project.rootPackage.name; generateSolutionEntry(mainpack); - + // Global section contains configurations ret.put("Global\n"); ret.put("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n"); ret.formattedWrite("\t\t%s|Win32 = %s|Win32\n", settings.buildType, settings.buildType); ret.put("\tEndGlobalSection\n"); ret.put("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n"); - + const string[] sub = ["ActiveCfg", "Build.0"]; const string[] conf = [settings.buildType~"|Win32"]; auto projectUuid = guid(mainpack); @@ -107,10 +107,10 @@ foreach (c; conf) foreach (s; sub) formattedWrite(ret, "\t\t%s.%s.%s = %s\n", guid(t), c, s, c); - + // TODO: for all dependencies ret.put("\tEndGlobalSection\n"); - + ret.put("\tGlobalSection(SolutionProperties) = preSolution\n"); ret.put("\t\tHideSolutionNode = FALSE\n"); ret.put("\tEndGlobalSection\n"); @@ -124,7 +124,7 @@ sln.flush(); } - + void generateProjectFiles(GeneratorSettings settings, in TargetInfo[string] targets) { bool[string] visited; @@ -146,16 +146,16 @@ return true; return false; } - + void generateProjectFile(string packname, GeneratorSettings settings, in TargetInfo[string] targets) { int i = 0; auto ret = appender!(char[])(); - + auto project_file_dir = m_project.rootPackage.path ~ projFileName(packname).parentPath; ret.put("\n"); ret.formattedWrite(" %s\n", guid(packname)); - + // Several configurations (debug, release, unittest) generateProjectConfiguration(ret, packname, settings.buildType, settings, targets); //generateProjectConfiguration(ret, packname, "release", settings, targets); @@ -229,12 +229,12 @@ proj.put(ret.data()); proj.flush(); } - + void generateProjectConfiguration(Appender!(char[]) ret, string pack, string type, GeneratorSettings settings, in TargetInfo[string] targets) { auto project_file_dir = m_project.rootPackage.path ~ projFileName(pack).parentPath; auto buildsettings = targets[pack].buildSettings.dup; - + string[] getSettings(string setting)(){ return __traits(getMember, buildsettings, setting); } string[] getPathSettings(string setting)() { @@ -248,7 +248,7 @@ } return ret; } - + foreach(architecture; settings.platform.architecture) { string arch; switch(architecture) { @@ -259,7 +259,7 @@ ret.formattedWrite(" \n", to!string(type), arch); // FIXME: handle compiler options in an abstract way instead of searching for DMD specific flags - + // debug and optimize setting ret.formattedWrite(" %s\n", buildsettings.options & BuildOptions.debugInfo ? "1" : "0"); ret.formattedWrite(" %s\n", buildsettings.options & BuildOptions.optimize ? "1" : "0"); @@ -267,7 +267,7 @@ ret.formattedWrite(" %s\n", buildsettings.options & BuildOptions.releaseMode ? "1" : "0"); // Lib or exe? - enum + enum { Executable = 0, StaticLib = 1, @@ -325,7 +325,7 @@ if (nd > ndummy) ndummy = nd; } string intersubdir = replicate("dummy/", ndummy) ~ getPackageFileName(pack); - + ret.put(" 0\n"); ret.put(" 0\n"); ret.put(" 0\n"); @@ -413,7 +413,7 @@ ret.put(" \n"); } // foreach(architecture) } - + void performOnDependencies(const Package main, string[string] configs, void delegate(const Package pack) op) { foreach (p; m_project.getTopologicalPackageList(false, main, configs)) { @@ -421,12 +421,12 @@ op(p); } } - + string generateUUID() const { import std.string; return "{" ~ toUpper(randomUUID().toString()) ~ "}"; } - + string guid(string projectName) { if(projectName !in m_projectUuids) m_projectUuids[projectName] = generateUUID(); @@ -466,7 +466,7 @@ return as[idx].opCmp(bs[idx]); if(as.length != bs.length) { - // If length differ, the longer one is "smaller", that is more + // If length differ, the longer one is "smaller", that is more // specialized and will be put out first. return as.length > bs.length? -1 : 1; } diff --git a/source/dub/init.d b/source/dub/init.d index 673386e..5a4edd6 100644 --- a/source/dub/init.d +++ b/source/dub/init.d @@ -25,7 +25,7 @@ if( !root_path.empty ){ if( !existsFile(root_path) ) createDirectory(root_path); - } + } //Make sure we do not overwrite anything accidentally auto files = packageInfoFilenames ~ ["source/", "views/", "public/"]; @@ -43,7 +43,7 @@ { writePackageJson(root_path, "A minimal D application.", null); createDirectory(root_path ~ "source"); - write((root_path ~ "source/app.d").toNativeString(), + write((root_path ~ "source/app.d").toNativeString(), q{import std.stdio; void main() @@ -59,7 +59,7 @@ createDirectory(root_path ~ "source"); createDirectory(root_path ~ "views"); createDirectory(root_path ~ "public"); - write((root_path ~ "source/app.d").toNativeString(), + write((root_path ~ "source/app.d").toNativeString(), q{import vibe.d; shared static this() diff --git a/source/dub/internal/vibecompat/core/file.d b/source/dub/internal/vibecompat/core/file.d index 8c51f74..5a806a3 100644 --- a/source/dub/internal/vibecompat/core/file.d +++ b/source/dub/internal/vibecompat/core/file.d @@ -31,7 +31,7 @@ void put(in char[] str) { put(cast(ubyte[])str); } void put(char ch) { put((&ch)[0 .. 1]); } void put(dchar ch) { char[4] chars; put(chars[0 .. encode(chars, ch)]); } - + ubyte[] readAll() { file.seek(0, std.stream.SeekPos.End); diff --git a/source/dub/internal/vibecompat/inet/path.d b/source/dub/internal/vibecompat/inet/path.d index 1fe30b1..fbe1557 100644 --- a/source/dub/internal/vibecompat/inet/path.d +++ b/source/dub/internal/vibecompat/inet/path.d @@ -30,7 +30,7 @@ bool m_absolute = false; bool m_endsWithSlash = false; } - + /// Constructs a Path object by parsing a path string. this(string pathstr) { @@ -38,20 +38,20 @@ m_absolute = (pathstr.startsWith("/") || m_nodes.length > 0 && (m_nodes[0].toString().countUntil(':')>0 || m_nodes[0] == "\\")); m_endsWithSlash = pathstr.endsWith("/"); } - + /// Constructs a path object from a list of PathEntry objects. this(immutable(PathEntry)[] nodes, bool absolute) { m_nodes = nodes; m_absolute = absolute; } - + /// Constructs a relative path with one path entry. this(PathEntry entry){ m_nodes = [entry]; m_absolute = false; } - + /// Determines if the path is absolute. @property bool absolute() const { return m_absolute; } @@ -74,14 +74,14 @@ } m_nodes = newnodes; } - + /// Converts the Path back to a string representation using slashes. string toString() const { if( m_nodes.empty ) return absolute ? "/" : ""; - + Appender!string ret; - + // for absolute paths start with / version(Windows) { @@ -91,12 +91,12 @@ } else { - if( absolute ) + if( absolute ) { ret.put('/'); } } - + foreach( i, f; m_nodes ){ if( i > 0 ) ret.put('/'); ret.put(f.toString()); @@ -104,10 +104,10 @@ if( m_nodes.length > 0 && m_endsWithSlash ) ret.put('/'); - + return ret.data; } - + /// Converts the Path object to a native path string (backslash as path separator on Windows). string toNativeString() const { @@ -119,26 +119,26 @@ } Appender!string ret; - + // for absolute unix paths start with / version(Posix) { if(absolute) ret.put('/'); } - + foreach( i, f; m_nodes ){ version(Windows) { if( i > 0 ) ret.put('\\'); } version(Posix) { if( i > 0 ) ret.put('/'); } else { enforce("Unsupported OS"); } ret.put(f.toString()); } - + if( m_nodes.length > 0 && m_endsWithSlash ){ version(Windows) { ret.put('\\'); } version(Posix) { ret.put('/'); } } - + return ret.data; } - - /// Tests if `rhs` is an anchestor or the same as this path. + + /// Tests if `rhs` is an anchestor or the same as this path. bool startsWith(const Path rhs) const { if( rhs.m_nodes.length > m_nodes.length ) return false; foreach( i; 0 .. rhs.m_nodes.length ) @@ -146,7 +146,7 @@ return false; return true; } - + /// Computes the relative path from `parentPath` to this path. Path relativeTo(const Path parentPath) const { assert(this.absolute && parentPath.absolute); @@ -170,7 +170,7 @@ ret.m_endsWithSlash = this.m_endsWithSlash; return ret; } - + /// The last entry of the path @property ref immutable(PathEntry) head() const { enforce(m_nodes.length > 0); return m_nodes[$-1]; } @@ -193,7 +193,7 @@ /// Determines if this path goes outside of its base path (i.e. begins with '..'). @property bool external() const { return !m_absolute && m_nodes.length > 0 && m_nodes[0].m_name == ".."; } - + ref immutable(PathEntry) opIndex(size_t idx) const { return m_nodes[idx]; } Path opSlice(size_t start, size_t end) const { auto ret = Path(m_nodes[start .. end], start == 0 ? absolute : false); @@ -201,15 +201,15 @@ return ret; } size_t opDollar(int dim)() const if(dim == 0) { return m_nodes.length; } - - + + Path opBinary(string OP)(const Path rhs) const if( OP == "~" ) { Path ret; ret.m_nodes = m_nodes; ret.m_absolute = m_absolute; ret.m_endsWithSlash = rhs.m_endsWithSlash; ret.normalize(); // needed to avoid "."~".." become "" instead of ".." - + assert(!rhs.absolute, "Trying to append absolute path."); size_t idx = m_nodes.length; foreach(folder; rhs.m_nodes){ @@ -226,13 +226,13 @@ } return ret; } - + Path opBinary(string OP)(string rhs) const if( OP == "~" ) { assert(rhs.length > 0, "Cannot append empty path string."); return opBinary!"~"(Path(rhs)); } Path opBinary(string OP)(PathEntry rhs) const if( OP == "~" ) { assert(rhs.toString().length > 0, "Cannot append empty path string."); return opBinary!"~"(Path(rhs)); } void opOpAssign(string OP)(string rhs) if( OP == "~" ) { assert(rhs.length > 0, "Cannot append empty path string."); opOpAssign!"~"(Path(rhs)); } void opOpAssign(string OP)(PathEntry rhs) if( OP == "~" ) { assert(rhs.toString().length > 0, "Cannot append empty path string."); opOpAssign!"~"(Path(rhs)); } void opOpAssign(string OP)(Path rhs) if( OP == "~" ) { auto p = this ~ rhs; m_nodes = p.m_nodes; m_endsWithSlash = rhs.m_endsWithSlash; } - + /// Tests two paths for equality using '=='. bool opEquals(ref const Path rhs) const { if( m_absolute != rhs.m_absolute ) return false; @@ -272,17 +272,17 @@ private { string m_name; } - + this(string str) { assert(str.countUntil('/') < 0 && (str.countUntil('\\') < 0 || str.length == 1)); m_name = str; } - + string toString() const { return m_name; } Path opBinary(string OP)(PathEntry rhs) const if( OP == "~" ) { return Path(cast(immutable)[this, rhs], false); } - + bool opEquals(ref const PathEntry rhs) const { return m_name == rhs.m_name; } bool opEquals(PathEntry rhs) const { return m_name == rhs.m_name; } bool opEquals(string rhs) const { return m_name == rhs; } @@ -426,7 +426,7 @@ dotpathp.normalize(); assert(dotpathp.toString() == "/test2/x/y"); } - + { auto parentpath = "/path/to/parent"; auto parentpathp = Path(parentpath); diff --git a/source/dub/internal/vibecompat/inet/url.d b/source/dub/internal/vibecompat/inet/url.d index 45b16f2..d9f021f 100644 --- a/source/dub/internal/vibecompat/inet/url.d +++ b/source/dub/internal/vibecompat/inet/url.d @@ -52,7 +52,7 @@ } /** Constructs a URL from its string representation. - + TODO: additional validation required (e.g. valid host and user names and port) */ this(string url_string) @@ -163,14 +163,14 @@ /// The path part plus query string and anchor @property string localURI() - const { + const { auto str = appender!string(); str.reserve(m_pathString.length + 2 + queryString.length + anchor.length); str.put(encode(path.toString())); if( queryString.length ) { str.put("?"); str.put(queryString); - } + } if( anchor.length ) { str.put("#"); str.put(anchor); @@ -267,7 +267,7 @@ assert(url.schema == "https", url.schema); assert(url.host == "www.example.net", url.host); assert(url.path == Path("/index.html"), url.path.toString()); - + url = URL.parse("http://jo.doe:password@sub.www.example.net:4711/sub2/index.html?query#anchor"); assert(url.schema == "http", url.schema); assert(url.username == "jo.doe", url.username); diff --git a/source/dub/package_.d b/source/dub/package_.d index 2c7e95c..8435149 100644 --- a/source/dub/package_.d +++ b/source/dub/package_.d @@ -34,7 +34,7 @@ /** Represents a package, including its sub packages - Documentation of the dub.json can be found at + Documentation of the dub.json can be found at http://registry.vibed.org/package-format */ class Package { @@ -175,7 +175,7 @@ simpleLint(); } - + @property string name() const { if (m_parentPackage) return m_parentPackage.name ~ ":" ~ m_info.name; @@ -354,7 +354,7 @@ s ~= "\n " ~ p ~ ", version '" ~ v.toString() ~ "'"; return s; } - + bool hasDependency(string depname, string config) const { if (depname in m_info.buildSettings.dependencies) return true; @@ -436,7 +436,7 @@ } } -/// Specifying package information without any connection to a certain +/// Specifying package information without any connection to a certain /// retrived package, like Package class is doing. struct PackageInfo { string name; diff --git a/source/dub/packagemanager.d b/source/dub/packagemanager.d index 69ab076..365a3f8 100644 --- a/source/dub/packagemanager.d +++ b/source/dub/packagemanager.d @@ -289,7 +289,7 @@ auto package_version = package_info["version"].get!string(); auto clean_package_version = package_version[package_version.startsWith("~") ? 1 : 0 .. $]; - logDiagnostic("Placing package '%s' version '%s' to location '%s' from file '%s'", + logDiagnostic("Placing package '%s' version '%s' to location '%s' from file '%s'", package_name, package_version, destination.toNativeString(), zip_file_path.toNativeString()); if( existsFile(destination) ){ @@ -413,7 +413,7 @@ if (fi.isDirectory) { // Indicate a directory. fpath.endsWithSlash(true); - // Ignore /.dub folder: This folder and its content + // Ignore /.dub folder: This folder and its content // are not tracked by the Journal. if (fpath.relativeTo(pack.path) == Path(".dub/")) continue; @@ -422,7 +422,7 @@ auto type = fi.isDirectory ? Journal.Type.Directory : Journal.Type.RegularFile; if (!journal.containsEntry(type, fpath.relativeTo(pack.path))) - throw new Exception("Untracked file found, aborting package removal, file: " + throw new Exception("Untracked file found, aborting package removal, file: " ~ fpath.toNativeString() ~ "\nPlease remove the package folder manually or use --force-remove."); } } @@ -510,7 +510,7 @@ enforce(p.ver == ver, format("Package in %s is refrenced with two conflicting versions: %s vs %s", path.toNativeString(), p.ver, ver)); return p; } - + try { auto pack = new Package(path); enforce(pack.name.length, "The package has no name, defined in: " ~ path.toString()); @@ -528,7 +528,7 @@ foreach (p; m_temporaryPackages) if (p.path == path) return p; - + auto pack = new Package(path); enforce(pack.name.length, "The package has no name, defined in: " ~ path.toString()); addPackages(m_temporaryPackages, pack); @@ -672,7 +672,7 @@ /// Generates a hash value for a given package. /// Some files or folders are ignored during the generation (like .dub and /// .svn folders) - Hash hashPackage(Package pack) + Hash hashPackage(Package pack) { string[] ignored_directories = [".git", ".dub", ".svn"]; // something from .dub_ignore or what? @@ -827,23 +827,23 @@ */ private class Journal { private enum Version = 1; - + enum Type { RegularFile, Directory, Alien } - + struct Entry { this( Type t, Path f ) { type = t; relFilename = f; } Type type; Path relFilename; } - + @property const(Entry[]) entries() const { return m_entries; } - + this() {} - + /// Initializes a Journal from a json file. this(Path journalFile) { auto jsonJournal = jsonFromFile(journalFile); @@ -871,7 +871,7 @@ } enforce(false, "Cannot remove entry, not available: " ~ e.relFilename.toNativeString()); } - + /// Save the current state to the path. void save(Path path) { Json jsonJournal = serialize(); @@ -887,7 +887,7 @@ return true; return false; } - + private Json serialize() const { Json[string] files; foreach(Entry e; m_entries) @@ -897,7 +897,7 @@ json["Files"] = files; return Json(json); } - + private { Entry[] m_entries; } diff --git a/source/dub/packagesupplier.d b/source/dub/packagesupplier.d index 27be871..fe65b32 100644 --- a/source/dub/packagesupplier.d +++ b/source/dub/packagesupplier.d @@ -35,7 +35,7 @@ /// path: absolute path to store the package (usually in a zip format) void retrievePackage(Path path, string packageId, Dependency dep, bool pre_release); - + /// returns the metadata for the package Json getPackageDescription(string packageId, Dependency dep, bool pre_release); } @@ -48,7 +48,7 @@ this(Path root) { m_path = root; } override @property string description() { return "file repository at "~m_path.toNativeString(); } - + Version[] getVersions(string package_id) { Version[] ret; @@ -72,13 +72,13 @@ enforce(existsFile(filename)); copyFile(filename, path); } - + Json getPackageDescription(string packageId, Dependency dep, bool pre_release) { auto filename = bestPackageFile(packageId, dep, pre_release); return jsonFromZip(filename, "dub.json"); } - + private Path bestPackageFile(string packageId, Dependency dep, bool pre_release) { Path toPath(Version ver) { @@ -103,7 +103,7 @@ CacheEntry[string] m_metadataCache; Duration m_maxCacheTime; } - + this(URL registry) { m_registryUrl = registry; @@ -123,7 +123,7 @@ ret.sort(); return ret; } - + void retrievePackage(Path path, string packageId, Dependency dep, bool pre_release) { import std.array : replace; @@ -133,12 +133,12 @@ logDiagnostic("Found download URL: '%s'", url); download(url, path); } - + Json getPackageDescription(string packageId, Dependency dep, bool pre_release) { return getBestPackage(packageId, dep, pre_release); } - + private Json getMetadata(string packageId) { auto now = Clock.currTime(UTC()); @@ -148,7 +148,7 @@ } auto url = m_registryUrl ~ Path(PackagesPath ~ "/" ~ packageId ~ ".json"); - + logDebug("Downloading metadata for %s", packageId); logDebug("Getting from %s", url); @@ -157,7 +157,7 @@ m_metadataCache[packageId] = CacheEntry(json, now); return json; } - + private Json getBestPackage(string packageId, Dependency dep, bool pre_release) { Json md = getMetadata(packageId); diff --git a/source/dub/version_.d b/source/dub/version_.d index 8e22adb..cac04d3 100644 --- a/source/dub/version_.d +++ b/source/dub/version_.d @@ -1 +1 @@ -module dub.version_; enum dubVersion = "v0.9.21"; +module dub.version_; enum dubVersion = "v0.9.21";