From 72dfb4f05a1403407f81f58a323a1de408995a1e Mon Sep 17 00:00:00 2001 From: geemili Date: Sat, 20 Apr 2024 01:21:58 -0600 Subject: [PATCH] feat: add build.zig --- build.zig | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++ build.zig.zon | 62 ++++++++++++++++++ 2 files changed, 231 insertions(+) create mode 100644 build.zig create mode 100644 build.zig.zon diff --git a/build.zig b/build.zig new file mode 100644 index 000000000..886e920c1 --- /dev/null +++ b/build.zig @@ -0,0 +1,169 @@ +const std = @import("std"); + +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + + const lib = b.addStaticLibrary(.{ + .name = "SDL", + .target = target, + .optimize = optimize, + }); + lib.addIncludePath(.{ .path = "include" }); + lib.addIncludePath(.{ .path = "src" }); + lib.installHeadersDirectoryOptions(.{ + .source_dir = .{ .path = "include/SDL3" }, + .install_dir = .header, + .install_subdir = "SDL3", + }); + lib.addCSourceFiles(.{ + .files = &.{ + "src/SDL.c", + "src/SDL_assert.c", + "src/SDL_error.c", + "src/SDL_guid.c", + "src/SDL_hashtable.c", + "src/SDL_hints.c", + "src/SDL_list.c", + "src/SDL_log.c", + "src/SDL_properties.c", + "src/SDL_utils.c", + + "src/atomic/SDL_atomic.c", + "src/atomic/SDL_spinlock.c", + + "src/audio/SDL_audio.c", + "src/audio/SDL_audiocvt.c", + "src/audio/SDL_audiodev.c", + "src/audio/SDL_audioqueue.c", + "src/audio/SDL_audioresample.c", + "src/audio/SDL_audiotypecvt.c", + "src/audio/SDL_mixer.c", + "src/audio/SDL_wave.c", + + "src/camera/SDL_camera.c", + + "src/core/SDL_core_unsupported.c", + "src/core/SDL_runapp.c", + + "src/cpuinfo/SDL_cpuinfo.c", + + "src/dynapi/SDL_dynapi.c", + + "src/events/SDL_clipboardevents.c", + "src/events/SDL_displayevents.c", + "src/events/SDL_dropevents.c", + "src/events/SDL_events.c", + "src/events/SDL_keyboard.c", + "src/events/SDL_keysym_to_scancode.c", + "src/events/SDL_mouse.c", + "src/events/SDL_pen.c", + "src/events/SDL_quit.c", + "src/events/SDL_scancode_tables.c", + "src/events/SDL_touch.c", + "src/events/SDL_windowevents.c", + "src/events/imKStoUCS.c", + + "src/file/SDL_iostream.c", + + "src/filesystem/SDL_filesystem.c", + + "src/joystick/SDL_gamepad.c", + "src/joystick/SDL_joystick.c", + "src/joystick/SDL_steam_virtual_gamepad.c", + "src/joystick/controller_type.c", + + "src/haptic/SDL_haptic.c", + + "src/hidapi/SDL_hidapi.c", + + "src/libm/e_atan2.c", + "src/libm/e_exp.c", + "src/libm/e_fmod.c", + "src/libm/e_log.c", + "src/libm/e_log10.c", + "src/libm/e_pow.c", + "src/libm/e_rem_pio2.c", + "src/libm/e_sqrt.c", + "src/libm/k_cos.c", + "src/libm/k_rem_pio2.c", + "src/libm/k_sin.c", + "src/libm/k_tan.c", + "src/libm/s_atan.c", + "src/libm/s_copysign.c", + "src/libm/s_cos.c", + "src/libm/s_fabs.c", + "src/libm/s_floor.c", + "src/libm/s_modf.c", + "src/libm/s_scalbn.c", + "src/libm/s_sin.c", + "src/libm/s_tan.c", + + "src/locale/SDL_locale.c", + + "src/main/SDL_main_callbacks.c", + + "src/misc/SDL_url.c", + + "src/power/SDL_power.c", + + "src/render/SDL_d3dmath.c", + "src/render/SDL_render.c", + "src/render/SDL_render_unsupported.c", + "src/render/SDL_yuv_sw.c", + + "src/sensor/SDL_sensor.c", + + "src/stdlib/SDL_crc16.c", + "src/stdlib/SDL_crc32.c", + "src/stdlib/SDL_getenv.c", + "src/stdlib/SDL_iconv.c", + "src/stdlib/SDL_malloc.c", + "src/stdlib/SDL_memcpy.c", + "src/stdlib/SDL_memmove.c", + "src/stdlib/SDL_memset.c", + "src/stdlib/SDL_mslibc.c", + "src/stdlib/SDL_qsort.c", + "src/stdlib/SDL_stdlib.c", + "src/stdlib/SDL_string.c", + "src/stdlib/SDL_strtokr.c", + + "src/storage/SDL_storage.c", + + "src/thread/SDL_thread.c", + + "src/time/SDL_time.c", + + "src/timer/SDL_timer.c", + + "src/video/SDL_RLEaccel.c", + "src/video/SDL_blit.c", + "src/video/SDL_blit_0.c", + "src/video/SDL_blit_1.c", + "src/video/SDL_blit_A.c", + "src/video/SDL_blit_N.c", + "src/video/SDL_blit_auto.c", + "src/video/SDL_blit_copy.c", + "src/video/SDL_blit_slow.c", + "src/video/SDL_bmp.c", + "src/video/SDL_clipboard.c", + "src/video/SDL_egl.c", + "src/video/SDL_fillrect.c", + "src/video/SDL_pixels.c", + "src/video/SDL_rect.c", + "src/video/SDL_stretch.c", + "src/video/SDL_surface.c", + "src/video/SDL_video.c", + "src/video/SDL_video_unsupported.c", + "src/video/SDL_vulkan_utils.c", + "src/video/SDL_yuv.c", + + "src/video/yuv2rgb/yuv_rgb_lsx.c", + "src/video/yuv2rgb/yuv_rgb_sse.c", + "src/video/yuv2rgb/yuv_rgb_std.c", + }, + }); + lib.linkLibC(); + + b.installArtifact(lib); +} diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 000000000..e7907c006 --- /dev/null +++ b/build.zig.zon @@ -0,0 +1,62 @@ +.{ + .name = "SDL", + // This is a [Semantic Version](https://semver.org/). + // In a future version of Zig it will be used for package deduplication. + .version = "3.1.1", + + // This field is optional. + // This is currently advisory only; Zig does not yet do anything + // with this value. + //.minimum_zig_version = "0.11.0", + + // This field is optional. + // Each dependency must either provide a `url` and `hash`, or a `path`. + // `zig build --fetch` can be used to fetch all dependencies of a package, recursively. + // Once all dependencies are fetched, `zig build` no longer requires + // internet connectivity. + .dependencies = .{ + // See `zig fetch --save ` for a command-line interface for adding dependencies. + //.example = .{ + // // When updating this field to a new URL, be sure to delete the corresponding + // // `hash`, otherwise you are communicating that you expect to find the old hash at + // // the new URL. + // .url = "https://example.com/foo.tar.gz", + // + // // This is computed from the file contents of the directory of files that is + // // obtained after fetching `url` and applying the inclusion rules given by + // // `paths`. + // // + // // This field is the source of truth; packages do not come from a `url`; they + // // come from a `hash`. `url` is just one of many possible mirrors for how to + // // obtain a package matching this `hash`. + // // + // // Uses the [multihash](https://multiformats.io/multihash/) format. + // .hash = "...", + // + // // When this is provided, the package is found in a directory relative to the + // // build root. In this case the package's hash is irrelevant and therefore not + // // computed. This field and `url` are mutually exclusive. + // .path = "foo", + //}, + }, + + // Specifies the set of files and directories that are included in this package. + // Only files and directories listed here are included in the `hash` that + // is computed for this package. + // Paths are relative to the build root. Use the empty string (`""`) to refer to + // the build root itself. + // A directory listed here means that all files within, recursively, are included. + .paths = .{ + // This makes *all* files, recursively, included in this package. It is generally + // better to explicitly list the files and directories instead, to insure that + // fetching from tarballs, file system paths, and version control all result + // in the same contents hash. + "", + // For example... + //"build.zig", + //"build.zig.zon", + //"src", + //"LICENSE", + //"README.md", + }, +}