Commit 0b8b3339 authored by Drew's avatar Drew

Add `publishProduct` atllbuild option

This allows a build.atpkg to export its products into a user-visible directory.

I'm not totally sure this is the right design, but it does resolve #17.
parent 889b61b0
Pipeline #966 failed with stage
......@@ -199,7 +199,9 @@ final class ATllbuild : Tool {
"linkWithProduct",
"swiftCPath",
"xctestify",
"xctestStrict"]
"xctestStrict",
"publishProduct"]
for key in task.allKeys {
if !knownOptions.contains(key) {
print("Warning: unknown option \(key) for task \(task.qualifiedName)")
......@@ -321,5 +323,25 @@ final class ATllbuild : Tool {
if system(cmd) != 0 {
fatalError(cmd)
}
if task["publishProduct"]?.bool == true {
if !manager.fileExistsAtPath("bin") {
try! manager.createDirectoryAtPath("bin", withIntermediateDirectories: false, attributes: nil)
}
try! copyByOverwriting("\(workDirectory)/products/\(name).swiftmodule", toPath: "bin/\(name).swiftmodule")
switch outputType {
case .Executable:
try! copyByOverwriting("\(workDirectory)/products/\(name)", toPath: "bin/\(name)")
case .StaticLibrary:
try! copyByOverwriting("\(workDirectory)/products/\(name).a", toPath: "bin/\(name).a")
}
}
}
}
private func copyByOverwriting(fromPath: String, toPath: String) throws {
let manager = NSFileManager.defaultManager()
if manager.fileExistsAtPath(toPath) {
try manager.removeItemAtPath(toPath)
}
try! manager.copyItemAtPath(fromPath, toPath: toPath)
}
\ No newline at end of file
......@@ -19,6 +19,9 @@ The `atllbuild` tool uses the [`swift-llbuild`](https://github.com/apple/swift-l
;;walk the src directory and recursively find all swift files
:source ["src/**.swift"]
;;if true, we publish the product to the bin/ directory.
:publishProduct false
;;If true, we don't build, we only output llbuild.yaml False is the default value.
:bootstrapOnly: false
;;Path to emit llbuild.yaml
......
(package
:name "publish_product"
:tasks {
:executable {
:tool "atllbuild"
:outputType "executable"
:name "executable"
:source ["main.swift"]
:publishProduct true
}
:library {
:tool "atllbuild"
:outputType "static-library"
:name "library"
:source ["lib.swift"]
:publishProduct true
}
:default {
:tool "nop"
:dependencies ["executable" "library"]
}
}
)
\ No newline at end of file
class Foo { }
\ No newline at end of file
print("Hello world!")
\ No newline at end of file
......@@ -10,6 +10,30 @@ pwd
echo "****************SELF-HOSTING TEST**************"
$ATBUILD atbuild
echo "****************PUBLISHPRODUCT TEST**************"
cd $DIR/tests/fixtures/publish_product
$ATBUILD
if [ ! -f "bin/executable" ]; then
echo "No executable"
exit 1
fi
if [ ! -f "bin/executable.swiftmodule" ]; then
echo "No module (executable)"
exit 1
fi
if [ ! -f "bin/library.swiftmodule" ]; then
echo "No module (library)"
exit 1
fi
if [ ! -f "bin/library.a" ]; then
echo "No library"
exit 1
fi
echo "****************AGRESSIVE TEST**************"
cd $DIR/tests/fixtures/agressive
if $ATBUILD 2&> /tmp/warnings.txt; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment