@@ -4,10 +4,55 @@ import scala.tasty.Reflection
4
4
import scala .tasty .file ._
5
5
import scala .NotImplementedError
6
6
7
+ import dotty .tools .dotc .Driver
8
+
7
9
object Main {
10
+ def parseArguments (args : Array [String ]): (Map [String , String ], Boolean ) = {
11
+ def nextArgument (optionMap : Map [String , String ], args : List [String ]): Map [String , String ] = args match {
12
+ case " --out" :: file :: tail => nextArgument(optionMap + (" outfile" -> file), tail)
13
+ case " -o" :: file :: tail => nextArgument(optionMap + (" outfile" -> file), tail)
14
+ case " --help" :: tail => nextArgument(optionMap + (" help" -> " " ), tail)
15
+ case " -h" :: tail => nextArgument(optionMap + (" help" -> " " ), tail)
16
+ case " --temp" :: folder :: tail => nextArgument(optionMap + (" temp" -> folder), tail)
17
+ case " -t" :: folder :: tail => nextArgument(optionMap + (" temp" -> folder), tail)
18
+ case file :: tail => nextArgument(optionMap + (" input" -> file), tail)
19
+ case Nil => optionMap
20
+ }
21
+
22
+ val help = """ Usage semanticdb [options] [file]
23
+ |Generate semanticdb's information related to the source file [file]
24
+ |Options are:
25
+ | -h,--help Show help
26
+ | -o <file>, --out <file> Place the output into <file>
27
+ | -t <folder>, --temp <folder> Use <folder> as the temp directory to store build artifacts
28
+ """ .stripMargin
29
+
30
+ var optionMap = nextArgument(Map (), args.toList)
31
+ if (optionMap.contains(" help" ) || ! optionMap.contains(" input" )) {
32
+ println(help)
33
+ return (optionMap, false )
34
+ } else {
35
+ if (! optionMap.contains(" temp" )) {
36
+ optionMap += (" temp" -> " /home/pierre/epfl/semester/dotty/semanticdb/testClass/" )
37
+ }
38
+ val driver = new Driver
39
+ val compilerParams : List [String ] =
40
+ optionMap(" input" ) ::
41
+ " -Yno-inline" ::
42
+ " -d" :: optionMap(" temp" ) ::
43
+ " -classpath" :: " /home/pierre/epfl/semester/dotty/library/../out/bootstrap/dotty-library-bootstrapped/scala-0.12/dotty-library_0.12-0.12.0-bin-SNAPSHOT.jar" ::
44
+ Nil
45
+
46
+ val foo = driver.process(compilerParams.toArray)
47
+ return (optionMap, true )
48
+ }
49
+ }
50
+
51
+
8
52
def main (args : Array [String ]): Unit = {
9
53
val extraClasspath = " ." // TODO allow to set it from the args with -classpath XYZ
10
54
val classes = args.toList
55
+ val (optionMap, canTreat) = parseArguments(args)
11
56
if (args.isEmpty) {
12
57
println(" Dotty Semantic DB: No classes where passed as argument" )
13
58
} else {
0 commit comments