Skip to content

Commit

Permalink
update docs, support universal binary
Browse files Browse the repository at this point in the history
  • Loading branch information
matyalatte committed Mar 22, 2024
1 parent fc7a077 commit 80714da
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 18 deletions.
1 change: 1 addition & 0 deletions batch_files/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

REM Builds texconv.dll with CMake and Visual Studio.
REM texconv.dll will be generated in ..\
REM The built dll does NOT require vcruntime140.dll

set VS_VERSION=Visual Studio 17 2022

Expand Down
23 changes: 23 additions & 0 deletions batch_files/build_without_vcruntime.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@echo off

REM Builds texconv.dll with CMake and Visual Studio.
REM texconv.dll will be generated in ..\
REM The built dll requires vcruntime140.dll

set VS_VERSION=Visual Studio 17 2022

mkdir %~dp0\..\build
@pushd %~dp0\..\build

cmake -G "%VS_VERSION%"^
-A x64^
-D CMAKE_CONFIGURATION_TYPES=Release^
-D CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL^
-D TEXCONV_USE_ALL=ON^
../

cmake --build . --config Release
copy bin\Release\texconv.dll ..\
@popd

pause
10 changes: 6 additions & 4 deletions docs/Build-on-Unix.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Building Workflow for Ubuntu and MacOS

You can build texconv with Ubuntu and MacOS.
You can build texconv on Linux and macOS.
But please note that there are some limitations.

- Unable to use GPU for conversion.
- Unable to use WIC supported formats (.bmp, .jpg, .png, etc.)
- Unable to use some cmake options to restore removed features.
- Unable to use WIC supported formats (`.bmp`, `.jpg`, `.png`, etc.)
(Or requires libjpeg and libpng to support `.jpg` and `.png`.)

Also, the offical Texconv only supports Windows.
I made sure I can build it with the following platforms and compilers.
Expand Down Expand Up @@ -37,11 +37,13 @@ It will put the file into `./Texconv-Custom-DLL/unix_external/sal/`.
## 3. Build the binary with a shell script

You can build `libtexconv.so` (or `libtexconv.dylib`) with a shell script.
Move to `Texconv-Custom-DLL/shell_scripts` and type `bash build.sh` on the terminal.
Run `bash shell_scripts/build.sh` on the terminal.
(Or run `bash shell_scripts/build_with_jpg_png.sh` to support `.jpg` and `.png`.)
`libtexconv.so` (or `libtexconv.dylib`) will be generated in `./Texconv-Custom-DLL/`.

## 4. Build executables (optional)

If you want an executable, use `build_as_exe.sh` instead of `build.sh`.
(Or use `build_as_exe_with_jpg_png.sh` to support `.jpg` and `.png`.)
`texconv` and `texassemble` will be generated in `./Texconv-Custom-DLL/`.
You can use them on the terminal. (e.g. `./texconv -ft tga -y -o outdir test.dds`)
9 changes: 6 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Texconv-Custom-DLL v0.3.0
# Texconv-Custom-DLL v0.4.0

Cross-platform implementation for [Texconv](https://github.com/microsoft/DirectXTex/wiki/Texconv) and [Texassemble](https://github.com/Microsoft/DirectXTex/wiki/Texassemble).
And you can use it as a DLL (or a shared library).
Expand Down Expand Up @@ -34,10 +34,13 @@ You can download the built binary from [the release page](https://github.com/mat
- `TexconvCustomDLL*-Windows.zip` is for Windows.
- `TexconvCustomDLL*-macOS.tar.bz2` is for macOS (10.15 or later).
- `TexconvCustomDLL*-Linux.tar.bz2` is for Linux with GLIBC 2.27+ and GLIBCXX 3.4.26+.

> Each zip file has a DLL and executables.
> You can copy whichever you want to use to your project.
> (The execuatbles won't refer the DLL.)
> (The executables don't refer the DLL.)
> Linux and macOS builds requrie libjpeg and libpng.
> Or use `*-no-deps.tar.bz2` versions that don't support jpg and png.
> The linux build only supports distributions using GLIBC.
> Build the executable by yourself if you want to use it on unsupported distros.
Expand Down
6 changes: 3 additions & 3 deletions docs/Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ These commands will convert `test.dds` to `outdir/test.tga`.

```bat
mkdir outdir
texconv.exe -ft tga -o outdir -y test.dds
texconv.exe -ft tga -o outdir -y -- test.dds
```

#### for Unix

```shell
mkdir outdir
./texconv -ft tga -o outdir -y test.dds
./texconv -ft tga -o outdir -y -- test.dds
```

## DLL (or shared library)
Expand Down Expand Up @@ -103,7 +103,7 @@ dll = ctypes.cdll.LoadLibrary(dll_path)

# Make arguments
dds_file = 'test.dds'
argv = ['-ft', 'tga', '-o', 'outdir', '-y', dds_file]
argv = ['-ft', 'tga', '-o', 'outdir', '-y', '--', dds_file]
argv = [ctypes.c_wchar_p(arg) for arg in argv]
argv = (ctypes.c_wchar_p*len(argv))(*argv)
err_buf = ctypes.create_unicode_buffer(512)
Expand Down
3 changes: 3 additions & 0 deletions options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ endif()
if(NOT WIN32)
set(TEXCONV_USE_WIC OFF)
set(TEXCONV_NO_GPU_CODEC ON)
set(BUILD_DX11 OFF)
set(BUILD_DX12 OFF)
endif()

if(APPLE)
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
# support macOS 10.15 or later
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "" FORCE)
# Avoid to link to png.h for Mono
Expand Down
2 changes: 0 additions & 2 deletions shell_scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ mkdir build
cd build
cmake \
-D CMAKE_BUILD_TYPE=Release\
-D BUILD_DX11=OFF\
-D BUILD_DX12=OFF\
-D CMAKE_POSITION_INDEPENDENT_CODE=ON\
-D TEXCONV_USE_ALL=ON\
../
Expand Down
2 changes: 0 additions & 2 deletions shell_scripts/build_as_exe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ mkdir build_exe
cd build_exe
cmake \
-D CMAKE_BUILD_TYPE=Release\
-D BUILD_DX11=OFF\
-D BUILD_DX12=OFF\
-D CMAKE_POSITION_INDEPENDENT_CODE=ON\
-D TEXCONV_BUILD_AS_EXE=ON\
-D TEXCONV_USE_ALL=ON\
Expand Down
2 changes: 0 additions & 2 deletions shell_scripts/build_as_exe_with_jpg_png.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ mkdir build_exe
cd build_exe
cmake \
-D CMAKE_BUILD_TYPE=Release\
-D BUILD_DX11=OFF\
-D BUILD_DX12=OFF\
-D CMAKE_POSITION_INDEPENDENT_CODE=ON\
-D TEXCONV_BUILD_AS_EXE=ON\
-D TEXCONV_USE_ALL=ON\
Expand Down
2 changes: 0 additions & 2 deletions shell_scripts/build_with_jpg_png.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ mkdir build
cd build
cmake \
-D CMAKE_BUILD_TYPE=Release\
-D BUILD_DX11=OFF\
-D BUILD_DX12=OFF\
-D CMAKE_POSITION_INDEPENDENT_CODE=ON\
-D TEXCONV_USE_ALL=ON\
-D ENABLE_LIBJPEG_SUPPORT=ON\
Expand Down

0 comments on commit 80714da

Please sign in to comment.