summaryrefslogtreecommitdiffstats
path: root/maven/make-copy-jars.sh
blob: 6ad63abab9157ba89bd7a7413cdd59a3a0f9ddc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/sh

info()
{
  echo "make-copy-jars: info: $1" 1>&2
}

copy()
{
  SOURCE="$1"
  TARGET="$2"

  info "copy $1 $2.tmp" 1>&2
  cp -n "$1" "$2.tmp" || exit 1
  info "rename $2.tmp $2" 1>&2
  mv "$2.tmp" "$2" || exit 1
}

if [ $# -ne 1 ]
then
  info "usage: version"
  exit 1
fi

VERSION="$1"
shift

INPUT="input/jogamp-all-platforms"

if [ ! -d "${INPUT}" ]
then
  echo "make-copy-jars: error: ${INPUT} is not an existing directory" 1>&2
  echo "make-copy-jars: error: unpack jogamp-all-platforms.7z into 'input'" 1>&2
  exit 1
fi

PROJECTS=`./make-list-projects.sh` || exit 1
PLATFORMS=`cat make-platforms.txt | awk '{print $1}'` || exit 1

IFS="
"

for PROJECT_LINE in ${PROJECTS}
do
  # Determine project name
  NAME=`echo "${PROJECT_LINE}" | awk -F: '{print $1}'` || exit 1
  NAME=`echo "${NAME}"         | tr -d ' '`            || exit 1

  # Determine whether or not the project has native jars
  NATIVES=`echo "${PROJECT_LINE}" | awk -F: '{print $2}'` || exit 1
  NATIVES=`echo "${NATIVES}"      | tr -d ' '`            || exit 1

  # Determine whether or not the project uses an empty "dummy" jar
  DUMMY=`echo "${PROJECT_LINE}" | awk -F: '{print $3}'` || exit 1
  DUMMY=`echo "${DUMMY}"        | tr -d ' '`            || exit 1

  # Determine the source zip file, may be dummy-src
  SRC_ZIP=`echo "${PROJECT_LINE}" | awk -F: '{print $4}'` || exit 1
  SRC_ZIP=`echo "${SRC_ZIP}"      | tr -d ' '`            || exit 1

  # Determine whether or not the project has atomic jars
  ATOMICS=`echo "${PROJECT_LINE}" | awk -F: '{print $5}'` || exit 1

  # Keep a list of all files copied, for deployment later
  MANIFEST_FILE="output/${NAME}/${VERSION}/manifest.txt"

  # Copy all native jars, if necessary
  if [ "${NATIVES}" = "natives" ]
  then
    for PLATFORM in ${PLATFORMS}
    do
      OUTPUT_NAME="${NAME}-${VERSION}-natives-${PLATFORM}.jar"
      SOURCE="${INPUT}/jar/${NAME}-natives-${PLATFORM}.jar"
      TARGET="output/${NAME}/${VERSION}/${OUTPUT_NAME}"
      copy "${SOURCE}" "${TARGET}"
      echo "${OUTPUT_NAME}" >> "${MANIFEST_FILE}"
    done
  else
    if [ "${NATIVES}" = "atomic-natives" ]
    then
      for PLATFORM in ${PLATFORMS}
      do
        OUTPUT_NAME="${NAME}-${VERSION}-natives-${PLATFORM}.jar"
        SOURCE="${INPUT}/jar/atomic/${NAME}-natives-${PLATFORM}.jar"
        TARGET="output/${NAME}/${VERSION}/${OUTPUT_NAME}"
        copy "${SOURCE}" "${TARGET}"
        echo "${OUTPUT_NAME}" >> "${MANIFEST_FILE}"
      done
    fi
  fi

  # Copy dummy jar, if necessary
  if [ "${DUMMY}" = "dummy-jar" ]
  then
    OUTPUT_NAME="${NAME}.jar"
    SOURCE="empty.jar"
  else
    # Copy main jar
    OUTPUT_NAME="${NAME}.jar"
    SOURCE="${INPUT}/jar/${OUTPUT_NAME}"
  fi
  TARGET="output/${NAME}/${VERSION}/${OUTPUT_NAME}"
  copy "${SOURCE}" "${TARGET}"
  echo "${OUTPUT_NAME}" >> "${MANIFEST_FILE}"

  # Copy dummy jars, if necessary
  if [ "${SRC_ZIP}" = "dummy-src" ]
  then
    OUTPUT_NAME="${NAME}-${VERSION}-sources.jar"
    SOURCE="empty.jar"
  else
    SOURCE="${INPUT}/${SRC_ZIP}"
  fi
  TARGET="output/${NAME}/${VERSION}/${OUTPUT_NAME}"
  copy "${SOURCE}" "${TARGET}"
  echo "${OUTPUT_NAME}" >> "${MANIFEST_FILE}"

  # Copy dummy jars to 'javadoc' jars, as we
  # don't publish real versions of these yet.
  OUTPUT_NAME="${NAME}-${VERSION}-javadoc.jar"
  SOURCE="empty.jar"
  TARGET="output/${NAME}/${VERSION}/${OUTPUT_NAME}"
  copy "${SOURCE}" "${TARGET}"
  echo "${OUTPUT_NAME}" >> "${MANIFEST_FILE}"

  # Copy atomics, if necessary
  if [ ! -z "${ATOMICS}" ]
  then
    info "atomics: ${ATOMICS}"
    IFS=" "
    for ATOMIC in ${ATOMICS}
    do
      JAR_NAME="${NAME}-${VERSION}-${ATOMIC}.jar"
      SOURCE="${INPUT}/jar/atomic/${NAME}-${ATOMIC}.jar"
      TARGET="output/${NAME}/${VERSION}/${JAR_NAME}"
      copy "${SOURCE}" "${TARGET}"
      echo "${JAR_NAME}" >> "${MANIFEST_FILE}"
    done
    IFS="
"
  fi
done