Commit defd7f81 authored by Drew's avatar Drew

Merge remote-tracking branch 'origin/master' into umbrella_headers

parents fa2efa95 ea762196
Pipeline #1088 passed with stage
......@@ -9,7 +9,7 @@ linux:
- docker build -t atbuild .
- id=$(docker create atbuild)
- mkdir bin
- docker cp $id:atbuild/.atllbuild/products/atbuild bin/atbuild
- docker cp $id:atbuild/bin/atbuild bin/atbuild
- docker rm -v $id
- docker rmi atbuild
tags:
......@@ -23,9 +23,9 @@ osx:
script:
- export PATH=/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin:"${PATH}"
- ./bootstrap/build.sh
- .atllbuild/products/atbuild check
- bin/atbuild check
tags:
- openswift
artifacts:
paths:
- .atllbuild/products/atbuild
- bin/atbuild
// Place your settings in this file to overwrite default and user settings.
{
"editor.tabSize": 4,
"editor.insertSpaces": true
}
\ No newline at end of file
# atbuild
[![Anarchy Tools compatible](https://img.shields.io/badge/Anarchy%20Tools-compatible-4BC51D.svg?style=flat)](http://anarchytools.org)
The Anarchy Tools Build Tool.
`atbuild` is a cross-platform build system, primarily for Swift-language projects, following the [Anarchy Tools philosophy](https://github.com/AnarchyTools/AnarchyTools) of simple, unopinionated, hackable tools.
......@@ -89,3 +91,11 @@ Usage:
atbuild [task]
task: ["default", "helloworld", "bootstrap"]
```
# Badges
To declare your project to be compatible with Anarchy Tools, simply
```markdown
[![Anarchy Tools compatible](https://img.shields.io/badge/Anarchy%20Tools-compatible-4BC51D.svg?style=flat)](http://anarchytools.org)
```
Subproject commit e3037b4c5a38db2350564c07d17acadc32ff19fa
Subproject commit 7c5ec16f21c90a486b018d7e4eb313d5ebfa583d
......@@ -23,6 +23,7 @@ import atpkg
*/
final class Shell : Tool {
func run(task: Task) {
setenv("ATBUILD_USER_PATH", userPath(), 1)
guard let script = task["script"]?.string else { fatalError("Invalid 'script' argument to shell tool.") }
do {
let oldPath = NSFileManager.defaultManager().currentDirectoryPath
......
......@@ -13,6 +13,7 @@
// limitations under the License.
import atpkg
import Foundation
/** The builtin tools. */
let tools: [String:Tool] = [
......@@ -38,3 +39,18 @@ func toolByName(name: String) -> Tool {
guard let tool = tools[name] else { fatalError("Unknown build tool \(name)") }
return tool
}
private var userPathCreated = false
/**Returns the "user" path. This is a path that the user may use to store artifacts or for any other purposes. This path is shared for all tasks built as part of the same `atbuild` invocation.
- postcondition: The path exists at this absolute locaton on disk.
- warning: This path is cleared between atbuild invocations. */
func userPath() -> String {
let manager = NSFileManager.defaultManager()
let userPath = manager.currentDirectoryPath + "/user"
if !userPathCreated {
let _ = try? manager.removeItemAtPath(userPath)
try! manager.createDirectoryAtPath(userPath, withIntermediateDirectories: false, attributes: nil)
userPathCreated = true
}
return userPath
}
......@@ -15,25 +15,22 @@
import Foundation
import atpkg
#if os(Linux)
import Glibc //need sleep
#endif
/**Synthesize a module map.
- parameter name: The name of the module to synthesize
- parameter umbrellaHeader: A path to the umbrella header. The path must be relative to the exported module map file.
- returns String contents of the synthesized modulemap
*/
private func synthesizeModuleMap(name: String, umbrellaHeader: String?) -> String {
var s = ""
s += "module \(name) {\n"
if let u = umbrellaHeader {
s += " umbrella header \"\(u)\"\n"
}
s += "\n"
s += "}\n"
return s
}
/**Synthesize a module map.
- parameter name: The name of the module to synthesize
- parameter umbrellaHeader: A path to the umbrella header. The path must be relative to the exported module map file.
- returns String contents of the synthesized modulemap
*/
private func synthesizeModuleMap(name: String, umbrellaHeader: String?) -> String {
var s = ""
s += "module \(name) {\n"
if let u = umbrellaHeader {
s += " umbrella header \"\(u)\"\n"
}
s += "\n"
s += "}\n"
return s
}
/**The ATllbuild tool builds a swift module via llbuild.
For more information on this tool, see `docs/attllbuild.md` */
......@@ -219,6 +216,7 @@ final class ATllbuild : Tool {
case SwiftCPath = "swiftc-path"
case XCTestify = "xctestify"
case XCTestStrict = "xctest-strict"
case IncludeWithUser = "include-with-user"
case PublishProduct = "publish-product"
case UmbrellaHeader = "umbrella-header"
case ModuleMap = "module-map"
......@@ -240,9 +238,9 @@ final class ATllbuild : Tool {
SwiftCPath,
XCTestify,
XCTestStrict,
IncludeWithUser,
PublishProduct,
UmbrellaHeader,
ModuleMap
UmbrellaHeader
]
}
}
......@@ -299,6 +297,13 @@ final class ATllbuild : Tool {
compileOptions.append(os)
}
}
if let includePaths = task[Options.IncludeWithUser.rawValue]?.vector {
for path_s in includePaths {
guard let path = path_s.string else { fatalError("Non-string path \(path_s)") }
compileOptions.append("-I")
compileOptions.append(userPath() + "/" + path)
}
}
var linkOptions: [String] = []
if let opts = task[Options.LinkOptions.rawValue]?.vector {
for o in opts {
......
......@@ -26,7 +26,8 @@
:output-type "executable"
:link-with ["attools.a" "atpkg.a"]
:dependencies ["attools" "atpkg.atpkg"]
:publish-product true
:overlays {
:bootstrap-osx {
:bootstrap-only true
......
(package
:name "b"
:tasks {
:second {
:tool "shell"
:script "echo SECOND >> $ATBUILD_USER_PATH/test"
}
}
)
\ No newline at end of file
import Foo
\ No newline at end of file
(package
:name "user_paths"
:import-packages ["b/build.atpkg"]
:tasks {
:first {
:tool "shell"
:script "echo FIRST >> $ATBUILD_USER_PATH/test"
}
:third {
:tool "shell"
:script "echo THIRD >> $ATBUILD_USER_PATH/test"
:dependencies ["first" "b.second"]
}
:compiledep {
:tool "shell"
:script "mkdir $ATBUILD_USER_PATH/Foo && echo module Foo { } > $ATBUILD_USER_PATH/Foo/module.modulemap"
}
:compile {
:tool "atllbuild"
:sources ["bar.swift"]
:include-with-user ["Foo"]
:dependencies ["compiledep"]
:output-type "static-library"
:name "bar"
}
}
)
\ No newline at end of file
......@@ -14,6 +14,22 @@ echo "****************UMBRELLA TEST**************"
cd $DIR/tests/fixtures/umbrella_header
$ATBUILD check
echo "****************USER PATH TEST**************"
cd $DIR/tests/fixtures/user_paths
$ATBUILD third
RESULT=`cat user/test`
RESULT2="FIRST
SECOND
THIRD"
if [ "$RESULT" != "$RESULT2" ]; then
echo "Unusual user path concoction $RESULT $RESULT2"
exit 1
fi
$ATBUILD compile
echo "****************PUBLISHPRODUCT TEST**************"
cd $DIR/tests/fixtures/publish_product
$ATBUILD
......
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