Skip to content

Commit

Permalink
build: Add windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasTavaresA committed Apr 7, 2024
1 parent 8ad345b commit 7fa76bd
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
password.txt
pickle.res
pickle.exe
pickle.apk
pickle
R.java
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ Crossplatform spinning wheel picker so you can make important life decisions

https://github.com/LucasTavaresA/pickle/assets/80704612/f061aa5f-06e5-4496-8af1-e89e2a6efe89

## Build

Don't forget to clone recursively to get the used raylib version

Building for windows requires [w64devkit](https://github.com/skeeto/w64devkit)

```sh
git clone --recurse-submodules https://github.com/LucasTavaresA/pickle.git
cd pickle
./build.sh
```

## Credits

Made with [raylib](https://www.raylib.com/)
Expand Down
Binary file modified assets/icon_hdpi.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 modified assets/icon_ldpi.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 modified assets/icon_mdpi.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 assets/icon_xhdpi.ico
Binary file not shown.
Binary file modified assets/icon_xhdpi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 35 additions & 9 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#!/usr/bin/env sh
# shellcheck disable=2164,2086
RUN=0
WINDOWS=0
LINUX=0
ANDROID=0
REDOWNLOAD=0
REBUILD=0
BUILD_FLAGS="-ggdb"
WARNING_FLAGS="-Wall -Wextra -Wshadow"
LINKING_FLAGS="-L./lib/desktop/ -I./raylib/src/ -l:libraylib.a -lm"
PROGRAM="pickle"
MAINTAINER="lucasta"
SOURCE="https://dl.google.com/android/repository/"
Expand All @@ -15,7 +17,7 @@ NDK="android-ndk-r26b"

print_help() {
printf \
"%s [linux|android] [-r -R -d -b]
"%s [windows|linux|android] [-r -R -d -b]
-r runs after building
-R builds with -DRELEASE, disabling debug mode features
Expand All @@ -40,11 +42,34 @@ main() {
BUILD_FLAGS="$BUILD_FLAGS -DRELEASE"
;;
"android")
if [ "$WINDOWS" = 1 ] || [ "$LINUX" = 1 ]; then
printf "You can only build for one platform at a time\n\n"
print_help
exit 1
fi

ANDROID=1
;;
"linux")
if [ "$WINDOWS" = 1 ] || [ "$ANDROID" = 1 ]; then
printf "You can only build for one platform at a time\n\n"
print_help
exit 1
fi

LINUX=1
BUILD_FLAGS="$BUILD_FLAGS $WARNING_FLAGS"
BUILD_FLAGS="$BUILD_FLAGS $WARNING_FLAGS -DPLATFORM_LINUX"
;;
"windows")
if [ "$LINUX" = 1 ] || [ "$ANDROID" = 1 ]; then
printf "You can only build for one platform at a time\n\n"
print_help
exit 1
fi

WINDOWS=1
BUILD_FLAGS="$BUILD_FLAGS -DPLATFORM_WINDOWS -Wl,--subsystem,windows"
LINKING_FLAGS="$LINKING_FLAGS -lgdi32 -lwinmm"
;;
"--help")
print_help
Expand All @@ -64,15 +89,11 @@ main() {
shift
done

if [ "$LINUX" = 0 ] && [ "$ANDROID" = 0 ]; then
if [ "$LINUX" = 0 ] && [ "$WINDOWS" = 0 ] && [ "$ANDROID" = 0 ]; then
printf "You need to specify a platform to build!\n\n"
print_help
exit 1
elif [ "$LINUX" = 1 ] && [ "$ANDROID" = 1 ]; then
printf "You can only build for one platform at a time\n\n"
print_help
exit 1
elif [ "$LINUX" = 1 ]; then
elif [ "$LINUX" = 1 ] || [ "$WINDOWS" = 1 ]; then
if [ "$REBUILD" = 1 ]; then
rm -rf ./lib/desktop/
fi
Expand All @@ -92,7 +113,12 @@ main() {
)
fi

cc src/main.c -I./raylib/src/ $BUILD_FLAGS -L./lib/desktop/ -l:libraylib.a -lm -o $PROGRAM || exit 1
if [ "$WINDOWS" = 1 ]; then
windres $PROGRAM.rc -O coff -o $PROGRAM.res --target=pe-x86-64
cc src/main.c $PROGRAM.res $BUILD_FLAGS $LINKING_FLAGS -o $PROGRAM || exit 1
else
cc src/main.c $BUILD_FLAGS $LINKING_FLAGS -o $PROGRAM || exit 1
fi

if [ "$RUN" = 1 ]; then
./$PROGRAM
Expand Down
1 change: 1 addition & 0 deletions pickle.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
id ICON "./assets/icon_xhdpi.ico"
8 changes: 7 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ int main()
{
SetConfigFlags(FLAG_WINDOW_RESIZABLE | FLAG_WINDOW_HIGHDPI |
FLAG_MSAA_4X_HINT);
#ifdef PLATFORM_WINDOWS
InitWindow(800, 600, APP_NAME);
#else
InitWindow(ScreenWidth, ScreenHeight, APP_NAME);
SetExitKey(0);
#endif
SetExitKey(KEY_NULL);

#ifndef PLATFORM_ANDROID
ChangeDirectory("assets");
Expand All @@ -102,7 +106,9 @@ int main()
Fonte = LoadFont("iosevka-regular.ttf");

WindowIcon = LoadImage("icon_xhdpi.png");
ImageFormat(&WindowIcon, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8);
SetWindowIcon(WindowIcon);
UnloadImage(WindowIcon);

#define X(name) name##Icon = LoadTexture(#name "Icon.png");
ICON_LIST
Expand Down

0 comments on commit 7fa76bd

Please sign in to comment.