11#! /bin/sh
2- # ./copy_libs.sh <base_dir> <artifact version, like 2.8.3-macos>
2+ # ./copy_libs.sh <base_dir> <artifact version, like 2.8.3-macos> [no-clean]
33
44set -e
55
@@ -11,20 +11,65 @@ OWN_DIR=$(dirname "$0")
1111cd " $BASEDIR " || exit 1
1212
1313version=$( echo " $2 " | cut -d ' -' -f 1)
14- rm -fr target/classes/libs
14+ major_version=$( echo " $version " | cut -d ' .' -f 1)
15+ minor_version=$( echo " $version " | cut -d ' .' -f 2)
16+ if [ -z " $3 " ]; then
17+ rm -fr target/classes/libs
18+ fi
1519mkdir -p target/classes/libs
16- cp " $AP_RELEASE /build/libasyncProfiler.so" \
17- " target/classes/libs/libasyncProfiler-$VERSION_PLATFORM .so"
18- cp " $AP_RELEASE /build/jattach" \
19- " target/classes/libs/jattach-$VERSION_PLATFORM "
2020
21- python3 " $OWN_DIR /timestamp.py" > " target/classes/libs/ap-timestamp-$version "
22- echo " $version " > target/classes/libs/ap-version
21+ # if version is smaller than 2.10:
22+ if ([ " $major_version " -le 2 ] && [ " $minor_version " -lt 10 ]); then
23+ echo " Copy $AP_RELEASE /build/libasyncProfiler.so"
24+ cp " $AP_RELEASE /build/libasyncProfiler.so" \
25+ " target/classes/libs/libasyncProfiler-$VERSION_PLATFORM .so"
26+ cp " $AP_RELEASE /build/jattach" \
27+ " target/classes/libs/jattach-$VERSION_PLATFORM "
2328
24- echo " Copy $AP_RELEASE /profiler.sh"
25- cp " $AP_RELEASE /profiler.sh" " target/classes/libs/profiler-$version .sh"
26- python3 " $OWN_DIR /profile_processor.py" " target/classes/libs/profiler-$version .sh"
29+ cp " $AP_RELEASE /build/libasyncProfiler.so" \
30+ " target/classes/libs/libasyncProfiler-$VERSION_PLATFORM .so"
2731
28- echo " Copy Java sources"
29- python3 " $OWN_DIR /copy_java_sources.py" " $BASEDIR " " $VERSION_PLATFORM "
32+ echo " libasyncProfiler-$VERSION_PLATFORM .so" > target/classes/libs/ap-profile-lib-$VERSION_PLATFORM
3033
34+ cp " $AP_RELEASE /build/jattach" \
35+ " target/classes/libs/jattach-$VERSION_PLATFORM "
36+
37+ python3 " $OWN_DIR /timestamp.py" > " target/classes/libs/ap-timestamp-$version "
38+ echo " $version " > target/classes/libs/ap-version
39+
40+ echo " Copy $AP_RELEASE /profiler.sh"
41+ cp " $AP_RELEASE /profiler.sh" " target/classes/libs/profiler-$version .sh"
42+ python3 " $OWN_DIR /profile_processor.py" " target/classes/libs/profiler-$version .sh"
43+
44+ echo " profiler-$version .sh" > target/classes/libs/ap-profile-script-$VERSION_PLATFORM
45+
46+ echo " Copy Java sources"
47+ python3 " $OWN_DIR /copy_java_sources.py" " $BASEDIR " " $VERSION_PLATFORM "
48+
49+ else
50+ # test endings ".so" and ".dylib" in a loop
51+ for ending in " so" " dylib" ; do
52+ # if the file exists, copy it
53+ if [ -f " $AP_RELEASE /lib/libasyncProfiler.$ending " ]; then
54+ echo " Copy $AP_RELEASE /lib/libasyncProfiler.$ending "
55+ cp " $AP_RELEASE /lib/libasyncProfiler.$ending " \
56+ " target/classes/libs/libasyncProfiler-$VERSION_PLATFORM .$ending "
57+ echo " libasyncProfiler-$VERSION_PLATFORM .$ending " > target/classes/libs/ap-profile-lib-$VERSION_PLATFORM
58+ fi
59+ done
60+
61+ cp " $AP_RELEASE /build/jattach" \
62+ " target/classes/libs/jattach-$VERSION_PLATFORM "
63+
64+ python3 " $OWN_DIR /timestamp.py" > " target/classes/libs/ap-timestamp-$version "
65+ echo " $version " > target/classes/libs/ap-version
66+
67+ echo " Copy $AP_RELEASE /bin/asprof"
68+ cp " $AP_RELEASE /bin/asprof" " target/classes/libs/asprof-$VERSION_PLATFORM "
69+
70+ echo " asprof-$VERSION_PLATFORM " > target/classes/libs/ap-profile-script-$VERSION_PLATFORM
71+
72+ echo " Copy Java sources"
73+ python3 " $OWN_DIR /copy_java_sources.py" " $BASEDIR " " $VERSION_PLATFORM "
74+
75+ fi
0 commit comments