Skip to content

Commit b57fb60

Browse files
committed
Update the import script
1 parent f1162dd commit b57fb60

File tree

2 files changed

+11
-88
lines changed

2 files changed

+11
-88
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ and [llbuild](https://github.com/apple/swift-llbuild).
77
Development
88
-------------
99

10-
All changes to source files in this repository need to be done in the repository of the Swift Package Manager repository ([link](https://github.com/apple/swift-package-manager)) and then copied here using the Script in `Utilities/import` which takes the local path to the SwiftPM directory as input (or uses `../swiftpm` as default).
11-
All targets with a TSC prefix in [SwiftPM](https://github.com/apple/swift-package-manager) are part of the swift-tools-support-core and will be imported by the import script. The plan is to eventually move ownership to this repository.
10+
All changes to source files in this repository need to be done in the repository of the Swift Package Manager repository ([link](https://github.com/apple/swift-package-manager)) and then copied here using the Script in `Utilities/import` which looks for SwiftPM next to its own checkout (`../swiftpm`).
11+
All files under the TSC directory in [SwiftPM](https://github.com/apple/swift-package-manager) are part of the swift-tools-support-core and will be imported by the import script. The plan is to eventually move ownership to this repository.
1212

1313
License
1414
-------

Utilities/import

Lines changed: 9 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
2+
3+
set -eu
24

35
# This source file is part of the Swift.org open source project
46
#
@@ -7,92 +9,13 @@
79
#
810
# See http://swift.org/LICENSE.txt for license information
911
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
10-
#
11-
# -------------------------------------------------------------------------
12-
# This script is used to bootstrap the tools-support-core package from its
13-
# sources in the Swift Package Manager repository.
14-
#
15-
# It does so by copying the sources of its targets from the directory that gets
16-
# specified as the directory that contains the Swift package manager.
17-
#
18-
# See below for a list of all directories that get copied.
19-
20-
EXEC_PATH=$0
21-
EXEC_DIR_NAME=`dirname $EXEC_PATH`
22-
TSC_PACKAGE_DIR=$EXEC_DIR_NAME/..
23-
24-
TSC_TARGETS=(
25-
TSCclibc
26-
TSCBasic
27-
TSCLibc
28-
TSCTestSupport
29-
TSCTestSupportExecutable
30-
TSCUtility
31-
)
32-
33-
TSC_TEST_TARGETS=(
34-
TSCBasicPerformanceTests
35-
TSCBasicTests
36-
TSCTestSupportTests
37-
TSCUtilityTests
38-
)
39-
40-
function copySources {
41-
local DIR=$1
42-
shift
43-
local SUB_DIR=$1
44-
shift
45-
local TARGETS=("$@")
46-
47-
# create the sub directory - don't mind if it exists already
48-
mkdir $SUB_DIR &> /dev/null
49-
50-
ALL_EXIST=1
51-
for TARGET in "${TARGETS[@]}"
52-
do
53-
SRC_DIR_PATH=$DIR/$SUB_DIR/$TARGET
54-
if [ ! -d $SRC_DIR_PATH ]; then
55-
echo "$SRC_DIR_PATH does not exist"
56-
ALL_EXIST=0
57-
fi
58-
done
59-
60-
if [ $ALL_EXIST -ne 1 ]; then
61-
echo "Aborting."
62-
exit -1
63-
fi
64-
65-
ALL_COPIED=1
66-
for TARGET in "${TARGETS[@]}"
67-
do
68-
SRC_DIR_PATH=$DIR/$SUB_DIR/$TARGET
69-
DST_DIR_PATH=$TSC_PACKAGE_DIR/$SUB_DIR/$TARGET
70-
rm -rf $DST_DIR_PATH
71-
cp -r $SRC_DIR_PATH $DST_DIR_PATH
72-
if [ $? -ne 0 ]; then
73-
echo "Couldn't copy $SRC_DIR_PATH to $DST_DIR_PATH."
74-
ALL_COPIED=0
75-
fi
76-
done
7712

78-
if [ $ALL_COPIED -ne 1 ]; then
79-
echo "Aborting."
80-
exit -1
81-
fi
82-
}
13+
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8314

84-
SWIFTPM_DIR="${1:-../swiftpm}"
15+
SRCROOT="`cd "${__dir}/..";pwd`"
16+
echo "SRCROOT is $SRCROOT"
8517

86-
echo "Copying ${TSC_TARGETS[@]} from $SWIFTPM_DIR to $TSC_PACKAGE_DIR"
87-
copySources $SWIFTPM_DIR "Sources" "${TSC_TARGETS[@]}"
88-
echo "Done!"
89-
echo "Copying ${TSC_TEST_TARGETS[@]} from $SWIFTPM_DIR to $TSC_PACKAGE_DIR"
90-
copySources $SWIFTPM_DIR "Tests" "${TSC_TEST_TARGETS[@]}"
91-
echo "Done!"
18+
IMPORT_DIR="`cd "${SRCROOT}/../swiftpm/TSC";pwd`"
9219

93-
if [ -x "$(command -v swift)" ]; then
94-
echo "Found 'swift' at `which swift`. Generating Linux main for unit tests."
95-
swift test --generate-linuxmain
96-
else
97-
echo "Didn't find 'swift' and will skip generating linux main for unit tests."
98-
fi
20+
echo Copying from $IMPORT_DIR
21+
cp -r ${IMPORT_DIR}/* $SRCROOT

0 commit comments

Comments
 (0)