diff --git a/.envrc.sample b/.envrc.sample new file mode 100644 index 0000000..89acf9a --- /dev/null +++ b/.envrc.sample @@ -0,0 +1,2 @@ +set -a +use flake diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..0e7df68 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,36 @@ +name: main +on: + pull_request: +concurrency: + group: ${{ github.ref }}-${{ github.workflow }} +jobs: + build-linux: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@main + - name: build tileconv + run: | + sudo apt-get update -yqqq + sudo apt-get install -yqqq libsquish-dev zlib1g-dev libimagequant0 libjpeg-turbo + make -j$(npoc) -C tileconv + - uses: actions/upload-artifact@v4 + with: + name: ubuntu-22.04 + path: tileconv/tileconv + if-no-files-found: error + build-nix: + strategy: + matrix: + include: + - os: macos-latest + - os: macos-15-intel + - os: ubuntu-24.04 + - os: ubuntu-24.04-arm + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@main + - uses: cachix/install-nix-action@master + with: + nix_path: nixpkgs=channel:nixos-25.11 + - run: | + nix-build diff --git a/.gitignore b/.gitignore index 6c910e9..ae81ff1 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,7 @@ /Debug /Release /.settings + +.direnv +.envrc +result diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..eba9707 --- /dev/null +++ b/default.nix @@ -0,0 +1,30 @@ +let +nixpkgs_unstable = import (fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-unstable-small") { }; +in +{ pkgs ? nixpkgs_unstable, ... }: +pkgs.stdenv.mkDerivation rec { + name = "tileconv"; + src = ./tileconv; + nativeBuildInputs = with pkgs; [ + gnumake + libjpeg8 + libsquish + libimagequant + zlib + ]; + buildInputs = with pkgs; [ + git + ]; + configurePhase = '' + make clean + mkdir -p $out/bin + ''; + buildPhase = '' + make -j$(nproc) all + cp tileconv $out/bin/tileconv + ''; + installPhase = '' + ls $out + ''; + enableParallelBuilding = true; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..d75632c --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1772864153, + "narHash": "sha256-YANRi2Sb6uUHFy/zhZjC0DmCpYKPMpXQBKj5iRZv6ks=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "8fbd4361b3a128506685a89bb18ff29ff23f6c59", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable-small", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..1acc77b --- /dev/null +++ b/flake.nix @@ -0,0 +1,42 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small"; + }; + outputs = { self, nixpkgs }: + let + systems = [ + "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" + ]; + forEachSystem = f: nixpkgs.lib.genAttrs systems (system: f system); + pkgsFor = nixpkgs.legacyPackages; + in { + devShells = forEachSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + in { + default = pkgs.stdenv.mkDerivation { + name = "tileconv"; + src = ./tileconv; + # Libs + buildInputs = with pkgs; [ + gnumake + libjpeg8 + libsquish + libimagequant + zlib + ]; + # Tools + nativeBuildInputs = with pkgs; [ + direnv + git + ]; + # Env + shellHook = '' + ''; + }; + }); + packages = forEachSystem (system: { + default = pkgsFor.${system}.callPackage ./default.nix { pkgs = import nixpkgs { inherit system; }; }; + }); + }; +} diff --git a/tileconv/Makefile b/tileconv/Makefile index 946c4d1..4cdb25d 100644 --- a/tileconv/Makefile +++ b/tileconv/Makefile @@ -6,7 +6,6 @@ include config.mk CXX ?= g++ CXXFLAGS = -c -Wall -O2 -std=c++11 -msse -mfpmath=sse -I$(ZLIB_INCLUDE) -I$(PNGQUANT_INCLUDE) -I$(SQUISH_INCLUDE) -I$(JPEG_INCLUDE) -LDFLAGS = -L$(ZLIB_LIB) -L$(PNGQUANT_LIB) -L$(SQUISH_LIB) -L$(JPEG_LIB) LIBS = -lz -limagequant -lsquish -ljpeg EXECUTABLE = tileconv @@ -78,5 +77,4 @@ $(EXECUTABLE): $(OBJECTS) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -o $@ clean: - $(RM) $(OBJECTS) -# $(RM) *.o + $(RM) -f *.o diff --git a/tileconv/colorquant.h b/tileconv/colorquant.h index 5bea05a..2a52e8e 100644 --- a/tileconv/colorquant.h +++ b/tileconv/colorquant.h @@ -22,7 +22,7 @@ THE SOFTWARE. #ifndef _COLORQUANT_H_ #define _COLORQUANT_H_ -#include +#include namespace tc { diff --git a/tileconv/config.mk b/tileconv/config.mk index ed73efa..0423126 100644 --- a/tileconv/config.mk +++ b/tileconv/config.mk @@ -1,17 +1,5 @@ # Where to install (Linux/Mac only) INSTALL_DIR ?= /usr/local -# Include paths of the external libraries -ZLIB_INCLUDE ?= ./zlib -SQUISH_INCLUDE ?= ./squish -PNGQUANT_INCLUDE ?= ./pngquant -JPEG_INCLUDE ?= ./jpeg-turbo - -# Paths to the libraries -ZLIB_LIB ?= ./zlib -SQUISH_LIB ?= ./squish -PNGQUANT_LIB ?= ./pngquant/lib -JPEG_LIB ?= ./jpeg-turbo - # Set to 1 when compiling on Windows using Win32 threads USE_WINTHREADS ?= 0 diff --git a/tileconv/jpeg-turbo/remove.me b/tileconv/jpeg-turbo/remove.me deleted file mode 100644 index 301f266..0000000 --- a/tileconv/jpeg-turbo/remove.me +++ /dev/null @@ -1 +0,0 @@ -Place your libjpeg-turbo libraries and includes here! diff --git a/tileconv/pngquant/lib/remove.me b/tileconv/pngquant/lib/remove.me deleted file mode 100644 index 44fa51d..0000000 --- a/tileconv/pngquant/lib/remove.me +++ /dev/null @@ -1 +0,0 @@ -Place your pngquant libraries and includes here! diff --git a/tileconv/squish/remove.me b/tileconv/squish/remove.me deleted file mode 100644 index 0b906dc..0000000 --- a/tileconv/squish/remove.me +++ /dev/null @@ -1 +0,0 @@ -Place your libsquish libraries and includes here! diff --git a/tileconv/tileconv.cpp b/tileconv/tileconv.cpp index 9b59931..559c8cf 100644 --- a/tileconv/tileconv.cpp +++ b/tileconv/tileconv.cpp @@ -278,7 +278,7 @@ bool TileConv::showInfo(const std::string &fileName) noexcept } else if (std::strncmp(sig, Graphics::HEADER_MOS_SIGNATURE, 4) == 0 || std::strncmp(sig, Graphics::HEADER_MOSC_SIGNATURE, 4) == 0) { // Parsing MOS or MOSC file - BytePtr mosData(nullptr, std::default_delete()); + BytePtr mosData(nullptr); bool isMosc = true; uint32_t mosSize; uint16_t width, height, cols, rows; diff --git a/tileconv/tiledata.h b/tileconv/tiledata.h index f88535e..2082da7 100644 --- a/tileconv/tiledata.h +++ b/tileconv/tiledata.h @@ -22,6 +22,7 @@ THE SOFTWARE. #ifndef _TILEDATA_H_ #define _TILEDATA_H_ #include +#include #include "types.h" #include "options.h" diff --git a/tileconv/zlib/remove.me b/tileconv/zlib/remove.me deleted file mode 100644 index 4e01446..0000000 --- a/tileconv/zlib/remove.me +++ /dev/null @@ -1 +0,0 @@ -Place your zlib libraries and includes here!