add dub file (needs more work)

This commit is contained in:
Matthew 2026-05-19 04:14:38 +10:00
parent aca976d4d9
commit 71ce058596
6 changed files with 85 additions and 15 deletions

View File

@ -1,13 +1,8 @@
#!/bin/bash
set -eu
if [ -z "$1" ]; then
echo "No output parameter named, please pass the build directory to this script."
exit 1
fi
script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
build="$1"
build="$script_dir/build"
if [ -x "$(command -v g++)" ]; then cpp_compiler="g++"; c_compiler="gcc";
elif [ -x "$(command -v clang++)" ]; then cpp_compiler="clang++"; c_compiler="clang";

BIN
dlib-test-library Executable file

Binary file not shown.

View File

@ -1945,10 +1945,10 @@ version(DLIB_TEST) unittest
u8[] data_valid, data_test;
File f = File("../dlib/platform.d", "rb");
File f = File("dlib/platform.d", "rb");
data_valid = f.rawRead(new u8[f.size()]);
data_test = LoadFile(&arena, "../dlib/platform.d");
data_test = LoadFile(&arena, "dlib/platform.d");
assert(data_valid == data_test);
}

78
dub.json Normal file
View File

@ -0,0 +1,78 @@
{
"name": "dlib",
"description": "General purpose library",
"targetType": "sourceLibrary",
"sourcePaths": ["dlib"],
"importPaths": ["dlib"],
"sourceFiles-linux": ["build/libstb.a"],
"sourceFiles-windows": [],
"libs-linux": [
"X11",
"Xfixes",
"SDL3"
],
"dflags-webassembly": [
"-mtriple=wasm32-unknown-unknown-wasm",
"-betterC",
"-vgc",
"-fvisibility=hidden",
"-i=.",
"-i=core",
"-i=std",
"--real-precision=double",
"--Xcc=-DBUILD_WASM",
"-gcc=clang"
],
"libs-windows": [],
"preGenerateCommands-linux": ["./build.sh"],
"subPackages": [
{
"name": "dlib-vulkan",
"description": "Vulkan library for rendering and compute",
"targetType": "sourceLibrary",
"sourcePaths": ["vulkan"],
"importPaths": ["vulkan"],
"sourceFiles-linux": ["build/libvma.a"],
"sourceFiles-windows": [],
"dflags-ldc": ["--Xcc=-DBUILD_VULKAN"],
"dflags-dmd": ["-Xcc=-DBUILD_VULKAN"],
"libs-linux": [
"vulkan",
"stdc++"
],
"libs-windows": [],
"versions": ["BUILD_VULKAN"],
"debugVersions": ["VULKAN_DEBUG"],
"buildTypes": {
"unittest": {
"buildOptions": ["unittests", "debugMode", "debugInfo"],
"versions": ["VULKAN_RENDERER_TEST"]
}
}
},
{
"name": "dlib-assets",
"description": "Asset loading utilities",
"targetType": "sourceLibrary",
"sourceFiles-linux": ["build/libcgltf.a"],
"sourceFiles-windows": [],
"versions": ["BUILD_ASSETS"]
},
{
"name": "dlib-opengl",
"description": "OpenGL bindings/set up utilities",
"targetType": "sourceLibrary",
"sourcePaths": ["opengl"],
"importPaths": ["opengl"],
"libs-linux": ["GL"],
"libs-windows": [],
"versions": ["BUILD_GL"]
}
],
"buildTypes": {
"unittest": {
"buildOptions": ["unittests", "debugMode", "debugInfo"],
"versions": ["DLIB_TEST", "VULKAN_RENDERER_TEST"]
}
}
}

View File

@ -2,9 +2,6 @@ import dlibincludes;
// TODO: fix on js side
alias PFNGLXCREATECONTEXTATTRIBSARBPROC = extern(C) GLXContext function(Display*, GLXFBConfig, GLXContext, int, const int*);
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB;
PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers;
PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers;
PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;

View File

@ -35,7 +35,7 @@ if [ "$1" == "wasm" ]; then
-i=std
-i=.
--real-precision=double
-Xcc=-DBUILD_WASM
--Xcc=-DBUILD_WASM
-gcc=clang
"--of=$out"
)
@ -94,9 +94,9 @@ else
-d-version=VULKAN_RENDERER_TEST
-d-version=DLIB_ASSETS
-d-version=BUILD_GL
-Xcc=-DBUILD_VULKAN
-Xcc=-DBUILD_ASSETS
-Xcc=-DBUILD_GL
--Xcc=-DBUILD_VULKAN
--Xcc=-DBUILD_ASSETS
--Xcc=-DBUILD_GL
)
# Test for compilation