forked from dlang/phobos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial dub.sdl with stdx-allocator and stdx-checkedint
- Loading branch information
Showing
6 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,7 @@ obj/ | |
.vscode | ||
|
||
*.html | ||
|
||
.dub/ | ||
libphobos_* | ||
source/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dub_stdx_allocator | ||
dub_stdx_checkedint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |