Create stbi redist.

This commit is contained in:
H. Utku Maden 2023-07-08 13:25:44 +03:00
parent fad876c1b3
commit 7d2dee5a4d
5 changed files with 80 additions and 0 deletions

2
Quik.StbImage.redist/.gitignore vendored Normal file

@ -0,0 +1,2 @@
out
runtimes

@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.0)
project(quik_stbi LANGUAGES C VERSION 1.0)
add_compile_options(-static-libgcc)
add_library(stbi SHARED "quik_stbi.c")
target_include_directories(stbi PRIVATE "../lib")
install(
TARGETS stbi
RUNTIME DESTINATION .
LIBRARY DESTINATION .)

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Quik.StbImage.redist</id>
<version>1.0.0</version>
<authors>STBI Authors, H. Utku Maden</authors>
<owners>utkumaden</owners>
<description>
This is a redistribution of STBI for use with the QUIK project.
Compiled with `STBI_NO_STDIO` and a custom assert function. Call
`quik_stbi_failed_assert_store` to replace.
</description>
<tags>native</tags>
</metadata>
<files>
<file src="runtimes/**" target=""/>
</files>
</package>

@ -0,0 +1,17 @@
#include "quik_stbi.h"
#define STB_IMAGE_IMPLEMENTATION 1
#include "stb/stb_image.h"
quik_failed_assert_cb_t quik_stbi_failed_assert = quik_stbi_failed_assert_default;
void quik_stbi_failed_assert_store(quik_failed_assert_cb_t cb)
{
quik_stbi_failed_assert = cb != NULL ? cb : quik_stbi_failed_assert_default;
}
void quik_stbi_failed_assert_default(const char *expr, const char *file, int line, const char *function)
{
abort();
}

@ -0,0 +1,30 @@
#ifndef _QUIK_STB_CONFIG_H_
#define _QUIK_STB_CONFIG_H_
#include "stddef.h"
#if __GNUC__ || __MSC_VER
#define __QUIK_FUNCTION__ __FUNCTION__
#define QEXTERN extern
#else
#define __QUIK_FUNCTION__ NULL
#endif
/* TODO: Change this declaration so we can export a DLL properly in windows. */
#define STBIDEF QEXTERN
#define STBI_NO_STDIO 1
typedef void (*quik_failed_assert_cb_t)(const char *expr, const char *file, int line, const char* func);
QEXTERN quik_failed_assert_cb_t quik_stbi_failed_assert;
QEXTERN void quik_stbi_failed_assert_store(quik_failed_assert_cb_t cb);
QEXTERN void quik_stbi_failed_assert_default(const char * expr, const char *file, int line, const char *function);
/* Overwrite cstdlib functions so we can get as close as possible to freestanding environment. */
#define STBI_ASSERT(EXPR) do { \
if (!(EXPR)) \
quik_stbi_failed_assert(#EXPR, __FILE__, __LINE__ - 2, __QUIK_FUNCTION__); \
} while(0)
#endif