Skip to content

Commit

Permalink
Merge pull request #5 from 420verfl0w/indev
Browse files Browse the repository at this point in the history
merge Indev to master
  • Loading branch information
Kbz-8 authored Dec 9, 2023
2 parents 197c710 + b79b8da commit 4acd240
Show file tree
Hide file tree
Showing 53 changed files with 3,674 additions and 134 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Windows (xmake)

on:
pull_request:
push:
paths-ignore:
- '.gitignore'
- 'LICENSE'
- 'README.md'

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [windows-latest]
arch: [x64]
mode: [release]

runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, 'ci skip')"

steps:
- name: Get current date as package key
id: cache_key
run: echo "key=$(date +'%W')" >> $GITHUB_OUTPUT

- name: Checkout repository
uses: actions/checkout@v4

# Install system dependencies
- name: Install Vulkan SDK
uses: humbletim/[email protected]
with:
version: 1.3.204.1
cache: true

# Force xmake to a specific folder (for cache)
- name: Set xmake env
run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" >> $GITHUB_ENV

# Install xmake
- name: Setup xmake
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: branch@master
actions-cache-folder: .xmake-cache-W${{ steps.cache_key.outputs.key }}

# Update xmake repository (in order to have the file that will be cached)
- name: Update xmake repository
run: xmake repo --update

# Fetch xmake dephash
- name: Retrieve dependencies hash
id: dep_hash
run: echo "hash=$(xmake l utils.ci.packageskey)" >> $GITHUB_OUTPUT

# Cache xmake dependencies
- name: Retrieve cached xmake dependencies
uses: actions/cache@v3
with:
path: ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages
key: Windows-${{ matrix.arch }}-${{ matrix.mode }}-${{ steps.dep_hash.outputs.hash }}-W${{ steps.cache_key.outputs.key }}

# Setup compilation mode and install project dependencies
- name: Configure xmake and install dependencies
run: xmake config --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --yes

# Build the mlx
- name: Build MacroLibX
run: xmake --yes

# Build the test
- name: Build Test
run: xmake build --yes Test
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,18 @@
*.a
*.so
*.out
*.dll
*.lib
*.exp
*.json
*.tmp
*.ilk
*.pdb
*.exe
.vs/
.xmake/
.cache/
objs/
build/
test/.gdb_history
test/Test
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
NAME = libmlx.so

SRCS = $(wildcard $(addsuffix /*.cpp, ./src/core))
SRCS += $(wildcard $(addsuffix /*.cpp, ./src/core/**))
SRCS += $(wildcard $(addsuffix /*.cpp, ./src/platform))
SRCS += $(wildcard $(addsuffix /*.cpp, ./src/renderer))
SRCS += $(wildcard $(addsuffix /*.cpp, ./src/renderer/**))
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<a href="https://github.com/420verfl0w/MacroLibX/actions/workflows/linux_gcc.yml"><img src="https://github.com/420verfl0w/MacroLibX/actions/workflows/linux_gcc.yml/badge.svg"></a>
<a href="https://github.com/420verfl0w/MacroLibX/actions/workflows/macos_x86.yml"><img src="https://github.com/420verfl0w/MacroLibX/actions/workflows/macos_x86.yml/badge.svg"></a>
</div>
<div align="center">
<a href="https://github.com/420verfl0w/MacroLibX/actions/workflows/windows.yml"><img src="https://github.com/420verfl0w/MacroLibX/actions/workflows/windows.yml/badge.svg"></a>
</div>
</div>

###### MacroLibX, a rewrite of 42 School's MiniLibX using SDL2 and Vulkan.
Expand Down Expand Up @@ -45,6 +48,10 @@ brew install molten-vk
brew install SDL2
```

### 🪟 Windows

To build on Windows you may need to use the [xmake](https://xmake.io) build. [Here's](./XMAKE_BUILD.md) how you can use it.

### Clone and Build

Finally, you can clone the Git repository. When inside it, run the GNU `make` command to compile MacroLibX.
Expand Down
47 changes: 47 additions & 0 deletions XMAKE_BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 🏗️ xmake build
To build on Windows (if you don't use [WSL](https://learn.microsoft.com/en-us/windows/wsl/install)) or on other OS, the MacroLibX uses [xmake](https://xmake.io), a build system which will download and compile all dependencies it won't find on your computer.

## 💾 Install xmake
You can find how to install it on your system [here](https://xmake.io/#/guide/installation). Note that you can also download a [portable version](https://github.com/xmake-io/xmake/releases) of xmake if you wish not to install it.

## ⚙️ Configure the MacroLibX build
Just as the Makfile build system, you can configure how xmake should build the MacroLibX. The base command to configure it is `xmake config [opts...]` or `xmake f [opts...]`.

### 📦 Compile mode
You can configure xmake to build the mlx in debug mode or in release mode (release mode is enabled by default). To do so you can use `xmake config --mode=debug` or `xmake config --mode=release`.

### 🛠️ Set the toolchain
To change the compilation toolchain using `xmake config --toolchain=[gcc|clang|...]`

### 🖼️ Image optimisations
If you run into glitches when writing or reading pixels from images you can turn off image optimisations using `xmake config --images_optimized=n`.

### 🖥️ Force the use of the integrated GPU (not recommended)
You can force the mlx to use your integrated GPU using `xmake config --force_integrated_gpu=y`. Note that there are a lot of chances that your application crashes using that.

### 💽 Dump the graphics memory
The mlx can dump it's graphics memory use to json files every two seconds by enabling this option `xmake config --graphics_memory_dump=y`.

### 🪛 A possible build configuration
As a configuration example here's how the command can look like `xmake config --mode=debug --toolchain=clang --graphics_memory_dump=y --images_optimized=n`

## 🚧 Build the lib

### Compile using command-line (first method)
Once you're ready to compile the lib, run `xmake` (or `xmake -jX` if you wish not to use all your computer threads, with X being the number of threads you wish to use) and watch as the lib compiles.

### Generate a project (second method)
xmake can also generate a project file for another tool:
* Visual Studio : `xmake project -k vs`
* CMakeLists.txt (which you can open in CLion and more) : `xmake project -k cmake`
* Makefile : `xmake project -k make`
* Ninja : `xmake project -k ninja`
* XCode : `xmake project -k xcode`

You should now be able to open the project file with the tool of your choice.

## 😋 Enjoy
Enjoy you project built with the mlx
<p align="center">
<img src="./res/screenshot_test_windows.png" alt="drawing" width="400"/>
</p>
Loading

0 comments on commit 4acd240

Please sign in to comment.