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
d724974a
Commit
d724974a
authored
May 11, 2016
by
Drew
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #97 from AnarchyTools/binpath
Add ATBUILD_BIN_PATH
parents
6c8802e0
5e877eb5
Pipeline
#1901
passed with stage
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
29 deletions
+47
-29
attools/src/CustomTool.swift
attools/src/CustomTool.swift
+2
-6
attools/src/Shell.swift
attools/src/Shell.swift
+33
-18
tests/fixtures/attool/build.atpkg
tests/fixtures/attool/build.atpkg
+1
-0
tests/fixtures/user_paths/b/build.atpkg
tests/fixtures/user_paths/b/build.atpkg
+1
-1
tests/fixtures/user_paths/build.atpkg
tests/fixtures/user_paths/build.atpkg
+3
-2
tests/test.sh
tests/test.sh
+7
-2
No files found.
attools/src/CustomTool.swift
View file @
d724974a
...
...
@@ -24,12 +24,8 @@ final class CustomTool: Tool {
}
cmd
+=
"--
\(
key
)
\"\(
evaluateSubstitutions
(
input
:
value
,
package
:
task
.
package
)
)\"
"
}
setenv
(
"ATBUILD_USER_PATH"
,
userPath
()
.
description
,
1
)
setenv
(
"ATBUILD_PLATFORM"
,
"
\(
Platform
.
targetPlatform
)
"
,
1
)
if
let
version
=
task
.
package
.
version
{
setenv
(
"ATBUILD_PACKAGE_VERSION"
,
version
,
1
)
Shell
.
environvironment
(
task
:
task
)
{
anarchySystem
(
cmd
)
}
anarchySystem
(
cmd
)
}
}
\ No newline at end of file
attools/src/Shell.swift
View file @
d724974a
...
...
@@ -27,31 +27,46 @@ import atpkg
* If the tool returns with an error code of non-zero, the tool will fail.
*/
final
class
Shell
:
Tool
{
func
run
(
task
:
Task
,
toolchain
:
String
)
{
///Sets the environment for the specified task.
static
func
environvironment
(
task
:
Task
,
block
:
()
->
())
{
setenv
(
"ATBUILD_PLATFORM"
,
"
\(
Platform
.
targetPlatform
)
"
,
1
)
setenv
(
"ATBUILD_USER_PATH"
,
userPath
()
.
description
,
1
)
if
let
version
=
task
.
package
.
version
{
setenv
(
"ATBUILD_PACKAGE_VERSION"
,
version
,
1
)
}
guard
var
script
=
task
[
"script"
]?
.
string
else
{
fatalError
(
"Invalid 'script' argument to shell tool."
)
}
script
=
evaluateSubstitutions
(
input
:
script
,
package
:
task
.
package
)
do
{
let
oldPath
=
try
FS
.
getWorkingDirectory
()
defer
{
do
{
try
FS
.
changeWorkingDirectory
(
path
:
oldPath
)
}
catch
{
print
(
"Can not revert to previous working directory '
\(
oldPath
)
':
\(
error
)
"
)
exit
(
42
)
}
}
try
FS
.
changeWorkingDirectory
(
path
:
task
.
importedPath
)
//does bin path not exist?
//let's create it!
let
binPath
=
try!
FS
.
getWorkingDirectory
()
.
appending
(
"bin"
)
if
!
FS
.
fileExists
(
path
:
binPath
)
{
try!
FS
.
createDirectory
(
path
:
binPath
)
}
setenv
(
"ATBUILD_BIN_PATH"
,
binPath
.
description
,
1
)
anarchySystem
(
"/bin/sh -c
\"\(
script
)\"
"
)
}
catch
{
print
(
"Can not change working directory to '
\(
task
.
importedPath
)
':
\(
error
)
"
)
exit
(
42
)
//deal with directory nonsense
let
oldPath
=
try!
FS
.
getWorkingDirectory
()
defer
{
do
{
try
FS
.
changeWorkingDirectory
(
path
:
oldPath
)
}
catch
{
print
(
"Can not revert to previous working directory '
\(
oldPath
)
':
\(
error
)
"
)
exit
(
42
)
}
}
do
{
try
FS
.
changeWorkingDirectory
(
path
:
task
.
importedPath
)
}
catch
{
print
(
"Cannot change working directory to
\(
task
.
importedPath
)
"
)
}
block
()
}
func
run
(
task
:
Task
,
toolchain
:
String
)
{
guard
var
script
=
task
[
"script"
]?
.
string
else
{
fatalError
(
"Invalid 'script' argument to shell tool."
)
}
script
=
evaluateSubstitutions
(
input
:
script
,
package
:
task
.
package
)
Shell
.
environvironment
(
task
:
task
)
{
anarchySystem
(
script
)
}
}
}
\ No newline at end of file
tests/fixtures/attool/build.atpkg
View file @
d724974a
...
...
@@ -25,6 +25,7 @@
:userpath "\${ATBUILD_USER_PATH}"
:platform "\${ATBUILD_PLATFORM}"
:version "\${ATBUILD_PACKAGE_VERSION}"
:bindir "\${ATBUILD_BIN_PATH}"
:dependencies ["a"]
}
}
...
...
tests/fixtures/user_paths/b/build.atpkg
View file @
d724974a
...
...
@@ -4,7 +4,7 @@
:tasks {
:second {
:tool "shell"
:script "echo SECOND >> $ATBUILD_USER_PATH/test"
:script "echo SECOND >> $ATBUILD_USER_PATH/test
&& echo SECOND >> $ATBUILD_BIN_PATH/test
"
}
}
)
\ No newline at end of file
tests/fixtures/user_paths/build.atpkg
View file @
d724974a
...
...
@@ -5,11 +5,12 @@
:tasks {
:first {
:tool "shell"
:script "echo FIRST >> $ATBUILD_USER_PATH/test"
;; note that binpath is not recreated, therefore we use single > here to force a new file
:script "echo FIRST >> $ATBUILD_USER_PATH/test && echo FIRST > $ATBUILD_BIN_PATH/test"
}
:third {
:tool "shell"
:script "echo THIRD >> $ATBUILD_USER_PATH/test"
:script "echo THIRD >> $ATBUILD_USER_PATH/test
&& echo THIRD >> $ATBUILD_BIN_PATH/test
"
:dependencies ["first" "b.second"]
}
:compiledep {
...
...
tests/test.sh
View file @
d724974a
...
...
@@ -196,9 +196,9 @@ echo "****************PLUGIN TEST**************"
cd
$DIR
/tests/fixtures/attool
$ATBUILD
>
/tmp/plugin.txt
if
[
"
$UNAME
"
==
"Darwin"
]
;
then
SEARCHTEXT
=
"
\-
key value --platform osx --test test_substitution --userpath .*tests/fixtures/attool/user --version 1.0"
SEARCHTEXT
=
"
\-
bindir .*tests/fixtures/attool/bin --
key value --platform osx --test test_substitution --userpath .*tests/fixtures/attool/user --version 1.0"
else
SEARCHTEXT
=
"
\-
key value --platform linux --test test_substitution --userpath .*tests/fixtures/attool/user --version 1.0"
SEARCHTEXT
=
"
\-
bindir .*tests/fixtures/attool/bin --
key value --platform linux --test test_substitution --userpath .*tests/fixtures/attool/user --version 1.0"
fi
if
!
grep
"
$SEARCHTEXT
"
/tmp/plugin.txt
;
then
...
...
@@ -369,6 +369,11 @@ if [ "$RESULT" != "$RESULT2" ]; then
echo
"Unusual user path concoction
$RESULT
$RESULT2
"
exit
1
fi
RESULT
=
`
cat
bin/test
`
if
[
"
$RESULT
"
!=
"
$RESULT2
"
]
;
then
echo
"Unusual bin path concoction
$RESULT
$RESULT2
"
exit
1
fi
$ATBUILD
compile
...
...
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