Removed unused resources directory hopefully,

And aslo added an IconHelper autoplugin which
will generate Mac OS X valid ICNS images.
This commit is contained in:
meeh
2018-04-24 05:01:25 +00:00
parent 832e55ddf9
commit 4f47fab139
3 changed files with 58 additions and 0 deletions

View File

@ -1,6 +1,7 @@
import sbt._ import sbt._
import Keys._ import Keys._
scalaVersion in Global := "2.11.11"
resolvers ++= Seq( resolvers ++= Seq(
DefaultMavenRepository, DefaultMavenRepository,
@ -40,6 +41,7 @@ lazy val macosx = (project in file("macosx"))
lazy val root = (project in file(".")) lazy val root = (project in file("."))
.aggregate(browserbundle, macosx) .aggregate(browserbundle, macosx)
scalacOptions in Compile := Seq("-deprecated")
fork := true fork := true

View File

@ -17,6 +17,10 @@ lazy val i2pBuildDir = new File("./../build")
lazy val warsForCopy = i2pBuildDir.list.filter { f => f.endsWith(".war") } lazy val warsForCopy = i2pBuildDir.list.filter { f => f.endsWith(".war") }
lazy val jarsForCopy = i2pBuildDir.list.filter { f => f.endsWith(".jar") } lazy val jarsForCopy = i2pBuildDir.list.filter { f => f.endsWith(".jar") }
convertToICNSTask := {
println("TODO")
}
buildAppBundleTask := { buildAppBundleTask := {
println(s"Building Mac OS X bundle for I2P version ${i2pVersion}.") println(s"Building Mac OS X bundle for I2P version ${i2pVersion}.")
bundleBuildPath.mkdir() bundleBuildPath.mkdir()

View File

@ -0,0 +1,52 @@
package root
import sbt._, Keys._
import java.io.File
/**
*
* This is an autoplugin for sbt which makes it possible to
* create an correctly made icns file for usage as app icon.
*
* The task "convertToICNSTask" should become available for us to define
* because of this class.
*
* sips is only a command on Mac OS X afaik so this would probably need to be
* built on a mac.
*
* @since 0.9.35
*/
object IconHelper extends AutoPlugin {
def convertToICNS(inF: File, outF: File) {
if (inF.ext == "icns") {
IO.copyFile(inF, outF, preserveLastModified = true)
} else {
import sys.process._
val lines = Seq("sips", "-g", "pixelHeight", "-g", "pixelWidth", inF.getPath).lines
val PixelWidth = "\\s+pixelWidth: (\\d+)".r
val PixelHeight = "\\s+pixelHeight: (\\d+)".r
val srcWidth = lines.collect { case PixelWidth (s) => s.toInt } .head
val srcHeight = lines.collect { case PixelHeight(s) => s.toInt } .head
val supported = IndexedSeq(16, 32, 48, 128, 256, 512)
val srcSize = math.min(512, math.max(srcWidth, srcHeight))
val tgtSize = supported(supported.indexWhere(_ >= srcSize))
val args0 = Seq(inF.getPath, "--out", outF.getPath)
val args1 = if (tgtSize != srcWidth || tgtSize != srcHeight) {
Seq("-z", tgtSize.toString, tgtSize.toString)
} else {
Seq.empty
}
val args = Seq("sips", "-s", "format", "icns") ++ args1 ++ args0
args.!!
}
}
object autoImport {
val convertToICNSTask = taskKey[Unit]("Converts an image to Mac OS X's ICNS icon format")
}
import autoImport._
}