Skip to content

Commit

Permalink
create base line version (#1)
Browse files Browse the repository at this point in the history
* add docker file for pspdev and android ndk
* add github action for psp and android build
* fix build config for qt4 and startup crash
  • Loading branch information
zie87 authored Apr 30, 2021
1 parent e2a0fef commit 8b9be78
Show file tree
Hide file tree
Showing 21 changed files with 266 additions and 17 deletions.
40 changes: 40 additions & 0 deletions .docker/android/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# based on: https://github.com/RossMeikleham/PlutoBoy/blob/master/build/Android/Dockerfile
FROM --platform=linux/amd64 debian:stretch

USER root

ARG DEBIAN_FRONTEND=noninteractive

ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8

ENV ANDROID_HOME /opt/android-sdk-linux

RUN dpkg --add-architecture i386 && \
apt-get update && \
apt-get install -y --no-install-recommends apt-utils && \
apt-get install -y --no-install-recommends expect build-essential openssh-client curl make && \
apt-get install -y --no-install-recommends file unzip wget gnupg && \
apt-get install -y --no-install-recommends libncurses5:i386 libstdc++6:i386 zlib1g:i386 && \
apt-get install -y --no-install-recommends openjdk-8-jdk ant maven && \
apt-get clean && rm -rf /var/lib/apt/lists/*

# Install Android SDK installer
RUN curl -o android-sdk.zip "https://dl.google.com/android/repository/tools_r25.2.5-linux.zip" \
&& unzip -C android-sdk.zip -d "${ANDROID_HOME}" \
&& rm *.zip

COPY .docker/android/scripts/ /opt/sdk-tools

ENV PATH ${PATH}:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:/opt/sdk-tools

RUN sdkmanager --list \
&& /opt/sdk-tools/android-accept-licenses.sh "sdkmanager platform-tools" \
&& /opt/sdk-tools/android-accept-licenses.sh "sdkmanager build-tools;26.0.3" \
&& /opt/sdk-tools/android-accept-licenses.sh "sdkmanager sources;android-26" \
&& /opt/sdk-tools/android-accept-licenses.sh "sdkmanager platforms;android-26" \
&& sdkmanager --list

RUN curl -o ndk.zip https://dl.google.com/android/repository/android-ndk-r14b-linux-x86_64.zip
RUN unzip -q ndk.zip
ENV PATH /android-ndk-r14b:$PATH
14 changes: 14 additions & 0 deletions .docker/android/scripts/android-accept-licenses.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/expect -f

set timeout 1800
set cmd [lindex $argv 0]
set licenses [lindex $argv 1]

spawn {*}$cmd
expect {
"Accept?*" {
exp_send "y\r"
exp_continue
}
eof
}
26 changes: 26 additions & 0 deletions .docker/devkit/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM ubuntu:focal
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -y --no-install-recommends apt-utils && \
apt-get install -y --no-install-recommends sudo ca-certificates pkg-config curl wget bzip2 xz-utils make git tar doxygen gnupg && \
apt-get install -y --no-install-recommends gdebi-core && \
apt-get install -y --no-install-recommends cmake && \
apt-get clean && rm -rf /var/lib/apt/lists/*

RUN wget https://github.com/devkitPro/pacman/releases/latest/download/devkitpro-pacman.amd64.deb && \
dpkg -i devkitpro-pacman.amd64.deb && \
rm devkitpro-pacman.amd64.deb

ENV DEVKITPRO=/opt/devkitpro
ENV PATH=${DEVKITPRO}/tools/bin:$PATH

RUN dkp-pacman -Syyu --noconfirm gamecube-dev wii-dev wiiu-dev && \
dkp-pacman -S --needed --noconfirm `dkp-pacman -Slq dkp-libs | grep '^ppc-'` && \
dkp-pacman -Scc --noconfirm
ENV DEVKITPPC=${DEVKITPRO}/devkitPPC

RUN dkp-pacman -Syyu --noconfirm 3ds-dev nds-dev gba-dev nds-portlibs && \
dkp-pacman -S --needed --noconfirm `dkp-pacman -Slq dkp-libs | grep '^3ds-'` && \
dkp-pacman -Scc --noconfirm
ENV DEVKITARM=${DEVKITPRO}/devkitARM
26 changes: 26 additions & 0 deletions .docker/pspdev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM alpine:3.12

RUN apk add --no-cache \
autoconf automake bison bzip2 cmake doxygen diffutils flex \
gcc g++ git gzip libarchive-dev curl-dev libelf gpgme-dev \
libssl1.1 libtool libusb-compat-dev m4 make ncurses-dev patch pkgconf \
python3 readline-dev subversion tar tcl texinfo unzip wget xz openssh

ENV PSPDEV /opt/pspsdk
ENV PSPSDK $PSPDEV/pspsdk
ENV PATH $PATH:$PSPDEV/bin:$PSPSDK/bin

RUN git clone https://github.com/pspdev/psptoolchain.git /tmp/psptoolchain

# work around for musl paths
RUN echo "#include <unistd.h>" > /usr/include/sys/unistd.h

RUN cd /tmp/psptoolchain \
&& ./toolchain.sh \
&& cd .. && rm -Rf /tmp/psptoolchain

RUN git clone https://github.com/pspdev/psplibraries.git /tmp/psplibraries

RUN cd /tmp/psplibraries && ls -l scripts \
&& ./libraries.sh \
&& cd .. && rm -Rf psplibraries
11 changes: 11 additions & 0 deletions .github/tools/ndk/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

if [ $1 == "debug" ]; then
ndk-build -C projects/mtg/Android -B -j $(nproc) NDK_TOOLCHAIN_VERSION=4.9 NDK_DEBUG=1
else
ndk-build -C projects/mtg/Android -B -j $(nproc) NDK_TOOLCHAIN_VERSION=4.9 NDK_DEBUG=0
fi

android list targets
android update project -t 1 -p projects/mtg/Android
ant $1 -f projects/mtg/Android/build.xml
28 changes: 28 additions & 0 deletions .github/tools/psp/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

echo PSPDEV = $PSPDEV
echo psp-config = `psp-config --psp-prefix`

cd JGE
make -f Makefile.hge -j $(nproc)
cp libhgetools.a lib/psp/libhgetools.a
cd ..

cd JGE
if [ $1 == "debug" ]; then
make -f Makefile debug -j $(nproc)
else
make -f Makefile -j $(nproc)
fi
cd ..

cd projects/mtg
mkdir -p objs deps
if [ $1 == "debug" ]; then
make -f Makefile debug -j $(nproc)
else
make -f Makefile -j $(nproc)
fi
cd -


27 changes: 27 additions & 0 deletions .github/workflows/ndk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Android

on:
push:
branches-ignore:
- 'docker'
schedule:
- cron: '0 4 * * 0' # Weekly on Sundays at 04:00

jobs:
native_build:
runs-on: ubuntu-latest

strategy:
matrix:
config: [release, debug]

steps:
- name: checkout
uses: actions/checkout@v1
with:
submodules: true

- name: build
uses: docker://zie87/wth_woth_android:latest
with:
args: /bin/sh -c ".github/tools/ndk/build.sh" ${{ matrix.config }}
27 changes: 27 additions & 0 deletions .github/workflows/psp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: PSP

on:
push:
branches-ignore:
- 'docker'
schedule:
- cron: '0 4 * * 0' # Weekly on Sundays at 04:00

jobs:
native_build:
runs-on: ubuntu-latest

strategy:
matrix:
config: [release, debug]

steps:
- name: checkout
uses: actions/checkout@v1
with:
submodules: true

- name: build
uses: docker://zie87/wth_woth_pspdev:latest
with:
args: /bin/sh -c ".github/tools/psp/build.sh" ${{ matrix.config }}
2 changes: 1 addition & 1 deletion JGE/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ HGE_OBJS = src/hge/hgecolor.o src/hge/hgeparticle.o \
src/hge/hgedistort.o src/hge/hgefont.o


CXXFLAGS = -W -Wall -Werror -Wno-unused
CXXFLAGS = -std=gnu++03 -W -Wall -Wno-unused

ifdef DEBUG
CXXFLAGS += -ggdb3
Expand Down
Binary file removed JGE/lib/psp/libhgetools.a
Binary file not shown.
21 changes: 13 additions & 8 deletions JGE/src/qt/filedownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ FileDownloader::FileDownloader(QString localPath, QString targetFile, QObject *p
return;
}
dir.cd(localPath);
m_tmp.setFileTemplate(dir.filePath("tmp"));
m_localPath = dir.filePath("core.zip");

QFile local(m_localPath);
Expand All @@ -37,7 +38,7 @@ FileDownloader::FileDownloader(QString localPath, QString targetFile, QObject *p
if(m_WebCtrl.networkAccessible()) {
/* Network is OK, we request the remote hash file */
m_state = DOWNLOADING_HASH;
requestHash(QUrl("http://code.google.com/p/wagic/downloads/detail?name="+m_targetFile));
requestHash(QUrl("https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/wagic/"+m_targetFile));
}

emit stateChanged(m_state);
Expand Down Expand Up @@ -75,7 +76,7 @@ FileDownloader::~FileDownloader()
void FileDownloader::requestHash(QUrl url)
{
QNetworkRequest request(url);
m_hashReply = m_WebCtrl.get(request);
m_hashReply = m_WebCtrl.head(request);

connect(m_hashReply, SIGNAL(finished()), SLOT(computeRemoteHash()));
}
Expand All @@ -85,14 +86,18 @@ void FileDownloader::computeRemoteHash()
if(m_hashReply->error() != QNetworkReply::NoError) {
m_state = NETWORK_ERROR;
} else {
QString aString = m_hashReply->readAll();
foreach(QByteArray hash, m_hashReply->rawHeader("x-goog-hash").split(',')) {
hash = hash.trimmed();
if(hash.startsWith("md5=")) {
m_remoteHash = hash.mid(4);
break;
}
}

int index = aString.indexOf("SHA1 Checksum: ");
m_remoteHash = aString.mid(index+52, 40);
if(m_localHash != m_remoteHash)
{ /* We download the real file */
m_state = DOWNLOADING_FILE;
setDownloadUrl(QUrl("http://wagic.googlecode.com/files/" + m_targetFile));
setDownloadUrl(QUrl("https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/wagic/" + m_targetFile));
}
else
{
Expand All @@ -104,12 +109,12 @@ void FileDownloader::computeRemoteHash()

void FileDownloader::computeLocalHash(QFile& file)
{
QCryptographicHash crypto(QCryptographicHash::Sha1);
QCryptographicHash crypto(QCryptographicHash::Md5);
QFile myFile(file.fileName());
myFile.open(QFile::ReadOnly);
while(!myFile.atEnd()){
crypto.addData(myFile.read(8192));
}
QByteArray hash = crypto.result();
m_localHash = hash.toHex();
m_localHash = hash.toBase64();
}
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Wagic: War of the Homebrew

*War of the Homebrew* is an open source collectible trading card game. You play as a wizard against the CPU with your army of minions. You start the game with a small collection of cards (symbolizing creatures and spells), and as you win battles against the AI, you earn credits that allow you to buy more cards and build more powerful decks. As you play, you unlock cards and new game modes, so it is much more than a simple card simulation.

*WotH* features several thousands of cards (*currently over 9000 unique cards*) and is playable on multiple platforms.

![screenshot](./doc/screenshot_demo.png)

It is based on [Wagic the Homebrew] in version 0.18.6 ([released](https://wololo.net/download/) in 2012). *War of the Homebrew* should be compatible with all mods create for this particular *Wagic* version.

[Wagic the Homebrew]: https://github.com/WagicProject/wagic

## Documentation

* [Building](./doc/build.md)
29 changes: 29 additions & 0 deletions doc/build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Building

## PSP
[docker image](https://hub.docker.com/repository/docker/zie87/wth_woth_pspdev)

```.sh
docker pull zie87/wth_woth_pspdev:latest
docker run --rm -u $UID --init -v $PWD:/opt/workspace -e LANG=$LANG -w /opt/workspace -it zie87/wth_woth_pspdev /bin/sh "./.github/tools/psp/build.sh" debug
```

## Linux (Qt4)

```.sh
# Arch Linux
sudo pacman -S cmake gcc boost libpng12
paru -S giflib4 qt4 phonon-qt4-gstreamer

mkdir build_qt && cd build_qt
qmake-qt4 ../projects/mtg/wagic-qt.pro CONFIG+=debug
make -j 4(nproc)
```

## Android
[docker image](https://hub.docker.com/repository/docker/zie87/wth_woth_android)

```.sh
docker pull zie87/wth_woth_android:latest
docker run --rm --init -v $PWD:/opt/workspace -e LANG=$LANG -w /opt/workspace -it zie87/wth_woth_android /bin/sh "./.github/tools/ndk/build.sh" debug
```
Binary file added doc/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/screenshot_demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion projects/mtg/Android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@

<activity android:configChanges="keyboard|keyboardHidden" android:name="com.google.ads.AdActivity" android:screenOrientation="sensorLandscape"/>
</application>
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="9"/>
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="12"/>
</manifest>
4 changes: 2 additions & 2 deletions projects/mtg/Android/ant.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
# 'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 'release' target.

key.store=wagic-mnguyen-release-key.keystore
#key.store=wagic-mnguyen-release-key.keystore
#key.store=wagic-mnguyen-beta-key.keystore
key.alias=wagic_release
#key.alias=wagic_release
2 changes: 1 addition & 1 deletion projects/mtg/Android/default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
# project structure.

# Project target.
target=android-9
target=android-21
2 changes: 1 addition & 1 deletion projects/mtg/Android/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-9
target=android-26
4 changes: 2 additions & 2 deletions projects/mtg/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ all: $(DEFAULT_RULE)

endif

CFLAGS := -Wall -W -Werror -Wno-unused $(CFLAGS)
CXXFLAGS += $(CFLAGS)
CFLAGS := -Wall -W -Wno-unused $(CFLAGS)
CXXFLAGS += -std=gnu++03 $(CFLAGS)
# -fno-exceptions

LDFLAGS += $(LIBS)
Expand Down
3 changes: 2 additions & 1 deletion projects/mtg/wagic-qt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ maemo5:QT += dbus
TARGET = wagic
TEMPLATE = app

QMAKE_CXXFLAGS += -std=c++03

#!macx:CONFIG += precompile_header
unix|macx:QMAKE_CXXFLAGS += -Wno-unused-parameter
unix|macx:!maemo5:!symbian:QMAKE_CXXFLAGS += -Werror
windows:DEFINES += WIN32
windows:DEFINES += _CRT_SECURE_NO_WARNINGS
unix|macx:DEFINES += LINUX
Expand Down

0 comments on commit 8b9be78

Please sign in to comment.