mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
Expose D frontend via DUB
This commit is contained in:
parent
cbd0d27882
commit
b203430b1b
4 changed files with 155 additions and 38 deletions
103
dub.sdl
103
dub.sdl
|
@ -5,7 +5,7 @@ copyright "Copyright © 1999-2017, The D Language Foundation"
|
||||||
license "BSL-1.0"
|
license "BSL-1.0"
|
||||||
|
|
||||||
targetType "none"
|
targetType "none"
|
||||||
dependency ":parser" version="*"
|
dependency ":frontend" version="*"
|
||||||
|
|
||||||
subPackage {
|
subPackage {
|
||||||
name "root"
|
name "root"
|
||||||
|
@ -49,3 +49,104 @@ subPackage {
|
||||||
|
|
||||||
dependency "dmd:lexer" version="*"
|
dependency "dmd:lexer" version="*"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
subPackage {
|
||||||
|
name "frontend"
|
||||||
|
targetType "library"
|
||||||
|
stringImportPaths "res"
|
||||||
|
versions "NoBackend"
|
||||||
|
versions "GC"
|
||||||
|
versions "NoMain"
|
||||||
|
sourcePaths
|
||||||
|
|
||||||
|
sourceFiles \
|
||||||
|
"src/dmd/access.d" \
|
||||||
|
"src/dmd/aggregate.d" \
|
||||||
|
"src/dmd/aliasthis.d" \
|
||||||
|
"src/dmd/apply.d" \
|
||||||
|
"src/dmd/argtypes.d" \
|
||||||
|
"src/dmd/arrayop.d" \
|
||||||
|
"src/dmd/arraytypes.d" \
|
||||||
|
"src/dmd/astcodegen.d" \
|
||||||
|
"src/dmd/attrib.d" \
|
||||||
|
"src/dmd/blockexit.d" \
|
||||||
|
"src/dmd/builtin.d" \
|
||||||
|
"src/dmd/canthrow.d" \
|
||||||
|
"src/dmd/clone.d" \
|
||||||
|
"src/dmd/complex.d" \
|
||||||
|
"src/dmd/cond.d" \
|
||||||
|
"src/dmd/constfold.d" \
|
||||||
|
"src/dmd/cppmangle.d" \
|
||||||
|
"src/dmd/cppmanglewin.d" \
|
||||||
|
"src/dmd/ctfeexpr.d" \
|
||||||
|
"src/dmd/dcast.d" \
|
||||||
|
"src/dmd/dclass.d" \
|
||||||
|
"src/dmd/declaration.d" \
|
||||||
|
"src/dmd/delegatize.d" \
|
||||||
|
"src/dmd/denum.d" \
|
||||||
|
"src/dmd/dimport.d" \
|
||||||
|
"src/dmd/dinifile.d" \
|
||||||
|
"src/dmd/dinterpret.d" \
|
||||||
|
"src/dmd/dmacro.d" \
|
||||||
|
"src/dmd/dmangle.d" \
|
||||||
|
"src/dmd/dmodule.d" \
|
||||||
|
"src/dmd/doc.d" \
|
||||||
|
"src/dmd/dscope.d" \
|
||||||
|
"src/dmd/dstruct.d" \
|
||||||
|
"src/dmd/dsymbol.d" \
|
||||||
|
"src/dmd/dsymbolsem.d" \
|
||||||
|
"src/dmd/dtemplate.d" \
|
||||||
|
"src/dmd/dversion.d" \
|
||||||
|
"src/dmd/escape.d" \
|
||||||
|
"src/dmd/expression.d" \
|
||||||
|
"src/dmd/expressionsem.d" \
|
||||||
|
"src/dmd/func.d" \
|
||||||
|
"src/dmd/gluelayer.d" \
|
||||||
|
"src/dmd/hdrgen.d" \
|
||||||
|
"src/dmd/id.d" \
|
||||||
|
"src/dmd/impcnvtab.d" \
|
||||||
|
"src/dmd/imphint.d" \
|
||||||
|
"src/dmd/init.d" \
|
||||||
|
"src/dmd/initsem.d" \
|
||||||
|
"src/dmd/inline.d" \
|
||||||
|
"src/dmd/inlinecost.d" \
|
||||||
|
"src/dmd/intrange.d" \
|
||||||
|
"src/dmd/json.d" \
|
||||||
|
"src/dmd/lib.d" \
|
||||||
|
"src/dmd/link.d" \
|
||||||
|
"src/dmd/mars.d" \
|
||||||
|
"src/dmd/mtype.d" \
|
||||||
|
"src/dmd/nogc.d" \
|
||||||
|
"src/dmd/nspace.d" \
|
||||||
|
"src/dmd/objc.d" \
|
||||||
|
"src/dmd/opover.d" \
|
||||||
|
"src/dmd/optimize.d" \
|
||||||
|
"src/dmd/parse.d" \
|
||||||
|
"src/dmd/parsetimevisitor.d" \
|
||||||
|
"src/dmd/printast.d" \
|
||||||
|
"src/dmd/safe.d" \
|
||||||
|
"src/dmd/sapply.d" \
|
||||||
|
"src/dmd/semantic.d" \
|
||||||
|
"src/dmd/sideeffect.d" \
|
||||||
|
"src/dmd/statement.d" \
|
||||||
|
"src/dmd/statement_rewrite_walker.d" \
|
||||||
|
"src/dmd/statementsem.d" \
|
||||||
|
"src/dmd/staticassert.d" \
|
||||||
|
"src/dmd/staticcond.d" \
|
||||||
|
"src/dmd/target.d" \
|
||||||
|
"src/dmd/templateparamsem.d" \
|
||||||
|
"src/dmd/traits.d" \
|
||||||
|
"src/dmd/typesem.d" \
|
||||||
|
"src/dmd/typinf.d" \
|
||||||
|
"src/dmd/utils.d" \
|
||||||
|
"src/dmd/visitor.d"
|
||||||
|
|
||||||
|
sourceFiles "src/dmd/scanelf.d" \
|
||||||
|
"src/dmd/libelf.d" platform="linux"
|
||||||
|
|
||||||
|
sourceFiles "src/dmd/scanmach.d" \
|
||||||
|
"src/dmd/libmach.d" platform="osx"
|
||||||
|
|
||||||
|
dependency "dmd:parser" version="*"
|
||||||
|
dependency "dmd:lexer" version="*"
|
||||||
|
}
|
||||||
|
|
21
test/dub_package/README.md
Normal file
21
test/dub_package/README.md
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
DMD as a library
|
||||||
|
================
|
||||||
|
|
||||||
|
The tests in this module are high-level and mostly indented to make sure all
|
||||||
|
necessary modules are included in the Dub package.
|
||||||
|
|
||||||
|
The tests are executable single-file packages for the D's package manager `dub`
|
||||||
|
and can be directly executed:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./lexer.d
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want to see the log output or want to pass additional options, use `--single`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
dub --single -v lexer.d
|
||||||
|
```
|
||||||
|
|
||||||
|
If you don't have `dub` installed on your system,
|
||||||
|
[install an official release](https://dlang.org/download.html).
|
31
test/dub_package/lexer.d
Executable file
31
test/dub_package/lexer.d
Executable file
|
@ -0,0 +1,31 @@
|
||||||
|
#!/usr/bin/env dub
|
||||||
|
/+dub.sdl:
|
||||||
|
dependency "dmd" path="../.."
|
||||||
|
+/
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
import dmd.lexer;
|
||||||
|
import dmd.tokens;
|
||||||
|
|
||||||
|
immutable expected = [
|
||||||
|
TOKvoid,
|
||||||
|
TOKidentifier,
|
||||||
|
TOKlparen,
|
||||||
|
TOKrparen,
|
||||||
|
TOKlcurly,
|
||||||
|
TOKrcurly
|
||||||
|
];
|
||||||
|
|
||||||
|
immutable sourceCode = "void test() {} // foobar";
|
||||||
|
scope lexer = new Lexer("test", sourceCode.ptr, 0, sourceCode.length, 0, 0);
|
||||||
|
lexer.nextToken;
|
||||||
|
|
||||||
|
TOK[] result;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
result ~= lexer.token.value;
|
||||||
|
} while (lexer.nextToken != TOKeof);
|
||||||
|
|
||||||
|
assert(result == expected);
|
||||||
|
}
|
38
test/dub_package/parser.d
Normal file → Executable file
38
test/dub_package/parser.d
Normal file → Executable file
|
@ -1,44 +1,8 @@
|
||||||
|
#!/usr/bin/env dub
|
||||||
/+dub.sdl:
|
/+dub.sdl:
|
||||||
dependency "dmd" path="../.."
|
dependency "dmd" path="../.."
|
||||||
+/
|
+/
|
||||||
// The tests in this module are highlevel and mostly indented to make sure all
|
|
||||||
// necessary modules are included in the Dub package.
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// lexer
|
|
||||||
unittest
|
|
||||||
{
|
|
||||||
import dmd.lexer;
|
|
||||||
import dmd.tokens;
|
|
||||||
|
|
||||||
immutable expected = [
|
|
||||||
TOKvoid,
|
|
||||||
TOKidentifier,
|
|
||||||
TOKlparen,
|
|
||||||
TOKrparen,
|
|
||||||
TOKlcurly,
|
|
||||||
TOKrcurly
|
|
||||||
];
|
|
||||||
|
|
||||||
immutable sourceCode = "void test() {} // foobar";
|
|
||||||
scope lexer = new Lexer("test", sourceCode.ptr, 0, sourceCode.length, 0, 0);
|
|
||||||
lexer.nextToken;
|
|
||||||
|
|
||||||
TOK[] result;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
result ~= lexer.token.value;
|
|
||||||
} while (lexer.nextToken != TOKeof);
|
|
||||||
|
|
||||||
assert(result == expected);
|
|
||||||
}
|
|
||||||
|
|
||||||
// parser
|
|
||||||
unittest
|
|
||||||
{
|
{
|
||||||
import dmd.astbase;
|
import dmd.astbase;
|
||||||
import dmd.parse;
|
import dmd.parse;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue