Another attempt at M1 compilation (#3859)

This commit is contained in:
Marcin Kostrzewa 2022-11-09 16:26:25 +01:00 committed by GitHub
parent e8f3ad3979
commit 23e04f905f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 18 deletions

View File

@ -667,11 +667,23 @@ lazy val `text-buffer` = project
) )
) )
lazy val rustParserTargetDirectory =
SettingKey[File]("target directory for the Rust parser")
(`syntax-rust-definition` / rustParserTargetDirectory) := {
// setting "debug" for release, because it isn't yet safely integrated into
// the parser definition
val versionName = if (BuildInfo.isReleaseMode) "debug" else "debug"
target.value / "rust" / versionName
}
val generateRustParserLib = val generateRustParserLib =
TaskKey[Seq[File]]("generateRustParserLib", "Generates parser native library") TaskKey[Seq[File]]("generateRustParserLib", "Generates parser native library")
`syntax-rust-definition` / generateRustParserLib := { `syntax-rust-definition` / generateRustParserLib := {
import sys.process._ import sys.process._
val libGlob = target.value.toGlob / "rust" / * / "libenso_parser.so" val libGlob =
(`syntax-rust-definition` / rustParserTargetDirectory).value.toGlob / "libenso_parser.so"
val allLibs = FileTreeView.default.list(Seq(libGlob)).map(_._1) val allLibs = FileTreeView.default.list(Seq(libGlob)).map(_._1)
if ( if (
sys.env.get("CI").isDefined || sys.env.get("CI").isDefined ||
@ -679,11 +691,25 @@ val generateRustParserLib =
(`syntax-rust-definition` / generateRustParserLib).inputFileChanges.hasChanges (`syntax-rust-definition` / generateRustParserLib).inputFileChanges.hasChanges
) { ) {
val os = System.getProperty("os.name") val os = System.getProperty("os.name")
if (os.startsWith("Mac")) { val baseCommand = Seq(
Seq("cargo", "build", "-p", "enso-parser-jni", "--target", "x86_64-apple-darwin") ! "cargo",
} else { "build",
Seq("cargo", "build", "-p", "enso-parser-jni") ! "-p",
} "enso-parser-jni",
"-Z",
"unstable-options",
"--out-dir",
(`syntax-rust-definition` / rustParserTargetDirectory).value.toString
)
val releaseMode = baseCommand ++
(if (BuildInfo.isReleaseMode)
Seq("--release")
else Seq())
val macBuild = releaseMode ++
(if (os.contains("Mac"))
Seq("--target", "x86_64-apple-darwin")
else Seq())
macBuild !
} }
FileTreeView.default.list(Seq(libGlob)).map(_._1.toFile) FileTreeView.default.list(Seq(libGlob)).map(_._1.toFile)
} }
@ -2041,7 +2067,8 @@ buildEngineDistribution := {
ensoVersion = ensoVersion, ensoVersion = ensoVersion,
editionName = currentEdition, editionName = currentEdition,
sourceStdlibVersion = stdLibVersion, sourceStdlibVersion = stdLibVersion,
targetStdlibVersion = targetStdlibVersion targetStdlibVersion = targetStdlibVersion,
targetDir = (`syntax-rust-definition` / rustParserTargetDirectory).value
) )
log.info(s"Engine package created at $root") log.info(s"Engine package created at $root")
} }

View File

@ -27,8 +27,7 @@ public final class Parser implements AutoCloseable {
} catch (URISyntaxException | LinkageError e) { } catch (URISyntaxException | LinkageError e) {
System.err.println("Cannot load " + parser); System.err.println("Cannot load " + parser);
File root = new File(".").getAbsoluteFile(); File root = new File(".").getAbsoluteFile();
if (!searchFromDirToTop(e, root, "target", "rust", "x86_64-apple-darwin", "debug", name) if (!searchFromDirToTop(e, root, "target", "rust", "debug", name)) {
&& !searchFromDirToTop(e, root, "target", "rust", "debug", name)) {
throw new IllegalStateException("Cannot load parser from " + parser, e); throw new IllegalStateException("Cannot load parser from " + parser, e);
} }
} }

View File

@ -63,7 +63,7 @@ object BuildInfo {
Seq(file) Seq(file)
} }
private def isReleaseMode: Boolean = def isReleaseMode: Boolean =
sys.env.get("ENSO_RELEASE_MODE").contains("true") sys.env.get("ENSO_RELEASE_MODE").contains("true")
/** Information regarding the Git repository that was used in the build. /** Information regarding the Git repository that was used in the build.

View File

@ -120,7 +120,8 @@ object DistributionPackage {
ensoVersion: String, ensoVersion: String,
editionName: String, editionName: String,
sourceStdlibVersion: String, sourceStdlibVersion: String,
targetStdlibVersion: String targetStdlibVersion: String,
targetDir: File
): Unit = { ): Unit = {
copyDirectoryIncremental( copyDirectoryIncremental(
@ -136,12 +137,7 @@ object DistributionPackage {
) )
val os = System.getProperty("os.name") val os = System.getProperty("os.name")
val isMac = os.startsWith("Mac") val isMac = os.startsWith("Mac")
val dir = if (isMac) { val parser = targetDir / (if (isMac) {
"target/rust/x86_64-apple-darwin/debug/"
} else {
"target/rust/debug/"
}
val parser = dir + (if (isMac) {
"libenso_parser.dylib" "libenso_parser.dylib"
} else if (os.startsWith("Windows")) { } else if (os.startsWith("Windows")) {
"enso_parser.dll" "enso_parser.dll"
@ -149,7 +145,7 @@ object DistributionPackage {
"libenso_parser.so" "libenso_parser.so"
}) })
copyFilesIncremental( copyFilesIncremental(
Seq(file(parser)), Seq(parser),
distributionRoot / "component", distributionRoot / "component",
cacheFactory.make("engine-parser-library") cacheFactory.make("engine-parser-library")
) )