7 readonly EXIT_CODE_SUCCESS=0
10 # This script should be located in coreclr/tests.
13 function print_usage {
15 echo 'Download coredistools for GC stress testing'
19 echo './setup-gcstress.sh --outputDir=<coredistools_lib_install_path>'
21 echo 'Required arguments:'
22 echo ' --outputDir=<path> : Directory to install libcoredistools.so'
26 function exit_with_error {
30 if [ ! -z "$2" ]; then
37 function handle_ctrl_c {
38 exit_with_error 1 'Aborted by Ctrl+C'
41 # Register the Ctrl-C handler
42 trap handle_ctrl_c INT
53 exit $EXIT_CODE_SUCCESS
62 echo "Unknown switch: $i"
64 exit $EXIT_CODE_SUCCESS
69 if [ -z "$libInstallDir" ]; then
70 echo "--libInstallDir is required."
75 # This script must be located in coreclr/tests.
76 scriptDir=$(cd "$(dirname "$0")"; pwd -P)
78 echo "Running init-tools.sh"
79 $scriptDir/../init-tools.sh
81 dotnetToolsDir=$scriptDir/../Tools
82 dotnetCmd=${dotnetToolsDir}/dotnetcli/dotnet
83 packageDir=${scriptDir}/../packages
84 csprojPath=${scriptDir}/src/Common/stress_dependencies/stress_dependencies.csproj
86 # Check tool directory
87 if [ ! -e $dotnetToolsDir ]; then
88 exit_with_error 1 'Directory containing dotnet commandline does not exist:'$dotnetToolsDir
90 if [ ! -e $dotnetCmd ]; then
91 exit_with_error 1 'dotnet commandline does not exist:'$dotnetCmd
94 # make package directory
95 if [ ! -e $packageDir ]; then
99 # make output directory
100 if [ ! -e $libInstallDir ]; then
101 mkdir -p $libInstallDir
105 rid=`$dotnetCmd --info | grep 'RID:' | sed 's/^ *RID: *//g'`
106 if [ -z "$rid" ]; then
107 exit_with_error 1 "Failed to query runtime Id"
110 # Download the package
111 echo Downloading CoreDisTools package
112 bash -c -x "$dotnetCmd restore $csprojPath --source https://dotnet.myget.org/F/dotnet-core/ --packages $packageDir"
115 exit_with_error 1 "Failed to restore the package"
119 libPath=`find $packageDir | grep $rid | grep -m 1 libcoredistools`
120 if [ ! -e $libPath ]; then
121 exit_with_error 1 'Failed to locate the downloaded library'
124 # Copy library to output directory
125 echo 'Copy library:' $libPath '-->' $libInstallDir/
126 cp -f $libPath $libInstallDir
129 exit_with_error 1 "Failed to copy the library"
133 exit $EXIT_CODE_SUCCESS