|
1 | | -#!/bin/sh |
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -eu |
2 | 4 |
|
3 | 5 | # This source file is part of the Swift.org open source project |
4 | 6 | # |
|
7 | 9 | # |
8 | 10 | # See http://swift.org/LICENSE.txt for license information |
9 | 11 | # 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 |
77 | 12 |
|
78 | | - if [ $ALL_COPIED -ne 1 ]; then |
79 | | - echo "Aborting." |
80 | | - exit -1 |
81 | | - fi |
82 | | -} |
| 13 | +__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
83 | 14 |
|
84 | | -SWIFTPM_DIR="${1:-../swiftpm}" |
| 15 | +SRCROOT="`cd "${__dir}/..";pwd`" |
| 16 | +echo "SRCROOT is $SRCROOT" |
85 | 17 |
|
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`" |
92 | 19 |
|
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