diff --git a/.direnv/bin/nix-direnv-reload b/.direnv/bin/nix-direnv-reload new file mode 100755 index 0000000..35da571 --- /dev/null +++ b/.direnv/bin/nix-direnv-reload @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -e +if [[ ! -d "/Users/andrew/personal/Projects/C/image_processor" ]]; then + echo "Cannot find source directory; Did you move it?" + echo "(Looking for "/Users/andrew/personal/Projects/C/image_processor")" + echo 'Cannot force reload with this script - use "direnv reload" manually and then try again' + exit 1 +fi + +# rebuild the cache forcefully +_nix_direnv_force_reload=1 direnv exec "/Users/andrew/personal/Projects/C/image_processor" true + +# Update the mtime for .envrc. +# This will cause direnv to reload again - but without re-building. +touch "/Users/andrew/personal/Projects/C/image_processor/.envrc" + +# Also update the timestamp of whatever profile_rc we have. +# This makes sure that we know we are up to date. +touch -r "/Users/andrew/personal/Projects/C/image_processor/.envrc" "/Users/andrew/personal/Projects/C/image_processor/.direnv"/*.rc diff --git a/.direnv/nix-profile-25.11-dwh1bd8g809r0kgr b/.direnv/nix-profile-25.11-dwh1bd8g809r0kgr new file mode 120000 index 0000000..a931da4 --- /dev/null +++ b/.direnv/nix-profile-25.11-dwh1bd8g809r0kgr @@ -0,0 +1 @@ +/nix/store/yy3zc65ij95wfnap3zqcr44kc4wzwlbq-nix-shell-env \ No newline at end of file diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..1d953f4 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use nix diff --git a/CMakeLists.txt b/CMakeLists.txt index d722ebe..087cc4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,9 +14,10 @@ set(LIB_SOURCES src/imgio.c ) -# find_package(PkgConfig REQUIRED) -find_library(TURBOJPEG_LIB NAMES turbojpeg REQUIRED) -find_path(TURBOJPEG_INCLUDE NAMES turbojpeg.h REQUIRED) +find_package(PkgConfig REQUIRED) +pkg_check_modules(TURBOJPEG REQUIRED IMPORTED_TARGET libturbojpeg) +# find_library(TURBOJPEG_LIB NAMES turbojpeg REQUIRED) +# find_path(TURBOJPEG_INCLUDE NAMES turbojpeg.h REQUIRED) add_library(PROCESSOR STATIC ${LIB_SOURCES}) @@ -28,5 +29,11 @@ target_include_directories(PROCESSOR ${TURBOJPEG_INCLUDE} ) -target_link_libraries(PROCESSOR PUBLIC ${TURBOJPEG_LIB}) +# target_link_libraries(PROCESSOR PUBLIC ${TURBOJPEG_LIB}) +target_link_libraries(PROCESSOR PUBLIC PkgConfig::TURBOJPEG) set_target_properties(PROCESSOR PROPERTIES EXPORT_NAME PROCESSOR) + +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) + add_executable(image_processor src/main.c) # Assuming you have a main.c + target_link_libraries(image_processor PRIVATE PROCESSOR) +endif() diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..1b0b5ad --- /dev/null +++ b/flake.nix @@ -0,0 +1,43 @@ +{ + description = "Image Processor API"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + }; + + outputs = { + self, + nixpkgs, + }: let + supportedSystems = ["aarch64-darwin" "x86_64-darwin" "x86_64-linux"]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + pkgsFor = system: import nixpkgs {inherit system;}; + in { + # This allows other flakes to "consume" this library + packages = forAllSystems (system: let + pkgs = pkgsFor system; + in { + default = pkgs.stdenv.mkDerivation { + pname = "image_processor"; + version = "0.1.0"; + src = ./.; + nativeBuildInputs = [pkgs.cmake pkgs.pkg-config]; + buildInputs = [pkgs.libjpeg_turbo]; + }; + }); + + # This provides the dev environment for the API itself + devShells = forAllSystems (system: let + pkgs = pkgsFor system; + in { + default = pkgs.mkShell { + nativeBuildInputs = [pkgs.cmake pkgs.pkg-config]; + buildInputs = [pkgs.libjpeg_turbo]; + shellHook = '' + export CPATH="${pkgs.libjpeg_turbo.dev}/include:$CPATH" + echo "⚙️ Image Processor API Dev Shell" + ''; + }; + }); + }; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..7af2a4b --- /dev/null +++ b/shell.nix @@ -0,0 +1,14 @@ +{pkgs ? import {}}: +pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + cmake + pkg-config + ]; + buildInputs = with pkgs; [ + libjpeg_turbo + ]; + # This tells pkg-config where the Nix libraries are automatically + shellHook = '' + echo "Image Processor Dev Environment Loaded" + ''; +} diff --git a/src/main.c b/src/main.c index 7cf5540..56f8b58 100644 --- a/src/main.c +++ b/src/main.c @@ -1,9 +1,8 @@ #include -#include -#include "utils.h" -#include "filters.h" +#include "image/utils.h" +#include "image/filters.h" // #include "transformations.h" -#include "imgio.h" +#include "image/imgio.h" int main()