Skip to content

Commit

Permalink
Merge pull request elizagamedev#22 from rkevin-arch/better-builds
Browse files Browse the repository at this point in the history
Better builds
  • Loading branch information
rkevin-arch authored Feb 28, 2021
2 parents 44dbbd9 + c482450 commit debea13
Show file tree
Hide file tree
Showing 13 changed files with 122 additions and 91 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/build-baremetal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,17 @@ jobs:
- name: Build ModShot
run: conan build ${{ github.workspace }}
working-directory: ${{ runner.temp }}\build
- name: Create dist folder
run: |
mkdir ${{ runner.temp }}\built_artifact;
move ${{ runner.temp }}\build\bin\lib ${{ runner.temp }}\built_artifact\lib;
move ${{ runner.temp }}\build\bin\* ${{ runner.temp }}\built_artifact\lib;
move ${{ runner.temp }}\built_artifact\lib\oneshot-shim.exe ${{ runner.temp }}\built_artifact\oneshot.exe
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: modshot_build_windows_${{ github.sha }}
path: ${{ runner.temp }}\build\bin
path: ${{ runner.temp }}\built_artifact
build-linux:
name: Build ModShot for Linux
runs-on: ubuntu-latest
Expand All @@ -45,7 +51,7 @@ jobs:
- name: Install dependencies
run: |
sudo DEBIAN_FRONTEND=noninteractive apt install -y \
libgtk2.0-dev libxfconf-0-dev libwmf0.2-7-gtk libegl1-mesa-dev libgbm-dev libasound2-dev libjack-dev libpulse-dev libaudio-dev &&
libgtk2.0-dev libxfconf-0-dev libwmf0.2-7-gtk libegl1-mesa-dev libgbm-dev libasound2-dev libjack-dev libpulse-dev libaudio-dev patchelf &&
sudo curl -Lo /usr/local/bin/linuxdeploy-x86_64.AppImage https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage &&
sudo chmod +x /usr/local/bin/linuxdeploy-x86_64.AppImage
- name: Setup Python
Expand All @@ -67,10 +73,10 @@ jobs:
- name: Build ModShot
run: conan build ${{ github.workspace }}
working-directory: ${{ runner.temp }}/build
- name: Create AppDir
- name: Create dist folder
run: |
mkdir ${{ runner.temp }}/dist &&
${{ github.workspace }}/make-linux-appdir.sh ${{ github.workspace }} ${{ runner.temp }}/build ${{ runner.temp }}/dist &&
${{ github.workspace }}/make-linux-dist.sh ${{ runner.temp }}/build ${{ runner.temp }}/dist &&
cd ${{ runner.temp }}/dist &&
tar czf ${{ runner.temp }}/modshot_${{ github.sha }}.tar.gz .
- name: Upload artifact
Expand Down
18 changes: 0 additions & 18 deletions .github/workflows/build-windows.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,10 @@ if(STEAM)
COPYONLY)
endif()

if(WIN32)
add_executable("oneshot-shim" WIN32
"${CMAKE_SOURCE_DIR}/windows/shim.c"
"${CMAKE_SOURCE_DIR}/assets/resources.rc")
endif()

#add_subdirectory(scripts)
6 changes: 4 additions & 2 deletions Dockerfile-linux
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ FROM conanio/gcc5
RUN conan remote add eliza "https://api.bintray.com/conan/eliza/conan" && \
conan remote add bincrafters "https://api.bintray.com/conan/bincrafters/public-conan"

RUN sudo apt update && DEBIAN_FRONTEND=noninteractive sudo apt install -y xorg-dev libx11-xcb-dev libxcb-render0-dev libxcb-render-util0-dev libgtk2.0-dev libxfconf-0-dev vim libwmf0.2-7-gtk librsvg2-common rsync
RUN sudo apt update && DEBIAN_FRONTEND=noninteractive sudo apt install -y \
xorg-dev libx11-xcb-dev libxcb-render0-dev libxcb-render-util0-dev libgtk2.0-dev libxfconf-0-dev vim libwmf0.2-7-gtk librsvg2-common rsync patchelf dos2unix && \
sudo rm -rf /var/lib/apt/lists/*
RUN sudo python -m pip install mako pyqt5 pyinstaller

# install all dependencies for the conanfile in commit
Expand All @@ -22,7 +24,7 @@ RUN cd /tmp && sudo chmod 755 appimagetool-x86_64.AppImage linuxdeploy-x86_64.Ap
sudo ln -s /usr/local/bin/appimagetool/AppRun /usr/local/bin/appimagetool-x86_64.AppImage && \
sudo ln -s /usr/local/bin/linuxdeploy/AppRun /usr/local/bin/linuxdeploy-x86_64.AppImage

ENTRYPOINT ["/work/src/build-entrypoint-linux.sh"]
ENTRYPOINT ["bash", "-c", "dos2unix /work/src/build-entrypoint-linux.sh && chmod +x /work/src/build-entrypoint-linux.sh && /work/src/build-entrypoint-linux.sh"]

# build this docker image as follows:
# docker build -t oneshot-build-linux .
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile-windows
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ COPY conanfile.py C:/Temp/install_deps/
RUN conan install --build=missing C:\Temp\install_deps

# finally, we build oneshot when we run the container
COPY build-entrypoint-windows.bat /
ENTRYPOINT ["C:\\build-entrypoint-windows.bat"]
ENTRYPOINT ["C:\\work\\src\\build-entrypoint-windows.bat"]
2 changes: 1 addition & 1 deletion binding-mri/binding-mri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ static void mriBindingInit()

rb_eval_string(
"if ENV['SSL_CERT_FILE'].nil?\n"
" ENV['SSL_CERT_FILE'] = './ssl/cacert.pem'\n"
" ENV['SSL_CERT_FILE'] = './lib/cacert.pem'\n"
"end\n"
);
}
Expand Down
3 changes: 2 additions & 1 deletion build-entrypoint-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ cd /work/build
conan install /work/src --build=missing
conan build /work/src

/work/src/make-linux-appdir.sh /work/src /work/build /work/dist
dos2unix /work/src/make-linux-dist.sh
/work/src/make-linux-dist.sh /work/build /work/dist /work/data
4 changes: 3 additions & 1 deletion build-entrypoint-windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ conan install \work\src --build=missing || (echo CONAN INSTALL FAILED! && exit 1
conan build \work\src || (echo CONAN BUILD FAILED! && goto end)
:: TODO: compile the journal?

robocopy C:\work\build\bin C:\work\dist /e
if exist C:\work\data (robocopy C:\work\data C:\work\dist /e)
robocopy C:\work\build\bin\lib C:\work\dist\lib /e
robocopy C:\work\build\bin\ C:\work\dist\lib
move C:\work\dist\lib\oneshot-shim.exe C:\work\dist\oneshot.exe

echo ModShot has been built. Enjoy.
:end
Expand Down
10 changes: 1 addition & 9 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,6 @@ def generate_version_number(self):

def build_configure(self):
self.generate_version_number()
# if we are on windows, git might clone files using the CRLF newline
# this will cause issues when building for linux, as some scripts cannot run properly
# we run dos2unix on them to convert their line endings
for file in ['make-appimage.sh', 'assets/AppRun', 'assets/oneshot.desktop']:
try:
tools.dos2unix(os.path.join(self.source_folder, file))
except FileNotFoundError:
pass # in case windows users don't need those files

cmake = CMake(self, msbuild_verbosity='minimal')
if self.options.platform == "steam":
Expand All @@ -114,7 +106,7 @@ def build(self):

# ship certificates into the ssl folder in the game directory
# openssl will use this folder since we hardcoded it in binding-mri.cpp
tools.download("https://curl.haxx.se/ca/cacert.pem", "bin/ssl/cacert.pem", overwrite=True)
tools.download("https://curl.haxx.se/ca/cacert.pem", "bin/lib/cacert.pem", overwrite=True)

def package(self):
self.copy("*", dst="bin", src="bin")
Expand Down
53 changes: 0 additions & 53 deletions make-linux-appdir.sh

This file was deleted.

57 changes: 57 additions & 0 deletions make-linux-dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash -eu

# this blacklist is used by linuxdeploy
EXCLUDELIST=https://raw.githubusercontent.com/AppImage/pkg2appimage/master/excludelist
SO_BLACKLIST="$(curl -sL $EXCLUDELIST | grep -o '^[^ #]*')"
SO_PROCESSED=""

function fail() {
echo "$1"
echo "Please beat the crap out of rkevin until he fixes this issue."
exit 1
}

function copy_dependencies() {
if [[ $SO_BLACKLIST =~ $1 ]]; then
return
fi
if [[ $SO_PROCESSED =~ $1 ]]; then
return
fi
[[ ! $1 =~ ^[a-zA-Z0-9+\.-]*$ ]] && fail "The library $1 has weird characters!"

SO_PROCESSED="$SO_PROCESSED $1"
cp "$2" "$DESTDIR/$1"
patchelf --set-rpath '$ORIGIN' "$DESTDIR/$1"
ldd "$2" | while read -ra line; do
if [[ ${line[0]} == 'linux-vdso.so.1' ]] || [[ ${line[0]} =~ 'ld-linux-x86-64.so.2' ]]; then
continue
fi
[[ ${line[1]} != '=>' ]] && echo ${line[*]} && fail "ldd's output isn't what this script expected!"
[[ ! ${line[3]} =~ ^\(0x[0-9a-f]*\)$ ]] && echo ${line[*]} && fail "ldd's output isn't what this script expected!"
copy_dependencies "${line[0]}" "${line[2]}"
done
}

if [ $# -lt 2 ]; then
echo "Usage: $0 BUILD_PATH DIST_PATH [DATA_PATH]"
fi

shopt -s dotglob

if [ $# -eq 3 ] && [ -d $3 ]; then
echo "Copying game files..."
cp -ar $3/* $2
fi

echo "Relocating dependencies..."
DESTDIR="$2/lib"
mkdir -p $DESTDIR
copy_dependencies oneshot "$1/bin/oneshot"

echo "Copying standard library..."
cp -ar "$1/bin/lib/ruby" "$2/lib/"
cp -ar "$1/bin/lib/cacert.pem" "$2/lib/"
ln -sf "lib/oneshot" "$2/oneshot"

echo "Done!"
2 changes: 2 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ void Config::read(int argc, char *argv[])
rgssVersion = 1;
game.title = "OneShot";
game.scripts = "Data/xScripts.rxdata";
gameFolder = "..";

defScreenW = 640;
defScreenH = 480;

Expand Down
35 changes: 35 additions & 0 deletions windows/shim.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <windows.h>
#include <wchar.h>

const wchar_t *ARGV0 = "lib\\oneshot.exe";

int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow) {
(void)hInstance;
(void)hPrevInstance;
(void)lpCmdLine;
(void)nCmdShow;

int argc;
LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc);

HMODULE hModule = GetModuleHandle(NULL);
if (hModule != NULL) {
wchar_t *oneshotDir[MAX_PATH];
GetModuleFileNameW(hModule, oneshotDir, sizeof(oneshotDir));
_wchdir(oneshotDir);
}

if (argc != 0) {
argv[0] = ARGV0;
}

_wexecv(L"lib\\oneshot.exe", argv);
MessageBoxW(NULL,
L"Cannot start ModShot for some reason.\nPlease check your ModShot installation.",
L"ModShot Shim",
MB_ICONERROR);
return 1;
}

0 comments on commit debea13

Please sign in to comment.