diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c5c6af..14e3ee5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ### Features and improvements ### + - Dependencies can now be specified per-configuration in addition to globally + - Version numbers are now handled according to [SemVer](http://semver.org/) - Library packages are now only built when running "dub" instead of trying to execute them - partially [pull #66][issue66] by Vadim Lopatin and [issue #53][issue53] - Add support for optional dependencies (picked up only if already installed) - [issue #5][issue5] - Compiles on DMD 2.063 @@ -29,6 +31,7 @@ - Fixed the linker workaround in the build script to work on non-Ubuntu systems - [issue #71][issue71] - Fixed handling of Windows UNC paths (by Lutger Blijdestijn) - [pull #75][issue75] - Fixed a possible infinite update loop - [issue #72][issue72] + - Fixed handling of multiple compiler/linker arguments with the same content (e.g. "--framework A --framework B" on OS X) [issue5]: https://github.com/rejectedsoftware/dub/issues/5 [issue53]: https://github.com/rejectedsoftware/dub/issues/53 diff --git a/examples/app/package.json b/examples/app/package.json new file mode 100644 index 0000000..7265230 --- /dev/null +++ b/examples/app/package.json @@ -0,0 +1,4 @@ +{ + "name": "app-example", + "description": "A simple D application" +} diff --git a/examples/app/source/app.d b/examples/app/source/app.d new file mode 100644 index 0000000..ba308f1 --- /dev/null +++ b/examples/app/source/app.d @@ -0,0 +1,6 @@ +import std.stdio; + +void main() +{ + writeln("Hello, World."); +} diff --git a/examples/header-lib/import/mylib.d b/examples/header-lib/import/mylib.d new file mode 100644 index 0000000..4536a0b --- /dev/null +++ b/examples/header-lib/import/mylib.d @@ -0,0 +1,3 @@ +module mylib; + +extern(C) void test(); diff --git a/examples/header-lib/package.json b/examples/header-lib/package.json new file mode 100644 index 0000000..b3e7dc2 --- /dev/null +++ b/examples/header-lib/package.json @@ -0,0 +1,6 @@ +{ + "name": "header-lib-example", + "description": "A simple D header library (C binding to libmylib.so)", + "targetType": "sourceLibrary", + "libs": "mylib" +} diff --git a/examples/lib-user/package.json b/examples/lib-user/package.json new file mode 100644 index 0000000..0f358eb --- /dev/null +++ b/examples/lib-user/package.json @@ -0,0 +1,7 @@ +{ + "name": "lib-user-example", + "description": "An application using a local library dependency", + "dependencies": { + "lib-example": {"version": "~master", "path": "../lib"} + } +} diff --git a/examples/lib-user/source/app.d b/examples/lib-user/source/app.d new file mode 100644 index 0000000..e2714a0 --- /dev/null +++ b/examples/lib-user/source/app.d @@ -0,0 +1,6 @@ +import lib; + +void main() +{ + test(); +} diff --git a/examples/lib/package.json b/examples/lib/package.json new file mode 100644 index 0000000..7fb63c3 --- /dev/null +++ b/examples/lib/package.json @@ -0,0 +1,5 @@ +{ + "name": "lib-example", + "description": "A simple D library", + "targetType": "library" +} diff --git a/examples/lib/source/lib.d b/examples/lib/source/lib.d new file mode 100644 index 0000000..345d027 --- /dev/null +++ b/examples/lib/source/lib.d @@ -0,0 +1,8 @@ +module lib; + +import std.stdio; + +void test() +{ + writeln("Hello, World."); +} diff --git a/examples/mixed/package.json b/examples/mixed/package.json new file mode 100644 index 0000000..234ffd1 --- /dev/null +++ b/examples/mixed/package.json @@ -0,0 +1,4 @@ +{ + "name": "mixed-example", + "description": "A package usable as both, an application and a library" +} diff --git a/examples/mixed/source/app.d b/examples/mixed/source/app.d new file mode 100644 index 0000000..c558c9e --- /dev/null +++ b/examples/mixed/source/app.d @@ -0,0 +1,8 @@ +module app; + +import lib; + +void main() +{ + test(); +} diff --git a/examples/mixed/source/lib.d b/examples/mixed/source/lib.d new file mode 100644 index 0000000..bb7e819 --- /dev/null +++ b/examples/mixed/source/lib.d @@ -0,0 +1,8 @@ +module lib; + +import std.stdio; + +void test() +{ + writeln("Hello, World!"); +} \ No newline at end of file diff --git a/examples/vibed-main/package.json b/examples/vibed-main/package.json new file mode 100644 index 0000000..5c1042b --- /dev/null +++ b/examples/vibed-main/package.json @@ -0,0 +1,8 @@ +{ + "name": "vibed-main-example", + "description": "A project using vibe.d and a custom main() function", + "dependencies": { + "vibe-d": "~master" + }, + "versions": ["VibeCustomMain"] +} diff --git a/examples/vibed-main/source/app.d b/examples/vibed-main/source/app.d new file mode 100644 index 0000000..30fd3e8 --- /dev/null +++ b/examples/vibed-main/source/app.d @@ -0,0 +1,13 @@ +import vibe.vibe; + +void main() +{ + listenHTTP(new HTTPServerSettings, &handleRequest); + lowerPrivileges(); + runEventLoop(); +} + +void handleRequest(HTTPServerRequest req, HTTPServerResponse res) +{ + res.writeBody("Hello, World!"); +} \ No newline at end of file diff --git a/examples/vibed/package.json b/examples/vibed/package.json new file mode 100644 index 0000000..befdb65 --- /dev/null +++ b/examples/vibed/package.json @@ -0,0 +1,7 @@ +{ + "name": "vibed-example", + "description": "A project using vibe.d", + "dependencies": { + "vibe-d": "~master" + } +} diff --git a/examples/vibed/source/app.d b/examples/vibed/source/app.d new file mode 100644 index 0000000..1a7d8de --- /dev/null +++ b/examples/vibed/source/app.d @@ -0,0 +1,11 @@ +import vibe.d; + +shared static this() +{ + listenHTTP(new HTTPServerSettings, &handleRequest); +} + +void handleRequest(HTTPServerRequest req, HTTPServerResponse res) +{ + res.writeBody("Hello, World!"); +} \ No newline at end of file diff --git a/source/dub/compilers/dmd.d b/source/dub/compilers/dmd.d index 9e20622..4d3916d 100644 --- a/source/dub/compilers/dmd.d +++ b/source/dub/compilers/dmd.d @@ -111,7 +111,7 @@ { import std.string; auto tpath = Path(settings.targetPath) ~ getTargetFileName(settings, platform); - auto args = ["dmd", "-of"~tpath.toNativeString()] ~ objects ~ settings.lflags.map!(l => "-L"~l)().array() ~ settings.sourceFiles; + auto args = [platform.compiler, "-of"~tpath.toNativeString()] ~ objects ~ settings.lflags.map!(l => "-L"~l)().array() ~ settings.sourceFiles; args ~= settings.dflags.filter!(f => f == "-g" || f == "-gc")().array(); logDebug("%s", args.join(" ")); auto res = spawnProcess(args).wait(); diff --git a/source/dub/packagemanager.d b/source/dub/packagemanager.d index e329ada..44d8f3b 100644 --- a/source/dub/packagemanager.d +++ b/source/dub/packagemanager.d @@ -61,10 +61,10 @@ { m_repositories[LocalPackageType.user] = Repository(user_path); m_repositories[LocalPackageType.system] = Repository(system_path); - refresh(); + refresh(true); } - @property void searchPath(Path[] paths) { m_searchPath = paths.dup; refresh(); } + @property void searchPath(Path[] paths) { m_searchPath = paths.dup; refresh(false); } @property const(Path)[] searchPath() const { return m_searchPath; } @property const(Path)[] completeSearchPath() @@ -399,7 +399,7 @@ writeLocalPackageList(type); } - void refresh() + void refresh(bool refresh_existing_packages) { // load locally defined packages void scanLocalPackages(LocalPackageType type) @@ -427,7 +427,15 @@ logWarn("Local package at %s has different name than %s (%s)", path.toNativeString(), name, info.name.get!string()); info.name = name; info["version"] = ver; - auto pp = new Package(info, path); + + Package pp; + if (!refresh_existing_packages) + foreach (p; m_repositories[type].localPackages) + if (p.path == path) { + pp = p; + break; + } + if (!pp) pp = new Package(info, path); packs ~= pp; } } catch( Exception e ){ @@ -443,6 +451,8 @@ scanLocalPackages(LocalPackageType.system); scanLocalPackages(LocalPackageType.user); + Package[][string] old_packages = m_packages; + // rescan the system and user package folder void scanPackageFolder(Path path) { @@ -455,7 +465,14 @@ if( !existsFile(pack_path ~ PackageJsonFilename) ) continue; Package p; try { - p = new Package(pack_path); + if (!refresh_existing_packages) + foreach (plist; old_packages) + foreach (pp; plist) + if (pp.path == pack_path) { + p = pp; + break; + } + if (!p) p = new Package(pack_path); m_packages[p.name] ~= p; } catch( Exception e ){ logError("Failed to load package in %s: %s", pack_path, e.msg); diff --git a/source/dub/project.d b/source/dub/project.d index 8696317..99a7385 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -155,7 +155,7 @@ m_dependencies = null; m_main = null; - m_packageManager.refresh(); + m_packageManager.refresh(false); try m_json = jsonFromFile(m_root ~ ".dub/dub.json", true); catch(Exception t) logDebug("Failed to read .dub/dub.json: %s", t.msg); @@ -457,7 +457,7 @@ if( !p && reqDep.dependency.optional ) continue; // Try an already installed package first - if( p && needsUpToDateCheck(pkg) ){ + if( p && needsUpToDateCheck(p) ){ logInfo("Triggering update of package %s", pkg); p = null; } @@ -497,12 +497,14 @@ return true; } - private bool needsUpToDateCheck(string packageId) { - try { - auto time = m_json["dub"]["lastUpdate"].opt!(Json[string]).get(packageId, Json("")).get!string; - if( !time.length ) return true; - return (Clock.currTime() - SysTime.fromISOExtString(time)) > dur!"days"(1); - } catch(Exception t) return true; + private bool needsUpToDateCheck(Package pack) { + version (none) { // needs to be updated for the new package system (where no project local packages exist) + try { + auto time = m_json["dub"]["lastUpdate"].opt!(Json[string]).get(pack.name, Json("")).get!string; + if( !time.length ) return true; + return (Clock.currTime() - SysTime.fromISOExtString(time)) > dur!"days"(1); + } catch(Exception t) return true; + } else return false; } private void markUpToDate(string packageId) {