Skip to content

Commit

Permalink
Merge pull request #50 from mahomaps/ci
Browse files Browse the repository at this point in the history
CI
  • Loading branch information
Feodor0090 committed May 28, 2023
2 parents a6f7717 + c09a54f commit 83e5748
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI
on:
push:
paths-ignore:
- '**.md'
jobs:
build:
runs-on: ubuntu-20.04
name: Build
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Setup
run: sudo dpkg --add-architecture i386 && sudo apt update && sudo apt-get install gcc-multilib libxt6:i386
- name: Build
run: cd ${{ github.workspace }} && chmod +x ./build.sh && ./build.sh
- name: Upload jar
uses: actions/upload-artifact@v2
with:
name: base.zip
path: ${{ github.workspace }}/mm_v1.jar
- name: Upload obf jar
uses: actions/upload-artifact@v2
with:
name: obf.zip
path: ${{ github.workspace }}/mm_v1_obf.jar
- name: Upload obf mappings
uses: actions/upload-artifact@v2
with:
name: mappings.zip
path: ${{ github.workspace }}/mm_v1_obf_map.txt
110 changes: 110 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/bin/bash

# Define RELEASE=1 before running to build a release.

# Compiler

echo "Downloading and updating compiler..."
if git clone https://github.com/Feodor0090/j2me_compiler.git 2>/dev/null
then
echo "Done."
else
echo "Already downloaded."
fi
cd j2me_compiler
git pull
cd ..

# Manifest

cp Application\ Descriptor manifest.mf
echo -en "Commit: " >> manifest.mf
git rev-parse --short HEAD >> manifest.mf

WORK_DIR=`dirname $0`
cd ${WORK_DIR}


mkdir -p jar

APP=mm_v1

# STATIC VARS
JAVA_HOME=./j2me_compiler/jdk1.6.0_45
WTK_HOME=./j2me_compiler/WTK2.5.2
PROGUARD=./j2me_compiler/proguard/bin/proguard.sh
RES=res
MANIFEST=manifest.mf
PATHSEP=":"
JAVAC=javac
JAR=jar

# DYNAMIC VARS
LIB_DIR=${WTK_HOME}/lib
CLDCAPI=${LIB_DIR}/cldcapi11.jar
MIDPAPI=${LIB_DIR}/midpapi20.jar
PREVERIFY=${WTK_HOME}/bin/preverify
TCP=${LIB_DIR}/*
CLASSPATH=`echo $TCP | sed "s/ /:/g"`

if [ -n "${JAVA_HOME}" ] ; then
JAVAC=${JAVA_HOME}/bin/javac
JAR=${JAVA_HOME}/bin/jar
fi

# ACTION
echo "Working on" ${APP}
pwd
echo "Creating or cleaning directories..."
mkdir -p ./tmpclasses
mkdir -p ./classes
rm -rf ./tmpclasses/*
rm -rf ./classes/*

echo "Compiling source files..."
${JAVAC} \
-bootclasspath ${CLDCAPI}${PATHSEP}${MIDPAPI} \
-source 1.3 \
-target 1.3 \
-d ./tmpclasses \
-classpath ./tmpclasses${PATHSEP}${CLASSPATH} \
`find ./src -name '*'.java`
if [ $? -eq 0 ]
then
echo "Compilation ok!"
else
exit 1
fi
echo "Preverifying class files..."
${PREVERIFY} \
-classpath ${CLDCAPI}${PATHSEP}${MIDPAPI}${PATHSEP}${CLASSPATH}${PATHSEP}./tmpclasses \
-d ./classes \
./tmpclasses
if [ $? -eq 0 ]
then
echo "Preverify ok!"
else
exit 1
fi

echo "Jaring preverified class files..."
${JAR} cmf ${MANIFEST} ${APP}.jar -C ./classes .

if [ -d ${RES} ] ; then
${JAR} uf ${APP}.jar -C ${RES} .
fi

echo "Build done!" ./${APP}.jar

echo Optimizing ${APP}
chmod +x ${PROGUARD}
touch cf.cfg

cat proguard.basecfg > cf.cfg
echo "-injars ./${APP}.jar" >> cf.cfg
echo "-outjar ./${APP}_obf.jar" >> cf.cfg
echo "-printseeds ./${APP}_obf_seeds.txt" >> cf.cfg
echo "-printmapping ./${APP}_obf_map.txt" >> cf.cfg
echo "-libraryjars ${CLASSPATH}" >> cf.cfg

${PROGUARD} @cf.cfg
30 changes: 30 additions & 0 deletions proguard.basecfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-dontusemixedcaseclassnames
-dontnote
-dontwarn
-defaultpackage ''
-microedition
-optimizations !library/*,!code/simplification/object
-overloadaggressively
-allowaccessmodification
-optimizationpasses 4

-keepclassmembers,includecode,allowobfuscation class mahomaps.map.GeoUpdateThread$LocationAPI {
<methods>;
}

-assumenosideeffects public class java.lang.StringBuffer {
public java.lang.String toString();
public char charAt(int);
public int capacity();
public int codePointAt(int);
public int codePointBefore(int);
public int indexOf(java.lang.String,int);
public int lastIndexOf(java.lang.String);
public int lastIndexOf(java.lang.String,int);
public int length();
public java.lang.String substring(int);
public java.lang.String substring(int,int);
}

-keep public class * extends javax.microedition.midlet.MIDlet

0 comments on commit 83e5748

Please sign in to comment.