Skip to content

Commit

Permalink
Utility scripts for scala-ide
Browse files Browse the repository at this point in the history
  • Loading branch information
Luc Bourlier committed Jul 17, 2014
1 parent b1110ec commit a351610
Show file tree
Hide file tree
Showing 3 changed files with 170 additions and 0 deletions.
24 changes: 24 additions & 0 deletions scala-ide/extractScalaIDEUsageFromClasses.sh
@@ -0,0 +1,24 @@
#!/bin/bash -xe
#####
#
#####
# $1 result file
# $2 partern to exclude. '/' chars have to be escaped: '\/'
#####

RESULT_FILE="$1"
EXCL_PATTERN="$2"

# clear the file
echo -n "" > ${RESULT_FILE}

for CLASSFILE in $(find . -name '*.class')
do
# for each .class file in the hierarchy
CLASSNAME=${CLASSFILE#*classes/}
CLASSNAME=${CLASSNAME%.class}
CLASSNAME=${CLASSNAME//\//.}

# extract binary references
javap -v ${CLASSFILE} | grep '= \(Methodref\|Class\)' | awk "/org\/scalaide\// && !/${EXCL_PATTERN}/ {print \$6\" ${CLASSNAME}\"}" >> ${RESULT_FILE}
done
77 changes: 77 additions & 0 deletions scala-ide/findInternalUsages.txt
@@ -0,0 +1,77 @@

--- for one project
find . -name '*.scala' | xargs grep 'scalaide.*\.internal' | awk -F ': *import ' '{imp[$2] = imp[$2]$1"\n"} END {for (i in imp) {print ">>>> "i" :\n"imp[i];}}'


--- per project
find . -name '*.scala' | xargs grep 'scalaide.*\.internal' | awk -F ': *import ' 'BEGIN {RS="(\r\n|\n)"} {print $2" "substr($1, 3)}'

--- grouped list, but not correctly ordered
sort play.internal scalatest.internal search.internal worksheet.internal | awk '{imp[$1] = imp[$1]" "$2"\n"} END {for (i in imp) {print ">>>> "i" :\n"imp[i];}}'

--- grouped list, with the right order
cat play.internal scalatest.internal search.internal worksheet.internal | awk '\
{
imp[$1] = imp[$1]" "$2"\n"
}

END {
k = 1
for (i in imp) {
keys[k++] = i
}

isort(keys, k)

for (i = 1; i <= k ; i++) {
print ">>>> "keys[i]" :\n"imp[keys[i]]
}
}

#insertion sort of A[1..n]
function isort( A, n, i, j, hold)
{
for( i = 2 ; i <= n ; i++)
{
hold = A[j = i]
while ( A[j-1] > hold )
{ j-- ; A[j+1] = A[j] }
A[j] = hold
}
# sentinel A[0] = "" will be created if needed
}
'

--- grouped list, with the right order, as csv
cat play.internal scalatest.internal search.internal worksheet.internal | awk '\
{
imp[$1] = imp[$1]" , "$2"\n"
}

END {
k = 1
for (i in imp) {
keys[k++] = i
}

isort(keys, k)

for (i = 1; i <= k ; i++) {
print ">>>> "keys[i]" \n"imp[keys[i]]
}
}

#insertion sort of A[1..n]
function isort( A, n, i, j, hold)
{
for( i = 2 ; i <= n ; i++)
{
hold = A[j = i]
while ( A[j-1] > hold )
{ j-- ; A[j+1] = A[j] }
A[j] = hold
}
# sentinel A[0] = "" will be created if needed
}
'

69 changes: 69 additions & 0 deletions scala-ide/generateZips.sh
@@ -0,0 +1,69 @@
#!/bin/bash -xe

WITH_VERSION_IN_NAME=false
case $1 in
--with-version-in-name )
WITH_VERSION_IN_NAME=true
shift
;;
esac

VERSION=$1
DEST_FOLDER=$2

function genLibrary () {
cd scala-library
cat > library.properties << EOF
# To test library with a 2.10.x version number
version.number=${VERSION}
copyright.string=Copyright 2002-2011, LAMP/EPFL
EOF

local JAR_NANE=""
if $WITH_VERSION_IN_NAME
then
JAR_NAME="scala-library_${VERSION}.jar"
else
JAR_NAME="scala-library.jar"
fi

zip -r ${JAR_NAME} library.properties META-INF/ scala/

cp ${JAR_NAME} ${DEST_FOLDER}

cd ..
}

function gen () {
ID=$1

mkdir -p scala-${ID}
cd scala-${ID}
cat > ${ID}.properties << EOF
version.number=${VERSION}
EOF

local JAR_NANE=""
if $WITH_VERSION_IN_NAME
then
JAR_NAME="scala-${ID}_${VERSION}.jar"
else
JAR_NAME="scala-${ID}.jar"
fi

zip ${JAR_NAME} ${ID}.properties

cp ${JAR_NAME} ${DEST_FOLDER}

cd ..
}

mkdir -p ${DEST_FOLDER}

genLibrary
gen compiler
gen reflect
gen swing
gen actor

0 comments on commit a351610

Please sign in to comment.