From ea2014819d498ee7fd1a68837aef874d0ab74181 Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Tue, 12 Dec 2023 13:08:00 +0100 Subject: [PATCH 01/10] fxing macos libraries location issue --- Makefile | 5 ++-- src/renderer/font.cpp | 57 +++++++++++++++++++++++++++++++++++++++++++ src/renderer/font.h | 37 ++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 src/renderer/font.cpp create mode 100644 src/renderer/font.h diff --git a/Makefile b/Makefile index 7c51147..01200a6 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: maldavid +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/10/04 16:43:41 by maldavid #+# #+# # -# Updated: 2023/12/10 23:15:03 by kbz_8 ### ########.fr # +# Updated: 2023/12/12 13:00:48 by kbz_8 ### ########.fr # # # # **************************************************************************** # @@ -44,7 +44,8 @@ else endif ifeq ($(OS), Darwin) - LDLIBS += -lSDL2 + LDLIBS += -L /opt/homebrew/lib -lSDL2 + CXXFLAGS += -I /opt/homebrew/include endif ifeq ($(DEBUG), true) diff --git a/src/renderer/font.cpp b/src/renderer/font.cpp new file mode 100644 index 0000000..4bab8c2 --- /dev/null +++ b/src/renderer/font.cpp @@ -0,0 +1,57 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* font.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maldavid +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/11 22:06:09 by kbz_8 #+# #+# */ +/* Updated: 2023/12/11 22:31:11 by kbz_8 ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include +#include + +constexpr const int RANGE = 1024; + +namespace mlx +{ + Font::Font(Renderer& renderer, const std::filesystem::path& path, float scale) : non_copyable(), _name(path.string()) + { + std::vector tmp_bitmap(RANGE * RANGE); + std::vector vulkan_bitmap(RANGE * RANGE * 4); + + std::ifstream file(path, std::ios::binary); + if(!file.is_open()) + { + core::error::report(e_kind::error, "Font load : cannot open font file, %s", _name.c_str()); + return; + } + std::ifstream::pos_type fileSize = std::filesystem::file_size(path); + file.seekg(0, std::ios::beg); + std::vector bytes(fileSize); + file.read(reinterpret_cast(bytes.data()), fileSize); + file.close(); + + stbtt_pack_context pc; + stbtt_PackBegin(&pc, tmp_bitmap.data(), RANGE, RANGE, RANGE, 1, nullptr); + stbtt_PackFontRange(&pc, bytes.data(), 0, scale, 32, 96, _cdata.data()); + stbtt_PackEnd(&pc); + for(int i = 0, j = 0; i < RANGE * RANGE; i++, j += 4) + { + vulkan_bitmap[j + 0] = tmp_bitmap[i]; + vulkan_bitmap[j + 1] = tmp_bitmap[i]; + vulkan_bitmap[j + 2] = tmp_bitmap[i]; + vulkan_bitmap[j + 3] = tmp_bitmap[i]; + } + _atlas.create(vulkan_bitmap.data(), RANGE, RANGE, VK_FORMAT_R8G8B8A8_UNORM, "__mlx_texts_pipeline_texture_atlas", true); + _atlas.setDescriptor(renderer.getFragDescriptorSet().duplicate()); + } + + Font::~Font() + { + + } +} diff --git a/src/renderer/font.h b/src/renderer/font.h new file mode 100644 index 0000000..92c3b84 --- /dev/null +++ b/src/renderer/font.h @@ -0,0 +1,37 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* font.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maldavid +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/11 21:17:04 by kbz_8 #+# #+# */ +/* Updated: 2023/12/11 22:31:22 by kbz_8 ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef __MLX_FONT__ +#define __MLX_FONT__ + +#include +#include +#include +#include + +namespace mlx +{ + class Font : public non_copyable + { + public: + Font(class Renderer& renderer, const std::filesystem::path& path, float scale); + inline const std::string& getName() const { return _name; } + ~Font(); + + private: + std::array _cdata; + TextureAtlas _atlas; + std::string _name; + }; +} + +#endif From 843d7f0fe22317cf9f68120e5441545b49c176d7 Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Tue, 12 Dec 2023 13:08:34 +0100 Subject: [PATCH 02/10] removing unused files --- src/renderer/font.cpp | 57 ------------------------------------------- src/renderer/font.h | 37 ---------------------------- 2 files changed, 94 deletions(-) delete mode 100644 src/renderer/font.cpp delete mode 100644 src/renderer/font.h diff --git a/src/renderer/font.cpp b/src/renderer/font.cpp deleted file mode 100644 index 4bab8c2..0000000 --- a/src/renderer/font.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* font.cpp :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maldavid +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/11 22:06:09 by kbz_8 #+# #+# */ -/* Updated: 2023/12/11 22:31:11 by kbz_8 ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include -#include -#include - -constexpr const int RANGE = 1024; - -namespace mlx -{ - Font::Font(Renderer& renderer, const std::filesystem::path& path, float scale) : non_copyable(), _name(path.string()) - { - std::vector tmp_bitmap(RANGE * RANGE); - std::vector vulkan_bitmap(RANGE * RANGE * 4); - - std::ifstream file(path, std::ios::binary); - if(!file.is_open()) - { - core::error::report(e_kind::error, "Font load : cannot open font file, %s", _name.c_str()); - return; - } - std::ifstream::pos_type fileSize = std::filesystem::file_size(path); - file.seekg(0, std::ios::beg); - std::vector bytes(fileSize); - file.read(reinterpret_cast(bytes.data()), fileSize); - file.close(); - - stbtt_pack_context pc; - stbtt_PackBegin(&pc, tmp_bitmap.data(), RANGE, RANGE, RANGE, 1, nullptr); - stbtt_PackFontRange(&pc, bytes.data(), 0, scale, 32, 96, _cdata.data()); - stbtt_PackEnd(&pc); - for(int i = 0, j = 0; i < RANGE * RANGE; i++, j += 4) - { - vulkan_bitmap[j + 0] = tmp_bitmap[i]; - vulkan_bitmap[j + 1] = tmp_bitmap[i]; - vulkan_bitmap[j + 2] = tmp_bitmap[i]; - vulkan_bitmap[j + 3] = tmp_bitmap[i]; - } - _atlas.create(vulkan_bitmap.data(), RANGE, RANGE, VK_FORMAT_R8G8B8A8_UNORM, "__mlx_texts_pipeline_texture_atlas", true); - _atlas.setDescriptor(renderer.getFragDescriptorSet().duplicate()); - } - - Font::~Font() - { - - } -} diff --git a/src/renderer/font.h b/src/renderer/font.h deleted file mode 100644 index 92c3b84..0000000 --- a/src/renderer/font.h +++ /dev/null @@ -1,37 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* font.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maldavid +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/11 21:17:04 by kbz_8 #+# #+# */ -/* Updated: 2023/12/11 22:31:22 by kbz_8 ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef __MLX_FONT__ -#define __MLX_FONT__ - -#include -#include -#include -#include - -namespace mlx -{ - class Font : public non_copyable - { - public: - Font(class Renderer& renderer, const std::filesystem::path& path, float scale); - inline const std::string& getName() const { return _name; } - ~Font(); - - private: - std::array _cdata; - TextureAtlas _atlas; - std::string _name; - }; -} - -#endif From 3c52fd05f3c5f36b526ef3d0a651f1a48771f801 Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Tue, 12 Dec 2023 13:27:19 +0100 Subject: [PATCH 03/10] fixing run file and lib name on macos --- Makefile | 3 ++- test/run.sh | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 01200a6..d32d5e0 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: maldavid +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/10/04 16:43:41 by maldavid #+# #+# # -# Updated: 2023/12/12 13:00:48 by kbz_8 ### ########.fr # +# Updated: 2023/12/12 13:19:33 by kbz_8 ### ########.fr # # # # **************************************************************************** # @@ -46,6 +46,7 @@ endif ifeq ($(OS), Darwin) LDLIBS += -L /opt/homebrew/lib -lSDL2 CXXFLAGS += -I /opt/homebrew/include + NAME = libmlx.dylib endif ifeq ($(DEBUG), true) diff --git a/test/run.sh b/test/run.sh index f3c908d..3b240b9 100755 --- a/test/run.sh +++ b/test/run.sh @@ -1 +1,7 @@ -clang main.c ../libmlx.so -lSDL2 -g && ./a.out +#!/bin/bash + +if [ $(uname -s) = 'Darwin' ]; then + clang main.c ../libmlx.dylib -L /opt/homebrew/lib -lSDL2 -g && ./a.out; +else + clang main.c ../libmlx.so -lSDL2 -g && ./a.out; +fi From 90b1dac0f50e54b42c29677ee2830ec0d4988a11 Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Tue, 12 Dec 2023 15:46:47 +0100 Subject: [PATCH 04/10] adding message when instance init fails --- Makefile | 2 +- src/renderer/core/render_core.cpp | 35 ++++++++++++++++++++++++++++++- src/renderer/core/render_core.h | 3 ++- src/renderer/core/vk_instance.cpp | 4 ++-- 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index d32d5e0..7a97434 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: maldavid +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/10/04 16:43:41 by maldavid #+# #+# # -# Updated: 2023/12/12 13:19:33 by kbz_8 ### ########.fr # +# Updated: 2023/12/12 13:38:08 by kbz_8 ### ########.fr # # # # **************************************************************************** # diff --git a/src/renderer/core/render_core.cpp b/src/renderer/core/render_core.cpp index 669e4c0..c708fd9 100644 --- a/src/renderer/core/render_core.cpp +++ b/src/renderer/core/render_core.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/12/17 23:33:34 by maldavid #+# #+# */ -/* Updated: 2023/12/10 23:14:18 by kbz_8 ### ########.fr */ +/* Updated: 2023/12/12 15:45:26 by kbz_8 ### ########.fr */ /* */ /* ************************************************************************** */ @@ -49,6 +49,39 @@ namespace mlx core::error::report(e_kind::fatal_error, "Vulkan : failed to find suitable memory type"); return std::nullopt; } + + const char* verbaliseResultVk(VkResult result) + { + switch(result) + { + case VK_SUCCESS: return "Success"; + case VK_NOT_READY: return "A fence or query has not yet completed"; + case VK_TIMEOUT: return "A wait operation has not completed in the specified time"; + case VK_EVENT_SET: return "An event is signaled"; + case VK_EVENT_RESET: return "An event is unsignaled"; + case VK_INCOMPLETE: return "A return array was too small for the result"; + case VK_ERROR_OUT_OF_HOST_MEMORY: return "A host memory allocation has failed"; + case VK_ERROR_OUT_OF_DEVICE_MEMORY: return "A device memory allocation has failed"; + case VK_ERROR_INITIALIZATION_FAILED: return "Initialization of an object could not be completed for implementation-specific reasons"; + case VK_ERROR_DEVICE_LOST: return "The logical or physical device has been lost"; + case VK_ERROR_MEMORY_MAP_FAILED: return "Mapping of a memory object has failed"; + case VK_ERROR_LAYER_NOT_PRESENT: return "A requested layer is not present or could not be loaded"; + case VK_ERROR_EXTENSION_NOT_PRESENT: return "A requested extension is not supported"; + case VK_ERROR_FEATURE_NOT_PRESENT: return "A requested feature is not supported"; + case VK_ERROR_INCOMPATIBLE_DRIVER: return "The requested version of Vulkan is not supported by the driver or is otherwise incompatible"; + case VK_ERROR_TOO_MANY_OBJECTS: return "Too many objects of the type have already been created"; + case VK_ERROR_FORMAT_NOT_SUPPORTED: return "A requested format is not supported on this device"; + case VK_ERROR_SURFACE_LOST_KHR: return "A surface is no longer available"; + case VK_SUBOPTIMAL_KHR: return "A swapchain no longer matches the surface properties exactly, but can still be used"; + case VK_ERROR_OUT_OF_DATE_KHR: return "A surface has changed in such a way that it is no longer compatible with the swapchain"; + case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR: return "The display used by a swapchain does not use the same presentable image layout"; + case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR: return "The requested window is already connected to a VkSurfaceKHR, or to some other non-Vulkan API"; + case VK_ERROR_VALIDATION_FAILED_EXT: return "A validation layer found an error"; + + default: return "Unknown Vulkan error"; + } + return nullptr; + } } void Render_Core::init() diff --git a/src/renderer/core/render_core.h b/src/renderer/core/render_core.h index e3fde08..fe4efbc 100644 --- a/src/renderer/core/render_core.h +++ b/src/renderer/core/render_core.h @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/08 19:16:32 by maldavid #+# #+# */ -/* Updated: 2023/12/08 18:53:36 by kbz_8 ### ########.fr */ +/* Updated: 2023/12/12 15:45:39 by kbz_8 ### ########.fr */ /* */ /* ************************************************************************** */ @@ -31,6 +31,7 @@ namespace mlx namespace RCore { std::optional findMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties, bool error = true); + const char* verbaliseResultVk(VkResult result); } #ifdef DEBUG diff --git a/src/renderer/core/vk_instance.cpp b/src/renderer/core/vk_instance.cpp index 226505c..9ee7914 100644 --- a/src/renderer/core/vk_instance.cpp +++ b/src/renderer/core/vk_instance.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/08 19:04:21 by maldavid #+# #+# */ -/* Updated: 2023/11/18 17:21:42 by maldavid ### ########.fr */ +/* Updated: 2023/12/12 15:46:06 by kbz_8 ### ########.fr */ /* */ /* ************************************************************************** */ @@ -54,7 +54,7 @@ namespace mlx VkResult res; if((res = vkCreateInstance(&createInfo, nullptr, &_instance)) != VK_SUCCESS) - core::error::report(e_kind::fatal_error, "Vulkan : failed to create Vulkan instance"); + core::error::report(e_kind::fatal_error, "Vulkan : failed to create Vulkan instance, %s", RCore::verbaliseResultVk(res)); volkLoadInstance(_instance); #ifdef DEBUG core::error::report(e_kind::message, "Vulkan : created new instance"); From 7786b07eb87493472cbdf7e3d8e25ffbaee66a88 Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Tue, 12 Dec 2023 15:53:57 +0100 Subject: [PATCH 05/10] adding message when vk res init fails --- src/renderer/core/vk_device.cpp | 7 ++++--- src/renderer/core/vk_fence.cpp | 7 ++++--- src/renderer/core/vk_semaphore.cpp | 9 +++++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/renderer/core/vk_device.cpp b/src/renderer/core/vk_device.cpp index 08ed842..0322030 100644 --- a/src/renderer/core/vk_device.cpp +++ b/src/renderer/core/vk_device.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/08 19:14:29 by maldavid #+# #+# */ -/* Updated: 2023/11/18 17:22:02 by maldavid ### ########.fr */ +/* Updated: 2023/12/12 15:50:02 by kbz_8 ### ########.fr */ /* */ /* ************************************************************************** */ @@ -56,8 +56,9 @@ namespace mlx createInfo.ppEnabledExtensionNames = deviceExtensions.data(); createInfo.enabledLayerCount = 0; - if(vkCreateDevice(_physicalDevice, &createInfo, nullptr, &_device) != VK_SUCCESS) - core::error::report(e_kind::fatal_error, "Vulkan : failed to create logcal device"); + VkResult res; + if((res = vkCreateDevice(_physicalDevice, &createInfo, nullptr, &_device)) != VK_SUCCESS) + core::error::report(e_kind::fatal_error, "Vulkan : failed to create logcal device, %s", RCore::verbaliseResultVk(res)); #ifdef DEBUG core::error::report(e_kind::message, "Vulkan : created new logical device"); #endif diff --git a/src/renderer/core/vk_fence.cpp b/src/renderer/core/vk_fence.cpp index 3c54d49..8061a6c 100644 --- a/src/renderer/core/vk_fence.cpp +++ b/src/renderer/core/vk_fence.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/04/02 17:53:06 by maldavid #+# #+# */ -/* Updated: 2023/12/10 22:45:21 by kbz_8 ### ########.fr */ +/* Updated: 2023/12/12 15:50:48 by kbz_8 ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,8 +20,9 @@ namespace mlx fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; - if(vkCreateFence(Render_Core::get().getDevice().get(), &fenceInfo, nullptr, &_fence) != VK_SUCCESS) - core::error::report(e_kind::fatal_error, "Vulkan : failed to create CPU synchronization object"); + VkResult res; + if((res = vkCreateFence(Render_Core::get().getDevice().get(), &fenceInfo, nullptr, &_fence)) != VK_SUCCESS) + core::error::report(e_kind::fatal_error, "Vulkan : failed to create CPU synchronization object, %s", RCore::verbaliseResultVk(res)); #ifdef DEBUG core::error::report(e_kind::message, "Vulkan : created new fence"); #endif diff --git a/src/renderer/core/vk_semaphore.cpp b/src/renderer/core/vk_semaphore.cpp index 00f2b07..59234eb 100644 --- a/src/renderer/core/vk_semaphore.cpp +++ b/src/renderer/core/vk_semaphore.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/08 19:01:08 by maldavid #+# #+# */ -/* Updated: 2023/11/18 17:22:29 by maldavid ### ########.fr */ +/* Updated: 2023/12/12 15:51:37 by kbz_8 ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,9 +21,10 @@ namespace mlx VkSemaphoreCreateInfo semaphoreInfo{}; semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; - if( vkCreateSemaphore(Render_Core::get().getDevice().get(), &semaphoreInfo, nullptr, &_imageAvailableSemaphores) != VK_SUCCESS || - vkCreateSemaphore(Render_Core::get().getDevice().get(), &semaphoreInfo, nullptr, &_renderFinishedSemaphores) != VK_SUCCESS) - core::error::report(e_kind::fatal_error, "Vulkan : failed to create GPU synchronization object"); + VkResult res; + if( (res = vkCreateSemaphore(Render_Core::get().getDevice().get(), &semaphoreInfo, nullptr, &_imageAvailableSemaphores)) != VK_SUCCESS || + (res = vkCreateSemaphore(Render_Core::get().getDevice().get(), &semaphoreInfo, nullptr, &_renderFinishedSemaphores)) != VK_SUCCESS) + core::error::report(e_kind::fatal_error, "Vulkan : failed to create GPU synchronization object, %s", RCore::verbaliseResultVk(res)); #ifdef DEBUG core::error::report(e_kind::message, "Vulkan : created new semaphore"); #endif From b60ae54e34cf3d59a4e1b409a7e1612881e7022f Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Tue, 12 Dec 2023 17:47:10 +0100 Subject: [PATCH 06/10] macos debug --- test/run.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/run.sh b/test/run.sh index 3b240b9..674e16f 100755 --- a/test/run.sh +++ b/test/run.sh @@ -1,5 +1,6 @@ #!/bin/bash +echo $(uname -s) if [ $(uname -s) = 'Darwin' ]; then clang main.c ../libmlx.dylib -L /opt/homebrew/lib -lSDL2 -g && ./a.out; else From cf3f16d83203116f982ead7f27458e46aea46f8f Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Tue, 12 Dec 2023 17:58:49 +0100 Subject: [PATCH 07/10] macos debug --- test/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/run.sh b/test/run.sh index 674e16f..bebe337 100755 --- a/test/run.sh +++ b/test/run.sh @@ -1,6 +1,6 @@ #!/bin/bash -echo $(uname -s) +echo "pouic $(uname -s)" if [ $(uname -s) = 'Darwin' ]; then clang main.c ../libmlx.dylib -L /opt/homebrew/lib -lSDL2 -g && ./a.out; else From 6c0d8829a5eec4dfbc3744dc4823fb299167af2a Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Tue, 12 Dec 2023 18:04:27 +0100 Subject: [PATCH 08/10] macos debug --- test/run.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/test/run.sh b/test/run.sh index bebe337..3b240b9 100755 --- a/test/run.sh +++ b/test/run.sh @@ -1,6 +1,5 @@ #!/bin/bash -echo "pouic $(uname -s)" if [ $(uname -s) = 'Darwin' ]; then clang main.c ../libmlx.dylib -L /opt/homebrew/lib -lSDL2 -g && ./a.out; else From f398126e080b3bd78dbc75947a78cc65146cf48b Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Tue, 12 Dec 2023 18:07:58 +0100 Subject: [PATCH 09/10] fixing CI --- .github/workflows/linux_clang.yml | 2 +- .github/workflows/linux_gcc.yml | 2 +- .github/workflows/macos_x86.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/linux_clang.yml b/.github/workflows/linux_clang.yml index 6bd0e30..5611333 100644 --- a/.github/workflows/linux_clang.yml +++ b/.github/workflows/linux_clang.yml @@ -39,4 +39,4 @@ jobs: # Build the test - name: Build Test - run: cd test && clang main.c ../libmlx.so -lSDL2 + run: cd test && bash ./run.sh diff --git a/.github/workflows/linux_gcc.yml b/.github/workflows/linux_gcc.yml index 6030878..559bb71 100644 --- a/.github/workflows/linux_gcc.yml +++ b/.github/workflows/linux_gcc.yml @@ -39,5 +39,5 @@ jobs: # Build the test - name: Build Test - run: cd test && gcc main.c ../libmlx.so -lSDL2 + run: cd test && bash ./run.sh diff --git a/.github/workflows/macos_x86.yml b/.github/workflows/macos_x86.yml index 217d31f..c64da05 100644 --- a/.github/workflows/macos_x86.yml +++ b/.github/workflows/macos_x86.yml @@ -45,5 +45,5 @@ jobs: # Build the test - name: Build Test - run: cd test && clang main.c ../libmlx.so -lSDL2 + run: cd test && bash ./run.sh From c5752f773ed9fc48611e679fa32e94eab778402f Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Tue, 12 Dec 2023 18:12:41 +0100 Subject: [PATCH 10/10] fixing CI --- .github/workflows/linux_clang.yml | 2 +- .github/workflows/linux_gcc.yml | 2 +- .github/workflows/macos_x86.yml | 2 +- test/build.sh | 8 ++++++++ test/run.sh | 7 ++----- 5 files changed, 13 insertions(+), 8 deletions(-) create mode 100755 test/build.sh diff --git a/.github/workflows/linux_clang.yml b/.github/workflows/linux_clang.yml index 5611333..e882a62 100644 --- a/.github/workflows/linux_clang.yml +++ b/.github/workflows/linux_clang.yml @@ -39,4 +39,4 @@ jobs: # Build the test - name: Build Test - run: cd test && bash ./run.sh + run: cd test && bash ./build.sh diff --git a/.github/workflows/linux_gcc.yml b/.github/workflows/linux_gcc.yml index 559bb71..3ababd5 100644 --- a/.github/workflows/linux_gcc.yml +++ b/.github/workflows/linux_gcc.yml @@ -39,5 +39,5 @@ jobs: # Build the test - name: Build Test - run: cd test && bash ./run.sh + run: cd test && bash ./build.sh diff --git a/.github/workflows/macos_x86.yml b/.github/workflows/macos_x86.yml index c64da05..0d1312f 100644 --- a/.github/workflows/macos_x86.yml +++ b/.github/workflows/macos_x86.yml @@ -45,5 +45,5 @@ jobs: # Build the test - name: Build Test - run: cd test && bash ./run.sh + run: cd test && bash ./build.sh diff --git a/test/build.sh b/test/build.sh new file mode 100755 index 0000000..28c509c --- /dev/null +++ b/test/build.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if [ $(uname -s) = 'Darwin' ]; then + clang main.c ../libmlx.dylib -L /opt/homebrew/lib -lSDL2 -g; +else + clang main.c ../libmlx.so -lSDL2 -g; +fi + diff --git a/test/run.sh b/test/run.sh index 3b240b9..993cb20 100755 --- a/test/run.sh +++ b/test/run.sh @@ -1,7 +1,4 @@ #!/bin/bash -if [ $(uname -s) = 'Darwin' ]; then - clang main.c ../libmlx.dylib -L /opt/homebrew/lib -lSDL2 -g && ./a.out; -else - clang main.c ../libmlx.so -lSDL2 -g && ./a.out; -fi +bash ./build.sh +./a.out