Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
A
atbuild
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AnarchyTools
atbuild
Commits
93850f4e
Commit
93850f4e
authored
May 09, 2016
by
Drew
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #93 from AnarchyTools/executable-name
Add executable-name option to atllbuild
parents
b9601c3f
8af5d3c8
Pipeline
#1840
passed with stage
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
5 deletions
+40
-5
attools/src/atllbuild.swift
attools/src/atllbuild.swift
+15
-5
tests/fixtures/executable_name/build.atpkg
tests/fixtures/executable_name/build.atpkg
+20
-0
tests/fixtures/executable_name/src/main.swift
tests/fixtures/executable_name/src/main.swift
+1
-0
tests/test.sh
tests/test.sh
+4
-0
No files found.
attools/src/atllbuild.swift
View file @
93850f4e
...
...
@@ -70,9 +70,10 @@ final class ATllbuild : Tool {
* - parameter sources: A resolved list of swift sources
* - parameter workdir: A temporary working directory for `atllbuild` to use
* - parameter modulename: The name of the module to be built.
* - parameter executableName: The name of the executable to be built. Typically the same as the module name.
* - returns: The string contents for llbuild.yaml suitable for processing by swift-build-tool
*/
func
llbuildyaml
(
sources
:
[
Path
],
workdir
:
Path
,
modulename
:
String
,
linkSDK
:
Bool
,
compileOptions
:
[
String
],
linkOptions
:
[
String
],
outputType
:
OutputType
,
linkWithProduct
:[
String
],
swiftCPath
:
Path
)
->
String
{
func
llbuildyaml
(
sources
:
[
Path
],
workdir
:
Path
,
modulename
:
String
,
linkSDK
:
Bool
,
compileOptions
:
[
String
],
linkOptions
:
[
String
],
outputType
:
OutputType
,
linkWithProduct
:[
String
],
swiftCPath
:
Path
,
executableName
:
String
)
->
String
{
let
productPath
=
workdir
.
appending
(
"products"
)
//this format is largely undocumented, but I reverse-engineered it from SwiftPM.
var
yaml
=
"client:
\n
name: swift-build
\n\n
"
...
...
@@ -138,7 +139,7 @@ final class ATllbuild : Tool {
llbuild_inputs
+=
objects
let
builtProducts
=
linkWithProduct
.
map
{
(
workdir
+
(
"products/"
+
$0
))
.
description
}
llbuild_inputs
+=
builtProducts
let
executablePath
=
productPath
.
appending
(
modulen
ame
)
let
executablePath
=
productPath
.
appending
(
executableN
ame
)
yaml
+=
" inputs:
\(
llbuild_inputs
)\n
"
yaml
+=
" outputs: [
\"
<atllbuild>
\"
,
\"\(
executablePath
)\"
]
\n
"
//and now we have the crazy 'args'
...
...
@@ -209,6 +210,7 @@ final class ATllbuild : Tool {
case
ModuleMap
=
"module-map"
case
WholeModuleOptimization
=
"whole-module-optimization"
case
Framework
=
"framework"
case
ExecutableName
=
"executable-name"
static
var
allOptions
:
[
Options
]
{
...
...
@@ -230,7 +232,8 @@ final class ATllbuild : Tool {
PublishProduct
,
UmbrellaHeader
,
WholeModuleOptimization
,
Framework
Framework
,
ExecutableName
]
}
}
...
...
@@ -394,6 +397,13 @@ final class ATllbuild : Tool {
guard
let
name
=
task
[
Options
.
Name
.
rawValue
]?
.
string
else
{
fatalError
(
"No name for atllbuild task"
)
}
let
executableName
:
String
if
let
e
=
task
[
Options
.
ExecutableName
.
rawValue
]?
.
string
{
precondition
(
outputType
==
.
Executable
,
"Must use
\(
Options
.
OutputType
.
rawValue
)
'executable' when using
\(
Options
.
ExecutableName
.
rawValue
)
"
)
executableName
=
e
}
else
{
executableName
=
name
}
if
task
[
Options
.
Framework
.
rawValue
]?
.
bool
==
true
{
#if !os(OSX)
fatalError
(
"
\(
Options
.
Framework
.
rawValue
)
is not supported on this platform."
)
...
...
@@ -483,7 +493,7 @@ final class ATllbuild : Tool {
swiftCPath
=
findToolPath
(
toolName
:
"swiftc"
,
toolchain
:
toolchain
)
}
let
yaml
=
llbuildyaml
(
sources
:
sources
,
workdir
:
workDirectory
,
modulename
:
name
,
linkSDK
:
sdk
,
compileOptions
:
compileOptions
,
linkOptions
:
linkOptions
,
outputType
:
outputType
,
linkWithProduct
:
linkWithProduct
,
swiftCPath
:
swiftCPath
)
let
yaml
=
llbuildyaml
(
sources
:
sources
,
workdir
:
workDirectory
,
modulename
:
name
,
linkSDK
:
sdk
,
compileOptions
:
compileOptions
,
linkOptions
:
linkOptions
,
outputType
:
outputType
,
linkWithProduct
:
linkWithProduct
,
swiftCPath
:
swiftCPath
,
executableName
:
executableName
)
let
_
=
try
?
yaml
.
write
(
to
:
llbuildyamlpath
)
if
bootstrapOnly
{
return
}
...
...
@@ -511,7 +521,7 @@ final class ATllbuild : Tool {
try
FS
.
copyItem
(
from
:
workDirectory
+
"products/
\(
name
)
.swiftdoc"
,
to
:
Path
(
"bin/
\(
name
)
.swiftdoc"
))
switch
outputType
{
case
.
Executable
:
try
FS
.
copyItem
(
from
:
workDirectory
+
"products/
\(
name
)
"
,
to
:
Path
(
"bin/
\(
n
ame
)
"
))
try
FS
.
copyItem
(
from
:
workDirectory
+
"products/
\(
executableName
)
"
,
to
:
Path
(
"bin/
\(
executableN
ame
)
"
))
case
.
StaticLibrary
:
try
FS
.
copyItem
(
from
:
workDirectory
+
"products/
\(
name
)
.a"
,
to
:
Path
(
"bin/
\(
name
)
.a"
))
case
.
DynamicLibrary
:
...
...
tests/fixtures/executable_name/build.atpkg
0 → 100644
View file @
93850f4e
(package
:name "executable_name"
:tasks {
:default {
:tool "atllbuild"
:name "executable_name"
:executable-name "executable-name"
:sources ["src/**.swift"]
:publish-product true
:output-type "executable"
}
:check {
:tool "shell"
:script "bin/executable-name"
:dependencies ["default"]
}
}
)
\ No newline at end of file
tests/fixtures/executable_name/src/main.swift
0 → 100644
View file @
93850f4e
print
(
"Hello world"
)
\ No newline at end of file
tests/test.sh
View file @
93850f4e
...
...
@@ -16,6 +16,10 @@ if ! $ATBUILD atbuild --use-overlay static; then
$ATBUILD
atbuild
fi
echo
"****************EXECUTABLE-NAME TEST**************"
cd
$DIR
/tests/fixtures/executable_name
$ATBUILD
check
echo
"****************ATBIN TEST**************"
cd
$DIR
/tests/fixtures/atbin
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment