Skip to content

Commit

Permalink
REVIEWED: Support build workflows for several platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
raysan5 committed Nov 30, 2023
1 parent e51ac27 commit d4449d8
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 49 deletions.
137 changes: 137 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: macOS

on:
workflow_dispatch:
push:
paths:
- 'src/**'
- '.github/workflows/linux.yml'
release:
types: [published]

permissions:
contents: read

jobs:
build:
permissions:
contents: write # for actions/upload-release-asset to upload release asset
runs-on: macos-latest

env:
PROJECT_NAME: ${{ github.event.repository.name }}
PROJECT_BUILD_PATH: ${{ github.event.repository.name }}/src
PROJECT_RELEASE_PATH: ${{ github.event.repository.name }}_dev_macos
PROJECT_SOURCES: "raylib_game.c"
PROJECT_CUSTOM_FLAGS: ""
RAYLIB_CONFIG_FLAGS: "-DSUPPORT_MODULE_RSHAPES -DSUPPORT_MODULE_RTEXTURES -DSUPPORT_MODULE_RTEXT -DSUPPORT_MODULE_RAUDIO -DSUPPORT_COMPRESSION_API -DSUPPORT_QUADS_DRAW_MODE -DSUPPORT_IMAGE_MANIPULATION -DSUPPORT_DEFAULT_FONT -DSUPPORT_TEXT_MANIPULATION -DSUPPORT_FILEFORMAT_WAV -DSUPPORT_FILEFORMAT_QOA -DSUPPORT_FILEFORMAT_MP3 -DSUPPORT_FILEFORMAT_OGG -DSUPPORT_FILEFORMAT_FLAC -DSUPPORT_STANDARD_FILEIO -DSUPPORT_TRACELOG"

steps:
- name: Checkout this repo
uses: actions/checkout@master
with:
path: ${{ env.PROJECT_NAME }}

- name: Checkout raylib repo
uses: actions/checkout@v3
with:
repository: raysan5/raylib
path: raylib

- name: Setup Release Paths
run: |
echo "PROJECT_RELEASE_PATH=${{ env.PROJECT_NAME }}_v${{ github.event.release.tag_name }}_macos" >> $GITHUB_ENV
shell: bash
if: github.event_name == 'release' && github.event.action == 'published'

- name: Setup Environment
run: |
mkdir ${{ env.PROJECT_RELEASE_PATH }}
cd ${{ env.PROJECT_RELEASE_PATH }}
mkdir ${{ env.PROJECT_NAME }}.app
cd ${{ env.PROJECT_NAME }}.app
mkdir Contents
cd Contents
mkdir MacOS
mkdir Resources
cd ../../..
ls
shell: bash

# Generating static library, note that i386 architecture is deprecated
# Defining GL_SILENCE_DEPRECATION because OpenGL is deprecated on macOS
- name: Build raylib Library
run: |
cd raylib/src
clang --version
# Extract version numbers from Makefile
brew install grep
RAYLIB_API_VERSION=`ggrep -Po 'RAYLIB_API_VERSION\s*=\s\K(.*)' Makefile`
RAYLIB_VERSION=`ggrep -Po 'RAYLIB_VERSION\s*=\s\K(.*)' Makefile`
# Build raylib x86_64 static
make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=STATIC CUSTOM_CFLAGS="-target x86_64-apple-macos10.12 -DGL_SILENCE_DEPRECATION"
mv -v -f libraylib.a libraylib_x86_64.a
make clean
# Build raylib arm64 static
make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=STATIC CUSTOM_CFLAGS="-target arm64-apple-macos11 -DGL_SILENCE_DEPRECATION" -B
mv -v -f libraylib.a libraylib_arm64.a
make clean
# Join x86_64 and arm64 static
lipo -create -output libraylib.a libraylib_x86_64.a libraylib_arm64.a
lipo libraylib.a -detailed_info
cd ../..
- name: Build Product
run: |
cd ${{ env.PROJECT_NAME }}/src
# Build project x86_64 binary
# TODO: Link with x86_64 raylib library: libraylib_x86_64.a
make PLATFORM=PLATFORM_DESKTOP BUILD_MODE=RELEASE PROJECT_SOURCE_FILES=${{ env.PROJECT_SOURCES }} PROJECT_CUSTOM_FLAGS=${{ env.PROJECT_CUSTOM_FLAGS }} PROJECT_BUILD_PATH=. RAYLIB_PATH=../../raylib PROJECT_CUSTOM_FLAGS="-target x86_64-apple-macos10.12"
mv -v -f ${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME }}_x86_64
make clean
# Build project arm64 binary
# TODO: Link with arm64 raylib library: libraylib_arm.a
make PLATFORM=PLATFORM_DESKTOP BUILD_MODE=RELEASE PROJECT_SOURCE_FILES=${{ env.PROJECT_SOURCES }} PROJECT_CUSTOM_FLAGS=${{ env.PROJECT_CUSTOM_FLAGS }} PROJECT_BUILD_PATH=. RAYLIB_PATH=../../raylib PROJECT_CUSTOM_FLAGS="-target arm64-apple-macos11"
mv -v -f ${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME }}_arm64
make clean
# Join x86_64 and arm64 binaries
lipo -create -output ${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME }}_x86_64 ${{ env.PROJECT_NAME }}_arm64
lipo ${{ env.PROJECT_NAME }} -detailed_info
cd ..
- name: Generate Artifacts
run: |
ls ${{ env.PROJECT_BUILD_PATH }}
cp ${{ env.PROJECT_BUILD_PATH }}/${{ env.PROJECT_NAME }} ${{ env.PROJECT_RELEASE_PATH }}/${{ env.PROJECT_NAME }}.app/Contents/MacOS
cp ${{ env.PROJECT_NAME }}/src/raylib.icns ${{ env.PROJECT_RELEASE_PATH }}/${{ env.PROJECT_NAME }}.app/Contents/Resources
cp ${{ env.PROJECT_NAME }}/src/Info.plist ${{ env.PROJECT_RELEASE_PATH }}/${{ env.PROJECT_NAME }}.app/Contents
cp ${{ env.PROJECT_NAME }}/README.md ${{ env.PROJECT_RELEASE_PATH }}
cp ${{ env.PROJECT_NAME }}/LICENSE ${{ env.PROJECT_RELEASE_PATH }}
ls ${{ env.PROJECT_RELEASE_PATH }}
7z a ./${{ env.PROJECT_RELEASE_PATH }}.zip ./${{ env.PROJECT_RELEASE_PATH }}
# Issue: Double zip: https://github.com/actions/upload-artifact/issues/39
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.PROJECT_RELEASE_PATH }}.zip
path: ./${{ env.PROJECT_RELEASE_PATH }}.zip

# Alternative: https://github.com/marketplace/actions/gh-release
- name: Upload Artifact to Release
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_name: ${{ env.PROJECT_RELEASE_PATH }}.zip
asset_path: ./${{ env.PROJECT_RELEASE_PATH }}.zip
asset_content_type: application/zip
if: github.event_name == 'release' && github.event.action == 'published'
2 changes: 1 addition & 1 deletion .github/workflows/webassembly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v12
with:
version: 3.1.26
version: 3.1.30
actions-cache-folder: 'emsdk-cache'

- name: Setup Release Paths
Expand Down
30 changes: 30 additions & 0 deletions src/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>gamejam_template</string>
<key>CFBundleIconFile</key>
<string>raylib.icns</string>
<key>CFBundleIdentifier</key>
<string>com.raylibtech.gamejam_template</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>gamejam_template</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>LSMinimumSystemVersion</key>
<string>10.12</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright (c) 2023 raylib technologies (@raylibtech)</string>
<key>CFBundleSignature</key>
<string>????</string>
</dict>
</plist>
27 changes: 15 additions & 12 deletions src/minshell.html
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
<!doctype html>
<html lang="en-us">
<html lang="EN-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>raylib web game</title>

<meta name="title" content="raylib web game">
<meta name="description" content="New raylib web videogame, developed using raylib videogames library">
<meta name="keywords" content="raylib, games, html5, programming, C, C++, library, learn, videogames">
<meta name="keywords" content="raylib, programming, examples, html5, C, C++, library, learn, games, videogames">
<meta name="viewport" content="width=device-width">

<!-- Open Graph metatags for sharing -->
<meta property="og:type" content="website" />
<meta property="og:title" content="raylib web game">
<meta property="og:image:type" content="image/png">
<meta property="og:image" content="https://www.raylib.com/common/img/raylib_logo.png">
<meta property="og:site_name" content="raylib.com">
<meta property="og:image" content="https://www.raylib.com/common/raylib_logo.png">
<meta property="og:image:alt" content="New raylib web videogame, developed using raylib videogames library" />
<meta property="og:site_name" content="raylib - example">
<meta property="og:url" content="https://www.raylib.com/games.html">
<meta property="og:description" content="New raylib web videogame, developed using raylib videogames library">

<!-- Twitter metatags for sharing -->
<meta name="twitter:card" content="summary">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@raysan5">
<meta name="twitter:title" content="raylib web game">
<meta name="twitter:image" content="https://www.raylib.com/common/raylib_logo.png">
<meta name="twitter:image:alt" content="New raylib web videogame, developed using raylib videogames library">
<meta name="twitter:url" content="https://www.raylib.com/games.html">
<meta name="twitter:description" content="New raylib web game, developed using raylib videogames library">
<meta name="twitter:description" content="New raylib web videogame, developed using raylib videogames library">

<!-- Favicon -->
<link rel="shortcut icon" href="https://www.raylib.com/favicon.ico">

<style>
body { margin: 0px; }
canvas.emscripten { border: 0px none; background-color: black; }
Expand Down Expand Up @@ -70,7 +73,7 @@
element.scrollTop = element.scrollHeight; // focus on bottom
}
};
})(),
})(),
canvas: (function() {
var canvas = document.getElementById('canvas');
return canvas;
Expand Down
Binary file added src/raylib.icns
Binary file not shown.
48 changes: 14 additions & 34 deletions src/raylib_game.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*******************************************************************************************
*
* raylib 9years gamejam template
* raylib gamejam template
*
* Template originally created with raylib 4.5-dev, last time updated with raylib 4.5-dev
* Template originally created with raylib 4.5-dev, last time updated with raylib 5.0
*
* Template licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 2022 Ramon Santamaria (@raysan5)
* Copyright (c) 2022-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/

Expand Down Expand Up @@ -49,13 +49,10 @@ typedef enum {
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
static const int screenWidth = 256;
static const int screenHeight = 256;
static const int screenWidth = 1280;
static const int screenHeight = 720;

static unsigned int screenScale = 1;
static unsigned int prevScreenScale = 1;

static RenderTexture2D target = { 0 }; // Initialized at init
static RenderTexture2D target = { 0 }; // Render texture to render our game

// TODO: Define global variables here, recommended to make them static

Expand All @@ -75,7 +72,7 @@ int main(void)

// Initialization
//--------------------------------------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib 9yr gamejam");
InitWindow(screenWidth, screenHeight, "raylib gamejam template");

// TODO: Load resources / Initialize variables at this point

Expand Down Expand Up @@ -117,46 +114,29 @@ void UpdateDrawFrame(void)
{
// Update
//----------------------------------------------------------------------------------
// Screen scale logic (x2)
if (IsKeyPressed(KEY_ONE)) screenScale = 1;
else if (IsKeyPressed(KEY_TWO)) screenScale = 2;
else if (IsKeyPressed(KEY_THREE)) screenScale = 3;

if (screenScale != prevScreenScale)
{
// Scale window to fit the scaled render texture
SetWindowSize(screenWidth*screenScale, screenHeight*screenScale);

// Scale mouse proportionally to keep input logic inside the 256x256 screen limits
SetMouseScale(1.0f/(float)screenScale, 1.0f/(float)screenScale);

prevScreenScale = screenScale;
}

// TODO: Update variables / Implement example logic at this point
//----------------------------------------------------------------------------------

// Draw
//----------------------------------------------------------------------------------
// Render all screen to texture (for scaling)
// Render game screen to a texture,
// it could be useful for scaling or further sahder postprocessing
BeginTextureMode(target);
ClearBackground(RAYWHITE);

// TODO: Draw screen at 256x256
// TODO: Draw your game screen here
DrawRectangle(10, 10, screenWidth - 20, screenHeight - 20, SKYBLUE);

EndTextureMode();

// Render to screen (main framebuffer)
BeginDrawing();
ClearBackground(RAYWHITE);

// Draw render texture to screen scaled as required
DrawTexturePro(target.texture, (Rectangle){ 0, 0, (float)target.texture.width, -(float)target.texture.height }, (Rectangle){ 0, 0, (float)target.texture.width*screenScale, (float)target.texture.height*screenScale }, (Vector2){ 0, 0 }, 0.0f, WHITE);

// Draw equivalent mouse position on the target render-texture
DrawCircleLines(GetMouseX(), GetMouseY(), 10, MAROON);
// Draw render texture to screen, scaled if required
DrawTexturePro(target.texture, (Rectangle){ 0, 0, (float)target.texture.width, -(float)target.texture.height }, (Rectangle){ 0, 0, (float)target.texture.width, (float)target.texture.height }, (Vector2){ 0, 0 }, 0.0f, WHITE);

// TODO: Draw everything that requires to be drawn at this point:
// TODO: Draw everything that requires to be drawn at this point, maybe UI?

EndDrawing();
//----------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/raylib_game.rc
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ BEGIN
BLOCK "040904E4" // English US
BEGIN
VALUE "CompanyName", "raylib technologies"
VALUE "FileDescription", "raylib 9yr gamejam template"
VALUE "FileDescription", "raylib gamejam template"
VALUE "FileVersion", "1.0"
VALUE "InternalName", "raylib-game"
VALUE "LegalCopyright", "(c) 2022 raylib technologies (@raylibtech)"
VALUE "LegalCopyright", "(c) 2023 raylib technologies (@raylibtech)"
//VALUE "OriginalFilename", "raylib_app.exe"
VALUE "ProductName", "raylib-game"
VALUE "ProductVersion", "1.0"
Expand Down

0 comments on commit d4449d8

Please sign in to comment.