21 object V { |
21 object V { |
22 val fatags = "0.6-SNAPSHOT" |
22 val fatags = "0.6-SNAPSHOT" |
23 val scalaJs = "0.6.33" |
23 val scalaJs = "0.6.33" |
24 val scala211 = "2.11.12" |
24 val scala211 = "2.11.12" |
25 val scala212 = "2.12.12" |
25 val scala212 = "2.12.12" |
|
26 val scala213 = "2.13.4" |
|
27 val scalatags = "0.9.2" |
26 } |
28 } |
27 |
29 |
28 object D { |
30 object D { |
29 val scalatags = ivy"com.lihaoyi::scalatags::0.6.8" |
31 val scalatags211 = ivy"com.lihaoyi::scalatags::0.6.8" |
|
32 val scalatags = ivy"com.lihaoyi::scalatags::${V.scalatags}" |
30 } |
33 } |
31 |
34 |
32 def camelCase(s: String): String = { |
35 def camelCase(s: String): String = { |
33 def inner(l: List[Char]): List[Char] = l match { |
36 def inner(l: List[Char]): List[Char] = l match { |
34 case '-' :: '-' :: c :: rest => c.toUpper :: inner(rest) |
37 case '-' :: '-' :: c :: rest => c.toUpper :: inner(rest) |
36 case c :: rest => c :: inner(rest) |
39 case c :: rest => c :: inner(rest) |
37 case Nil => Nil |
40 case Nil => Nil |
38 } |
41 } |
39 inner(s toList) mkString "" |
42 inner(s toList) mkString "" |
40 } |
43 } |
|
44 |
|
45 val compilerOptions = Seq( |
|
46 "-deprecation", // Emit warning and location for usages of deprecated APIs. |
|
47 "-encoding", "utf-8", // Specify character encoding used by source files. |
|
48 "-explaintypes", // Explain type errors in more detail. |
|
49 "-feature", // Emit warning and location for usages of features that should be imported explicitly. |
|
50 "-language:higherKinds", // Allow higher-kinded types |
|
51 "-language:implicitConversions", // Allow definition of implicit functions called views |
|
52 "-language:reflectiveCalls", |
|
53 "-language:postfixOps", |
|
54 "-unchecked", // Enable additional warnings where generated code depends on assumptions. |
|
55 "-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access. |
|
56 "-target:jvm-1.8" |
|
57 ) |
41 |
58 |
42 trait Common extends CrossSbtModule with PublishModule { |
59 trait Common extends CrossSbtModule with PublishModule { |
43 |
60 |
44 override def artifactName = "fatags" |
61 override def artifactName = "fatags" |
45 |
62 |
55 developers = Seq( |
72 developers = Seq( |
56 Developer("tzeman", "Tomas Zeman", "") |
73 Developer("tzeman", "Tomas Zeman", "") |
57 ) |
74 ) |
58 ) |
75 ) |
59 |
76 |
60 override def scalacOptions = T{Seq( |
77 override def scalacOptions: T[Seq[String]] = T{compilerOptions} |
61 "-deprecation", // Emit warning and location for usages of deprecated APIs. |
|
62 "-encoding", "utf-8", // Specify character encoding used by source files. |
|
63 "-explaintypes", // Explain type errors in more detail. |
|
64 "-feature", // Emit warning and location for usages of features that should be imported explicitly. |
|
65 "-language:higherKinds", // Allow higher-kinded types |
|
66 "-language:implicitConversions", // Allow definition of implicit functions called views |
|
67 "-language:reflectiveCalls", |
|
68 "-language:postfixOps", |
|
69 "-unchecked", // Enable additional warnings where generated code depends on assumptions. |
|
70 "-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access. |
|
71 "-Xfuture", // Turn on future language features. |
|
72 "-target:jvm-1.8" |
|
73 )} |
|
74 |
78 |
75 def hgId: Input[String] = T.input { |
79 def hgId: Input[String] = T.input { |
76 os.proc("hg", "id", "-i").call().out.text.trim |
80 os.proc("hg", "id", "-i").call().out.text.trim |
77 } |
81 } |
78 |
82 |
82 |
86 |
83 def hgTag: Input[Option[String]] = T.input { |
87 def hgTag: Input[Option[String]] = T.input { |
84 os.proc("hg", "id", "-t").call().out.text.trim.split(' ').headOption |
88 os.proc("hg", "id", "-t").call().out.text.trim.split(' ').headOption |
85 } |
89 } |
86 |
90 |
87 override def ivyDeps: Target[Loose.Agg[Dep]] = Agg(D.scalatags) |
91 override def ivyDeps: Target[Loose.Agg[Dep]] = T{ |
|
92 if (scalaVersion() == V.scala211) Agg(D.scalatags211) else Agg(D.scalatags) |
|
93 } |
88 |
94 |
89 override def sources: Sources = T.sources{ |
95 override def sources: Sources = T.sources{ |
90 super.sources() :+ PathRef(millSourcePath / 'shared / 'src / 'main / 'scala) |
96 super.sources() :+ PathRef(millSourcePath / 'shared / 'src / 'main / 'scala) |
91 } |
97 } |
92 |
98 |
140 class JsModule(val crossScalaVersion: String) extends ScalaJSModule |
146 class JsModule(val crossScalaVersion: String) extends ScalaJSModule |
141 with Common { |
147 with Common { |
142 override def scalaJSVersion: Target[String] = V.scalaJs |
148 override def scalaJSVersion: Target[String] = V.scalaJs |
143 } |
149 } |
144 |
150 |
145 object jvm extends Cross[JvmModule](V.scala211, V.scala212) |
151 object jvm extends Cross[JvmModule](V.scala211, V.scala212, V.scala213) |
146 object js extends Cross[JsModule](V.scala211, V.scala212) |
152 object js extends Cross[JsModule](V.scala211, V.scala212, V.scala213) |
147 |
153 |
148 def publishLocal(): define.Command[Unit] = T.command{ |
154 def compileAll(): Command[Unit] = T.command{ |
|
155 jvm(V.scala213).compile() |
|
156 js(V.scala213).compile() |
|
157 jvm(V.scala212).compile() |
|
158 js(V.scala212).compile() |
|
159 jvm(V.scala211).compile() |
|
160 js(V.scala211).compile() |
|
161 () |
|
162 } |
|
163 |
|
164 def publishLocal(): Command[Unit] = T.command{ |
|
165 jvm(V.scala213).publishLocal()() |
|
166 js(V.scala213).publishLocal()() |
149 jvm(V.scala212).publishLocal()() |
167 jvm(V.scala212).publishLocal()() |
150 js(V.scala212).publishLocal()() |
168 js(V.scala212).publishLocal()() |
151 jvm(V.scala211).publishLocal()() |
169 jvm(V.scala211).publishLocal()() |
152 js(V.scala211).publishLocal()() |
170 js(V.scala211).publishLocal()() |
153 } |
171 } |
154 |
172 |
155 def publishM2Local(p: os.Path): define.Command[Unit] = T.command{ |
173 def publishM2Local(p: os.Path): Command[Unit] = T.command{ |
|
174 jvm(V.scala213).publishM2Local(p.toString)() |
|
175 js(V.scala213).publishM2Local(p.toString)() |
156 jvm(V.scala212).publishM2Local(p.toString)() |
176 jvm(V.scala212).publishM2Local(p.toString)() |
157 js(V.scala212).publishM2Local(p.toString)() |
177 js(V.scala212).publishM2Local(p.toString)() |
158 jvm(V.scala211).publishM2Local(p.toString)() |
178 jvm(V.scala211).publishM2Local(p.toString)() |
159 js(V.scala211).publishM2Local(p.toString)() |
179 js(V.scala211).publishM2Local(p.toString)() |
160 () |
180 () |
161 } |
181 } |
162 |
182 |
163 object example extends ScalaModule with ScalaJSModule { |
183 object example extends ScalaModule with ScalaJSModule { |
164 override def scalaVersion: Target[String] = T{V.scala212} |
184 override def scalaVersion: Target[String] = T{V.scala213} |
165 override def scalaJSVersion: Target[String] = V.scalaJs |
185 override def scalaJSVersion: Target[String] = V.scalaJs |
166 |
186 |
|
187 override def scalacOptions: T[Seq[String]] = T{compilerOptions} |
167 |
188 |
168 /* Ugly hack to prevent |
189 override def moduleDeps: Seq[PublishModule] = Seq(js(V.scala213)) |
169 * "Referring to non-existent method fontawesome.generic.FA... error" |
190 |
170 */ |
|
171 //override def moduleDeps: Seq[PublishModule] = Seq(js(V.scala212)) |
|
172 override def ivyDeps: Target[Loose.Agg[Dep]] = Agg(D.scalatags) |
|
173 override def sources: Sources = T.sources{super.sources() ++ js(V.scala212).sources()} |
|
174 override def generatedSources = T{js(V.scala212).generatedSources()} |
|
175 } |
191 } |
176 |
192 |
177 |
|
178 // vim: et ts=2 sw=2 syn=scala |
193 // vim: et ts=2 sw=2 syn=scala |