Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ jobs:
container:
image: sacbase/sac-compiler
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v7
with:
submodules: 'recursive'
- name: Configure sac2c
run: cp -r /root/.sac2crc $HOME/.sac2crc
- name: Install SDL3
run: apt install -y libsdl3-dev libsdl3-image-dev libsdl3-ttf-dev
- name: Setup CMake
run: cmake -DTARGETS="seq;mt_pth" -B build
- name: Build
run: make
run: cmake --build build
12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@ INCLUDE ("cmake-common/misc-macros.cmake")

SET (SDL_BUILDING_LIBRARY ON)
FIND_PACKAGE (SDL3 REQUIRED)
FIND_PACKAGE (X11 REQUIRED)

SET (SAC2C_EXTRA_INC "-I${X11_INCLUDE_DIR}")
SET (SAC2C_CPP_INC "-Xl" "-lX11" "-Xtl" "-lX11")
# X11 is needed for X-forwarding over SSH
FIND_PACKAGE (X11 QUIET)

IF (X11_FOUND)
MESSAGE (STATUS "X11 found")
SET (SAC2C_CC_FLAGS "-DHAVE_X11")
SET (SAC2C_EXTRA_INC "-I${X11_INCLUDE_DIR}")
SET (SAC2C_CPP_INC "-Xl" "-lX11" "-Xtl" "-lX11")
ENDIF ()

# Check if sac2c suppports building generically
IF (BUILDGENERIC)
Expand Down
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ SAC2C ?= sac2c
TARGETS ?= "seq;mt_pth"
BUILD_DIR ?= build

.PHONY: all build clean
.PHONY: all build examples clean

all: build

build:
cmake -DSAC2C_EXEC=$(SAC2C) -DTARGETS=$(TARGETS) -B $(BUILD_DIR)
cmake --build $(BUILD_DIR)

examples: $(BUILD_DIR)/mandelbrot $(BUILD_DIR)/minimal

$(BUILD_DIR)/mandelbrot: examples/mandelbrot.sac
$(SAC2C) $< -o $@

$(BUILD_DIR)/minimal: examples/minimal.sac
$(SAC2C) $< -o $@

clean:
$(RM) -r $(BUILD_DIR)
5 changes: 5 additions & 0 deletions src/src/sdl3.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
#include <stdio.h>
#include <stdint.h>
#include <SDL3/SDL.h>

#ifdef HAVE_X11
#include <X11/Xlib.h>
#endif

#include "sdl3.h"

Expand Down Expand Up @@ -66,8 +69,10 @@ SDLcontext *SAC_InitDisplay(sac_int height, sac_int width)
ctx->height = height;
ctx->running = true;

#ifdef HAVE_X11
// Fix for using SDL with X-forwarding over SSH
XInitThreads();
#endif

if (!SDL_Init(SDL_INIT_VIDEO)) {
SAC_RuntimeError("SDL_Init failed: %s", SDL_GetError());
Expand Down