Created
August 17, 2012 13:35
-
-
Save fjolnir/3378731 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
\ Tranquil compiler | |
import "CoreFoundation" | |
inPath = "Tests/smartfib.tq" | |
outPath = "a.out" | |
runtimeLibPath = "Build/libtranquil.dylib" | |
ldFlags = ["-lobjc", runtimeLibPath] | |
(0 to: (... count)) each: { i | | |
if ...[i] == "-o" | |
outPath = ...[++i] | |
else if inPath == nil | |
inPath = ...[i] | |
else | |
ldFlags << ...[i] | |
} | |
irPath = "/tmp/#{CFUUIDCreateString(nil, CFUUIDCreate(nil))}.bc" | |
compilationTask = NSTask launchedTaskWithLaunchPath: "Build/tranquil" | |
arguments: ["-aot", "-o", irPath, inPath]; | |
waitUntilExit; | |
self | |
if (compilationTask terminationStatus) != 0 | |
Abort() | |
asmPath = "/tmp/#{CFUUIDCreateString(nil, CFUUIDCreate(nil))}.s" | |
assemblingTask = NSTask launchedTaskWithLaunchPath: "/usr/local/llvm/bin/llc" | |
arguments: ["-O2", "-o", asmPath, irPath]; | |
waitUntilExit; | |
self | |
if (assemblingTask terminationStatus) != 0 | |
Abort() | |
linkingTask = NSTask launchedTaskWithLaunchPath: "/usr/local/llvm/bin/clang" | |
arguments: ldFlags + ["-o", outPath, asmPath]; | |
waitUntilExit; | |
self | |
if (linkingTask terminationStatus) != 0 | |
Abort() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment