diff --git a/.gitignore b/.gitignore index f0e2480..be8720d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ bin build *~ .vs +result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..0380ccd --- /dev/null +++ b/flake.lock @@ -0,0 +1,24 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1789724158, + "narHash": "sha256-a+eLlfZMyiiI5LIQ946grNITLv+FMldenpy02jbE3NI=", + "rev": "0a3468a402c449992505b6a9fc5b06580141b750", + "type": "tarball", + "url": "https://releases.nixos.org/nixpkgs/nixpkgs-26.11pre1075779.0a3468a402c4/nixexprs.tar.zst" + }, + "original": { + "type": "tarball", + "url": "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.zst" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..e7d00cc --- /dev/null +++ b/flake.nix @@ -0,0 +1,56 @@ +{ + description = "Touhou Toolkit"; + + inputs = { + nixpkgs.url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.zst"; + }; + + outputs = inputs: { + packages = builtins.mapAttrs (system: pkgs: let + inherit (pkgs) lib stdenv fetchFromGitHub; + thtypes = fetchFromGitHub { + owner = "thpatch"; + repo = "thtypes"; + rev = "29ed7d6e1db555ad15fd29edcc0763754ad5b764"; + hash = "sha256-j3lrToLuS7SbzzdL3/8uB0nL1z04GtmfmKIC/v37jwI="; + }; + in { + thtk = stdenv.mkDerivation { + pname = "thtk"; + version = "12"; + + src = inputs.self; + + env.NIX_CFLAGS_COMPILE = "-I${thtypes}"; + + nativeBuildInputs = with pkgs; [ + cmake + pkg-config + validatePkgConfig + flex + bison + ]; + + buildInputs = with pkgs; [ + zlib + libpng + ]; + + cmakeFlags = [ + (lib.cmakeBool "WITH_LIBPNG_SOURCE" false) + ]; + + meta = { + description = "Touhou Toolkit"; + homepage = "https://github.com/thpatch/thtk"; + changelog = "https://github.com/thpatch/thtk/releases"; + license = lib.licenses.bsd2; + pkgConfigModules = [ "thtk" ]; + platforms = with lib.platforms; linux ++ windows; + }; + }; + + default = inputs.self.packages.${system}.thtk; + }) inputs.nixpkgs.legacyPackages; + }; +} diff --git a/thtk/CMakeLists.txt b/thtk/CMakeLists.txt index 27379c4..9a6c63a 100644 --- a/thtk/CMakeLists.txt +++ b/thtk/CMakeLists.txt @@ -27,7 +27,7 @@ set_target_properties(thtk PROPERTIES find_package(PkgConfig) if (PKG_CONFIG_FOUND) - configure_file(thtk.pc.in ${CMAKE_CURRENT_BINARY_DIR}/thtk.pc) + configure_file(thtk.pc.in ${CMAKE_CURRENT_BINARY_DIR}/thtk.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/thtk.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) endif() diff --git a/thtk/thtk.pc.in b/thtk/thtk.pc.in index 15526e6..73f8001 100644 --- a/thtk/thtk.pc.in +++ b/thtk/thtk.pc.in @@ -1,7 +1,7 @@ prefix = @CMAKE_INSTALL_PREFIX@ exec_prefix = ${prefix} -includedir = ${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ -libdir = ${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir = @CMAKE_INSTALL_FULL_INCLUDEDIR@ +libdir = @CMAKE_INSTALL_FULL_LIBDIR@ Name: @PROJECT_NAME@ Description: Touhou Toolkit shared library