diff --git a/cmake/linux-arm.cmake b/cmake/linux-arm.cmake new file mode 100644 index 0000000..a973557 --- /dev/null +++ b/cmake/linux-arm.cmake @@ -0,0 +1,13 @@ +# QUIK Toolchain file for Linux-arm systems. +# Copyright (C) 2023 + +set(CMAKE_SYSTEM_NAME Linux) + +set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) +set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) + +set(CMAKE_FIND_ROOT_PATH "/usr/arm-linux-gnueabihf") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/linux-arm64.cmake b/cmake/linux-arm64.cmake new file mode 100644 index 0000000..5008591 --- /dev/null +++ b/cmake/linux-arm64.cmake @@ -0,0 +1,13 @@ +# QUIK Toolchain file for Linux-arm64 (aarch64) systems. +# Copyright (C) 2023 + +set(CMAKE_SYSTEM_NAME Linux) + +set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc) +set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++) + +set(CMAKE_FIND_ROOT_PATH "/usr/aarch64-linux-gnu") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/linux-x64.cmake b/cmake/linux-x64.cmake new file mode 100644 index 0000000..1366483 --- /dev/null +++ b/cmake/linux-x64.cmake @@ -0,0 +1,9 @@ +# QUIK Toolchain file for Linux-x64 (amd64) systems. +# Copyright (C) 2023 + +set(CMAKE_SYSTEM_NAME Linux) + +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_COMPILER g++) + +add_compile_options(-m64) diff --git a/cmake/linux-x86.cmake b/cmake/linux-x86.cmake new file mode 100644 index 0000000..2f2a27b --- /dev/null +++ b/cmake/linux-x86.cmake @@ -0,0 +1,14 @@ +# QUIK Toolchain file for Linux-x86 (i386) systems. +# Copyright (C) 2023 + +set(CMAKE_SYSTEM_NAME Linux) + +set(CMAKE_C_COMPILER i686-linux-gnu-gcc) +set(CMAKE_CXX_COMPILER i686-linux-gnu-g++) + +add_compile_options(-m32 -march=i686) + +set(CMAKE_FIND_ROOT_PATH "/usr/i686-linux-gnu") +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/osx-arm64.cmake b/cmake/osx-arm64.cmake new file mode 100644 index 0000000..b708f77 --- /dev/null +++ b/cmake/osx-arm64.cmake @@ -0,0 +1,14 @@ +# QUIK Toolchain file for OSX-ARM64 systems. +# Copyright (C) 2024 + +set(CMAKE_SYSTEM_NAME OSX) + +set(CMAKE_C_COMPILER aarch64-apple-darwin23-clang) +set(CMAKE_CXX_COMPILER aarch64-apple-darwin23-clang++) + +set(CMAKE_FIND_ROOT_PATH "/usr/local/SDK/MacOSX14.0.sdk/usr" + "/usr/local/SDK/MacOSX14.0.sdk/System") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/osx-x64.cmake b/cmake/osx-x64.cmake new file mode 100644 index 0000000..5af58d8 --- /dev/null +++ b/cmake/osx-x64.cmake @@ -0,0 +1,14 @@ +# QUIK Toolchain file for OSX-ARM64 systems. +# Copyright (C) 2024 + +set(CMAKE_SYSTEM_NAME OSX) + +set(CMAKE_C_COMPILER x86_64-apple-darwin23-clang) +set(CMAKE_CXX_COMPILER x86_64-apple-darwin23-clang++) + +set(CMAKE_FIND_ROOT_PATH "/usr/local/SDK/MacOSX14.0.sdk/usr" + "/usr/local/SDK/MacOSX14.0.sdk/System") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/win-x64.cmake b/cmake/win-x64.cmake new file mode 100644 index 0000000..7224a0d --- /dev/null +++ b/cmake/win-x64.cmake @@ -0,0 +1,14 @@ +# QUIK Toolchain file for Windows-x64 systems. +# Copyright (C) 2023 + +set(CMAKE_SYSTEM_NAME Windows) + +set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) +set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) + +set(CMAKE_FIND_ROOT_PATH "/usr/x86_64-w64-mingw32") +add_compile_options(-m64) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/win-x86.cmake b/cmake/win-x86.cmake new file mode 100644 index 0000000..1808cc4 --- /dev/null +++ b/cmake/win-x86.cmake @@ -0,0 +1,14 @@ +# QUIK Toolchain file for Windows-x86 systems. +# Copyright (C) 2023 + +set(CMAKE_SYSTEM_NAME Windows) + +set(CMAKE_C_COMPILER i686-w64-mingw32-gcc) +set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++) + +set(CMAKE_FIND_ROOT_PATH "/usr/i686-w64-mingw32") +add_compile_options(-m32) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/include/quik_common.h b/include/quik_common.h new file mode 100644 index 0000000..055f48c --- /dev/null +++ b/include/quik_common.h @@ -0,0 +1,52 @@ +#ifndef _QUIK_COMMON_H_ +#define _QUIK_COMMON_H_ + +#include "stdlib.h" + +#if __GNUC__ || _MSC_VER + #define __QUIK_FUNCTION__ __FUNCTION__ +#else + #define __QUIK_FUNCTION__ NULL +#endif + +#if WIN32 || _MSC_VER > 0 || __MINGW__ + #define QEXTERN __declspec(dllexport) +#else + #define QEXTERN +#endif + +/** + * @brief Callback for failed assert function for QUIK redist libraries. + * @param[in] expr The expression that failed. + * @param[in] file The failing file (if available) + * @param[in] line The failing line number (if available) + * @param[in] func The failing function (if available) +*/ +typedef void (*quik_failed_assert_cb_t)(const char *expr, const char *file, int line, const char* func); + +#define DECLARE_ASSERT_CB(NAME) \ + QEXTERN quik_failed_assert_cb_t NAME##_failed_assert +#define DECLARE_ASSERT_STORE(NAME) \ + QEXTERN void NAME##_failed_assert_store(quik_failed_assert_cb_t cb) + +#define DEFINE_ASSERT_CB(NAME) \ + quik_failed_assert_cb_t NAME##_failed_assert +#define DEFINE_ASSERT_STORE(NAME) \ + void NAME##_failed_assert_store(quik_failed_assert_cb_t cb) { \ + NAME##_failed_assert = cb != NULL ? cb : quik_default_assert; \ + } + +#define QUIK_DECLARE_LIB(NAME) \ + DECLARE_ASSERT_CB(NAME); \ + DECLARE_ASSERT_STORE(NAME); + +#define QUIK_DEFINE_LIB(NAME) \ + DEFINE_ASSERT_CB(NAME); \ + DEFINE_ASSERT_STORE(NAME); + +inline static void quik_default_assert(const char *expr, const char *file, int line, const char *function) +{ + abort(); +} + +#endif diff --git a/sh/.gitattributes b/sh/.gitattributes new file mode 100644 index 0000000..f7a4cb0 --- /dev/null +++ b/sh/.gitattributes @@ -0,0 +1 @@ +*.sh text eof=lf \ No newline at end of file diff --git a/sh/publish.sh b/sh/publish.sh new file mode 100644 index 0000000..40d69d0 --- /dev/null +++ b/sh/publish.sh @@ -0,0 +1,18 @@ +#!/bin/bash +if [-z "$1"] +then + $1 = $(dirname "$0") +fi + +if [ -z "$QUIK_API_KEY" ] +then + echo "Please define QUIK_API_KEY" + exit 1 +fi + +cd $1 +dotnet nuget add source \ + -n QUIK -u themixedupstuff -p "$QUIK_API_KEY" \ + --store-password-in-clear-text \ + https://git.mixedup.dev/api/packages/QUIK/nuget/index.json +dotnet nuget push -s QUIK bin/*/*.nupkg diff --git a/sh/quik_build_native.sh b/sh/quik_build_native.sh new file mode 100644 index 0000000..ca6cf16 --- /dev/null +++ b/sh/quik_build_native.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# $1 Source path of the project. +# $2 Target architecture list. +# DST is the destination directory. +# NOINSTALL = 1 to skip installing. + +SRC=$1 +ARCHS=$2 + +if [ -z "$SRC" ] +then + echo You need to provide a source path. + return +fi + +if [ -z "$ARCHS" ] +then + ARCHS="linux-arm linux-arm64 linux-x64 win-x64 win-x86" +fi + +if [ -z "$DST" ] +then + DST=$PWD +fi + +if [ -z "$CMAKE_DIR"] +then + CMAKE_DIR="$SRC/Quik.Common/cmake" +fi + +for ARCH in $ARCHS; do + # Output directory. + PREFIX=$DST/runtimes/$ARCH/native + # Build directory. + BUILD=$DST/out/$ARCH + # Cmake toolchain file. + TOOLCHAIN=$CMAKE_DIR/$ARCH.cmake + + # Create directories. + mkdir -p $PREFIX $BUILD + # Configure CMAKE. + cmake -B $BUILD -S $SRC \ + -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_FLAGS=-static-libgcc \ + -DCMAKE_CXX_FLAGS=-static-libgcc \ + -DCMAKE_INSTALL_PREFIX=$PREFIX \ + -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN \ + $QUIK_ADDITIONAL_CMAKE + + # Build and install. + ninja -C $BUILD all + + if [ ! $NOINSTALL ] + then + ninja -C $BUILD install + fi +done