Merge branch 'master' of https://github.com/raysan5/raylib
This commit is contained in:
commit
1904873838
2
.github/workflows/cmake.yml
vendored
2
.github/workflows/cmake.yml
vendored
@ -86,7 +86,7 @@ jobs:
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install gcc-multilib
|
||||
sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev
|
||||
sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libwayland-dev libwayland-bin libxkbcommon-dev
|
||||
- name: Configure CMake
|
||||
# Use a bash shell so we can use the same syntax for environment variable
|
||||
# access regardless of the host operating system
|
||||
|
2
.github/workflows/linux.yml
vendored
2
.github/workflows/linux.yml
vendored
@ -55,7 +55,7 @@ jobs:
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install gcc-multilib
|
||||
sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev
|
||||
sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libwayland-bin
|
||||
mkdir build
|
||||
cd build
|
||||
mkdir ${{ env.RELEASE_NAME }}
|
||||
|
2
.github/workflows/linux_examples.yml
vendored
2
.github/workflows/linux_examples.yml
vendored
@ -27,7 +27,7 @@ jobs:
|
||||
- name: Setup Environment
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev
|
||||
sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libwayland-bin
|
||||
|
||||
- name: Build Library
|
||||
run: |
|
||||
|
@ -39,6 +39,12 @@ include(CMakeOptions.txt)
|
||||
# Enforces a few environment and compiler configurations
|
||||
include(BuildOptions)
|
||||
|
||||
if (UNIX AND NOT APPLE)
|
||||
if (NOT GLFW_BUILD_WAYLAND AND NOT GLFW_BUILD_X11)
|
||||
MESSAGE(FATAL_ERROR "Cannot disable both Wayland and X11")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Main sources directory (the second parameter sets the output directory name to raylib)
|
||||
add_subdirectory(src raylib)
|
||||
|
||||
|
@ -20,9 +20,10 @@ option(MACOS_FATLIB "Build fat library for both i386 and x86_64 on macOS" OFF)
|
||||
cmake_dependent_option(USE_AUDIO "Build raylib with audio module" ON CUSTOMIZE_BUILD ON)
|
||||
|
||||
enum_option(USE_EXTERNAL_GLFW "OFF;IF_POSSIBLE;ON" "Link raylib against system GLFW instead of embedded one")
|
||||
if(UNIX AND NOT APPLE)
|
||||
option(USE_WAYLAND "Use Wayland for window creation" OFF)
|
||||
endif()
|
||||
|
||||
# GLFW build options
|
||||
option(GLFW_BUILD_WAYLAND "Build the bundled GLFW with Wayland support" ON)
|
||||
option(GLFW_BUILD_X11 "Build the bundled GLFW with X11 support" ON)
|
||||
|
||||
option(INCLUDE_EVERYTHING "Include everything disabled by default (for CI usage" OFF)
|
||||
set(OFF ${INCLUDE_EVERYTHING} CACHE INTERNAL "Replace any OFF by default with \${OFF} to have it covered by this option")
|
||||
|
@ -1,8 +1,8 @@
|
||||
|
||||
if(USE_EXTERNAL_GLFW STREQUAL "ON")
|
||||
find_package(glfw3 3.3.3 REQUIRED)
|
||||
find_package(glfw3 3.4 REQUIRED)
|
||||
elseif(USE_EXTERNAL_GLFW STREQUAL "IF_POSSIBLE")
|
||||
find_package(glfw3 3.3.3 QUIET)
|
||||
find_package(glfw3 3.4 QUIET)
|
||||
endif()
|
||||
if (glfw3_FOUND)
|
||||
set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw)
|
||||
@ -16,7 +16,6 @@ if(NOT glfw3_FOUND AND NOT USE_EXTERNAL_GLFW STREQUAL "ON" AND "${PLATFORM}" MAT
|
||||
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||
set(GLFW_INSTALL OFF CACHE BOOL "" FORCE)
|
||||
set(GLFW_BUILD_WAYLAND ${USE_WAYLAND} CACHE BOOL "" FORCE)
|
||||
set(GLFW_LIBRARY_TYPE "OBJECT" CACHE STRING "" FORCE)
|
||||
|
||||
|
||||
|
@ -1,16 +1,18 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
// This has been tested to work with zig 0.11.0, zig 0.12.0-dev.2075+f5978181e and 0.12.0-dev.2990+31763d28c
|
||||
// This has been tested with zig version(s):
|
||||
// 0.11.0
|
||||
// 0.12.0-dev.2075+f5978181e
|
||||
// 0.12.0-dev.2990+31763d28c
|
||||
//
|
||||
// anytype is used here to preserve compatibility, in 0.12.0dev the std.zig.CrossTarget type
|
||||
// Anytype is used here to preserve compatibility, in 0.12.0dev the std.zig.CrossTarget type
|
||||
// was reworked into std.Target.Query and std.Build.ResolvedTarget. Using anytype allows
|
||||
// us to accept both CrossTarget and ResolvedTarget and act accordingly in getOsTagVersioned.
|
||||
pub fn addRaylib(b: *std.Build, target: anytype, optimize: std.builtin.OptimizeMode, options: Options) !*std.Build.Step.Compile {
|
||||
var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
const gpa = general_purpose_allocator.allocator();
|
||||
// get the relative source path, because it is needed for addCSourceFilesVersioned
|
||||
const relative = srcdir[b.build_root.path.?.len..];
|
||||
|
||||
if (comptime builtin.zig_version.minor >= 12 and @TypeOf(target) != std.Build.ResolvedTarget) {
|
||||
@compileError("Expected 'std.Build.ResolvedTarget' for argument 2 'target' in 'addRaylib', found '" ++ @typeName(@TypeOf(target)) ++ "'");
|
||||
} else if (comptime builtin.zig_version.minor == 11 and @TypeOf(target) != std.zig.CrossTarget) {
|
||||
@ -53,33 +55,33 @@ pub fn addRaylib(b: *std.Build, target: anytype, optimize: std.builtin.OptimizeM
|
||||
}
|
||||
|
||||
addCSourceFilesVersioned(raylib, &.{
|
||||
try join2(gpa, relative, "rcore.c"),
|
||||
try join2(gpa, relative, "utils.c"),
|
||||
try join2(gpa, srcdir, "rcore.c"),
|
||||
try join2(gpa, srcdir, "utils.c"),
|
||||
}, raylib_flags_arr.items);
|
||||
|
||||
if (options.raudio) {
|
||||
addCSourceFilesVersioned(raylib, &.{
|
||||
try join2(gpa, relative, "raudio.c"),
|
||||
try join2(gpa, srcdir, "raudio.c"),
|
||||
}, raylib_flags_arr.items);
|
||||
}
|
||||
if (options.rmodels) {
|
||||
addCSourceFilesVersioned(raylib, &.{
|
||||
try join2(gpa, relative, "rmodels.c"),
|
||||
try join2(gpa, srcdir, "rmodels.c"),
|
||||
}, raylib_flags_arr.items);
|
||||
}
|
||||
if (options.rshapes) {
|
||||
addCSourceFilesVersioned(raylib, &.{
|
||||
try join2(gpa, relative, "rshapes.c"),
|
||||
try join2(gpa, srcdir, "rshapes.c"),
|
||||
}, raylib_flags_arr.items);
|
||||
}
|
||||
if (options.rtext) {
|
||||
addCSourceFilesVersioned(raylib, &.{
|
||||
try join2(gpa, relative, "rtext.c"),
|
||||
try join2(gpa, srcdir, "rtext.c"),
|
||||
}, raylib_flags_arr.items);
|
||||
}
|
||||
if (options.rtextures) {
|
||||
addCSourceFilesVersioned(raylib, &.{
|
||||
try join2(gpa, relative, "rtextures.c"),
|
||||
try join2(gpa, srcdir, "rtextures.c"),
|
||||
}, raylib_flags_arr.items);
|
||||
}
|
||||
|
||||
@ -96,7 +98,7 @@ pub fn addRaylib(b: *std.Build, target: anytype, optimize: std.builtin.OptimizeM
|
||||
switch (getOsTagVersioned(target)) {
|
||||
.windows => {
|
||||
addCSourceFilesVersioned(raylib, &.{
|
||||
try join2(gpa, relative, "rglfw.c"),
|
||||
try join2(gpa, srcdir, "rglfw.c"),
|
||||
}, raylib_flags_arr.items);
|
||||
raylib.linkSystemLibrary("winmm");
|
||||
raylib.linkSystemLibrary("gdi32");
|
||||
@ -107,7 +109,7 @@ pub fn addRaylib(b: *std.Build, target: anytype, optimize: std.builtin.OptimizeM
|
||||
.linux => {
|
||||
if (!options.platform_drm) {
|
||||
addCSourceFilesVersioned(raylib, &.{
|
||||
try join2(gpa, relative, "rglfw.c"),
|
||||
try join2(gpa, srcdir, "rglfw.c"),
|
||||
}, raylib_flags_arr.items);
|
||||
raylib.linkSystemLibrary("GL");
|
||||
raylib.linkSystemLibrary("rt");
|
||||
@ -137,7 +139,7 @@ pub fn addRaylib(b: *std.Build, target: anytype, optimize: std.builtin.OptimizeM
|
||||
},
|
||||
.freebsd, .openbsd, .netbsd, .dragonfly => {
|
||||
addCSourceFilesVersioned(raylib, &.{
|
||||
try join2(gpa, relative, "rglfw.c"),
|
||||
try join2(gpa, srcdir, "rglfw.c"),
|
||||
}, raylib_flags_arr.items);
|
||||
raylib.linkSystemLibrary("GL");
|
||||
raylib.linkSystemLibrary("rt");
|
||||
@ -156,7 +158,7 @@ pub fn addRaylib(b: *std.Build, target: anytype, optimize: std.builtin.OptimizeM
|
||||
// On macos rglfw.c include Objective-C files.
|
||||
try raylib_flags_arr.append("-ObjC");
|
||||
addCSourceFilesVersioned(raylib, &.{
|
||||
try join2(gpa, relative, "rglfw.c"),
|
||||
try join2(gpa, srcdir, "rglfw.c"),
|
||||
}, raylib_flags_arr.items);
|
||||
raylib.linkFramework("Foundation");
|
||||
raylib.linkFramework("CoreServices");
|
||||
@ -251,14 +253,23 @@ fn getOsTagVersioned(target: anytype) std.Target.Os.Tag {
|
||||
}
|
||||
}
|
||||
|
||||
fn addCSourceFilesVersioned(exe: *std.Build.Step.Compile, files: []const []const u8, flags: []const []const u8) void {
|
||||
fn addCSourceFilesVersioned(
|
||||
exe: *std.Build.Step.Compile,
|
||||
files: []const []const u8,
|
||||
flags: []const []const u8,
|
||||
) void {
|
||||
//- HACK(cabarger): I hate this so much!!!
|
||||
if (comptime builtin.zig_version.minor >= 12) {
|
||||
exe.addCSourceFiles(.{
|
||||
.files = files,
|
||||
.flags = flags,
|
||||
});
|
||||
} else {
|
||||
for (files) |file| {
|
||||
exe.addCSourceFile(.{
|
||||
.file = .{ .path = file },
|
||||
.flags = flags,
|
||||
});
|
||||
}
|
||||
} else if (comptime builtin.zig_version.minor == 11) {
|
||||
exe.addCSourceFiles(files, flags);
|
||||
} else {
|
||||
@compileError("Expected zig version 11 or 12");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,15 +84,6 @@
|
||||
#include "GLFW/glfw3native.h" // Required for: glfwGetCocoaWindow()
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Defines and Macros
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: HACK: Added flag if not provided by GLFW when using external library
|
||||
// Latest GLFW release (GLFW 3.3.8) does not implement this flag, it was added for 3.4.0-dev
|
||||
#if !defined(GLFW_MOUSE_PASSTHROUGH)
|
||||
#define GLFW_MOUSE_PASSTHROUGH 0x0002000D
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user