diff --git a/.circleci/run.sh b/.circleci/run.sh index 06eb9add81d..12315349fae 100755 --- a/.circleci/run.sh +++ b/.circleci/run.sh @@ -134,6 +134,15 @@ publictests() make -f posix.mak -j$N publictests DUB=$DUB BUILD=$BUILD } +# test stdx dub package +dub_package() +{ + pushd test + dub -v --single dub_stdx_checkedint.d + dub -v --single dub_stdx_allocator.d + popd +} + case $1 in install-deps) install_deps ;; setup-repos) setup_repos ;; diff --git a/.gitignore b/.gitignore index 1c5757d80f8..efcbaa7d841 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,7 @@ obj/ .vscode *.html + +.dub/ +libphobos_* +source/ diff --git a/dub.sdl b/dub.sdl index e0910420e11..fb58c66a3a2 100644 --- a/dub.sdl +++ b/dub.sdl @@ -1,6 +1,50 @@ name "phobos" license "BSL-1.0" +description "D Standard Library" +authors "DLang Community" copyright "Copyright © 1999-2018, The D Language Foundation" + targetType "library" sourcePaths "std" "etc" targetPath "generated" + +subPackage { + name "checkedint" + targetType "library" + preGenerateCommands `rdmd --eval=' + auto pkgDir = environment.get("DUB_PACKAGE_DIR"); + auto destDir = pkgDir.buildPath("source", "stdx"); + mkdirRecurse(destDir); + pkgDir.buildPath("std", "experimental", "checkedint.d") + .readText + .replace("std.experimental.checkedint", "stdx.checkedint") + .toFile(destDir.buildPath("checkedint.d"));'` + sourceFiles "source/stdx/checkedint.d" + importPaths "source" +} + +// This meta package is needed because dub searches for the source files _before_ it evaluates preGenerateCommands +// However, it does run its dependencies _before_ searching through its source paths +subPackage { + name "allocator-generator" + targetType "none" + preGenerateCommands `rdmd --eval=' + auto pkgDir = environment.get("DUB_PACKAGE_DIR"); + auto destDir = pkgDir.buildPath("source", "stdx", "allocator"); + auto srcDir = pkgDir.buildPath("std", "experimental", "allocator"); + foreach (file; srcDir.dirEntries("*.d", SpanMode.depth)) { + auto destFile = file.replace(srcDir, destDir); + destFile.dirName.mkdirRecurse; + file.readText.replace("std.experimental.allocator", "stdx.allocator") + .toFile(destFile); + } + '` +} + +subPackage { + name "allocator" + targetType "library" + dependency "phobos:allocator-generator" version="*" + sourcePaths "source/stdx/allocator" + importPaths "source" +} diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 00000000000..5e4860db706 --- /dev/null +++ b/test/.gitignore @@ -0,0 +1,2 @@ +dub_stdx_allocator +dub_stdx_checkedint diff --git a/test/dub_stdx_allocator.d b/test/dub_stdx_allocator.d new file mode 100755 index 00000000000..5ae47b9b9d0 --- /dev/null +++ b/test/dub_stdx_allocator.d @@ -0,0 +1,13 @@ +#!/usr/bin/env dub +/++dub.sdl: +dependency "phobos:allocator" path=".." ++/ + +void main(string[] args) +{ + import stdx.allocator.mallocator : Mallocator; // From latest Phobos + import std.stdio; // current phobos + auto buf = Mallocator.instance.allocate(10); + writeln("allocate: ", buf); + scope(exit) Mallocator.instance.deallocate(buf); +} diff --git a/test/dub_stdx_checkedint.d b/test/dub_stdx_checkedint.d new file mode 100755 index 00000000000..d0a920d24ae --- /dev/null +++ b/test/dub_stdx_checkedint.d @@ -0,0 +1,11 @@ +#!/usr/bin/env dub +/++dub.sdl: +dependency "phobos:checkedint" path=".." ++/ + +void main(string[] args) +{ + import stdx.checkedint; // From latest Phobos + import std.stdio; // DMD's Phobos + writeln("checkedint: ", 2.checked + 3); +}