Repository navigation
Expand file tree
/
Copy pathbuild
More file actions
executable file
·117 lines (110 loc) · 2.99 KB
/
Copy pathbuild
File metadata and controls
executable file
·117 lines (110 loc) · 2.99 KB
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
#!/bin/sh
#
# SPDX-License-Identifier: CDDL-1.0
#
# Copyright 2025 Peter Tribble
#
# build kar
#
# Usage:
#
# ./build
# Builds all the java classes and creates the jar
#
# ./build collector
# Builds the native collector for this platform
#
# ./build pmd
# Runs the pmd static code analysis tool, if it's installed
#
# ./build javadoc
# Generates the javadoc
#
# ./build packages
# Creates SVR4 packages
#
PATH=/usr/jdk/instances/jdk11/bin:$PATH
export PATH
JKDIR=$(dirname "$0")
LIBDIR=${JKDIR}/lib
JARLIBDIR=${LIBDIR}/java
JKJAR=${JARLIBDIR}/jkstat.jar
KJAR=${JARLIBDIR}/kar.jar
BUILDJARS=${JKJAR}
#
# run
# ./build pmd
# to use this, you must have pmd in your path
#
# new PMD version 7 only has categories, configured in pmd-ruleset.xml
#
PMDRULES="./pmd-ruleset.xml"
PMDCACHE="${HOME}/.pmd/cache.kar"
case $1 in
collector)
ARCH=$(/usr/bin/uname -p)
mkdir -p bin/"${ARCH}"
gcc -m64 -o bin/"${ARCH}"/kar_collector -lkstat src/kar_collector.c
exit 0
;;
javadoc)
rm -fr javadoc
mkdir javadoc
javadoc -classpath "$BUILDJARS:." -Xdoclint:all -d javadoc uk.co.petertribble.kar
exit 0
;;
clean)
# shellcheck disable=SC2046
rm -f $(find uk/co -type f -name '*.class')
# shellcheck disable=SC2046
rm -f $(find . -type f -name '*~')
rm -fr javadoc
exit 0
;;
pmd)
if [ ! -d "${HOME}/.pmd" ]; then
mkdir -p "${HOME}/.pmd"
fi
# shellcheck disable=SC2046
pmd check --cache "${PMDCACHE}" -d uk -R "${PMDRULES}" --use-version java-11 --aux-classpath $(echo lib/java/* | sed 's= =:=g') 2>/dev/null
pmd check --cache "${PMDCACHE}.html" -d help/*.html -R category/html/bestpractices.xml 2>/dev/null
exit 0
;;
spotbugs)
#
# spotbugs works on the class files, so those need to be available
#
javac -Xlint -Xlint:-rawtypes -classpath ".:${BUILDJARS}" uk/co/petertribble/kar/*.java
javac -Xlint -classpath ".:${BUILDJARS}" uk/co/petertribble/kar/graphite/*.java
# shellcheck disable=SC2046
spotbugs -auxclasspath $(echo lib/java/* | sed 's= =:=g') uk
# shellcheck disable=SC2046
rm -f $(find uk/co/petertribble/kar -type f -name '*.class')
exit 0
;;
packages)
sed 's:^JARLIBDIR=.*$:JARLIBDIR=/usr/share/kar:' kar > kar.installed
# shellcheck disable=SC2086
./mkproto i386 $2 > prototype.i386
# shellcheck disable=SC2086
./mkproto sparc $2 > prototype.sparc
MYPWD=$(pwd)
pkgmk -d /tmp -f prototype.i386 -r "${MYPWD}" TRIBkar
pkgtrans -s /tmp /tmp/TRIBkar-i386.pkg TRIBkar
rm -fr /tmp/TRIBkar
pkgmk -d /tmp -f prototype.sparc -r "${MYPWD}" TRIBkar
pkgtrans -s /tmp /tmp/TRIBkar-sparc.pkg TRIBkar
rm -fr /tmp/TRIBkar
ls -l /tmp/TRIBkar-sparc.pkg /tmp/TRIBkar-i386.pkg
rm prototype.i386 prototype.sparc
rm kar.installed
rm -f depend
exit 0
;;
esac
javac -Xlint -Xlint:-rawtypes -classpath ".:${BUILDJARS}" uk/co/petertribble/kar/*.java
javac -Xlint -classpath ".:${BUILDJARS}" uk/co/petertribble/kar/graphite/*.java
# shellcheck disable=SC2046
jar -cf "${KJAR}" $(find uk/co/petertribble/kar -name '*.class') help/*
# shellcheck disable=SC2046
rm -f $(find uk/co/petertribble/kar -type f -name '*.class')