-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to define project descriptor to allow for dependency specific f…
…oreign code compilation (#3389) * Support project settings and build configuration via properties file
- Loading branch information
Showing
7 changed files
with
331 additions
and
106 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
6 changes: 6 additions & 0 deletions
6
javalib/src/main/resources/scala-native/scala-native.properties
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,6 @@ | ||
# output for debugging | ||
project.organization = org.scala-native | ||
project.name = javalib | ||
|
||
# defines SCALANATIVE_LINK_Z if @link("z") annnotation is used (found in NIR) | ||
nir.link.names = z |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# output for debugging | ||
project.orgainzation = org.scala-native | ||
project.name = nativelib | ||
|
||
# setup define based on GC selected | ||
project.gcProject = true | ||
|
||
# CG define | ||
preprocessor.defines = NDEBUG | ||
|
||
# path to vendored libunwind and GC | ||
compile.include.paths = platform/posix/libunwind, gc |
53 changes: 53 additions & 0 deletions
53
tools/src/main/scala/scala/scalanative/build/Descriptor.scala
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,53 @@ | ||
package scala.scalanative.build | ||
|
||
import java.io.FileReader | ||
import java.nio.file.Path | ||
import java.util.Properties | ||
|
||
import scala.util.Try | ||
import java.io.Reader | ||
import scala.annotation.tailrec | ||
|
||
final case class Descriptor( | ||
organization: Option[String], | ||
name: Option[String], | ||
gcProject: Boolean, | ||
links: List[String], | ||
defines: List[String], | ||
includes: List[String] | ||
) | ||
|
||
object Descriptor { | ||
|
||
def load(path: Path): Try[Descriptor] = Try { | ||
var reader: Reader = null | ||
try { | ||
reader = new FileReader(path.toFile()) | ||
val props = new Properties() | ||
props.load(reader) | ||
Descriptor( | ||
Option(props.getProperty("project.organization")), | ||
Option(props.getProperty("project.name")), | ||
props.getProperty("project.gcProject", "false").toBoolean, | ||
parseStrings("nir.link.names", props), | ||
parseStrings("preprocessor.defines", props), | ||
parseStrings("compile.include.paths", props) | ||
) | ||
} finally { | ||
if (reader != null) { | ||
try { | ||
reader.close() | ||
} catch { | ||
case t: Throwable => | ||
} | ||
} | ||
} | ||
} | ||
|
||
private def parseStrings(prop: String, props: Properties): List[String] = | ||
Option(props.getProperty(prop)) match { | ||
case Some(value) => value.split(',').map(_.trim()).toList | ||
case None => List.empty | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.