Skip to content

Commit

Permalink
Fix build on Mingw (#574)
Browse files Browse the repository at this point in the history
and add Mingw build to Github Actions.
  • Loading branch information
Honeybunch authored May 22, 2022
1 parent 4a52fe4 commit 1f07cb0
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 9 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@ on:

jobs:

mingw:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
with:
# Fetch all history to make sure tags are
# included (used for version creation)
fetch-depth: 0
- uses: seanmiddleditch/gha-setup-ninja@v3
- uses: Honeybunch/setup-mingw@v3
- name: Configure Mingw x64
run: cmake -B build -G "Ninja Multi-Config" -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
- name: Build Mingw x64 Debug
run: cmake --build build --config Debug
- name: Build Mingw x64 RelWithDebInfo
run: cmake --build build --config RelWithDebInfo
- name: Build Mingw x64 Release
run: cmake --build build --config Release

linux:

runs-on: ubuntu-latest
Expand Down
26 changes: 18 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,24 @@ macro(commom_lib_settings lib write)
PUBLIC # only for basisu_c_binding.
BASISU_NO_ITERATOR_DEBUG_LEVEL
)
target_sources(
${lib}
PRIVATE
# The msvs generator automatically sets the needed VCLinker
# option when a .def file is seen in sources.
lib/internalexport.def
$<${write}:lib/internalexport_write.def>
)
# The generator automatically sets the needed VCLinker
# option when a .def file is seen in sources.
# The def files that we add have a different syntax depending on the ABI
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
target_sources(
${lib}
PRIVATE
lib/internalexport_mingw.def
$<${write}:lib/internalexport_write_mingw.def>
)
else()
target_sources(
${lib}
PRIVATE
lib/internalexport.def
$<${write}:lib/internalexport_write.def>
)
endif()
elseif(EMSCRIPTEN)
target_compile_definitions(${lib} PRIVATE
# To reduce size, don't support transcoding to formats not
Expand Down
2 changes: 1 addition & 1 deletion lib/astc_encode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "astc-encoder/Source/astcenc.h"

// Provide pthreads support on windows
#if defined(_WIN32) && !defined(__CYGWIN__)
#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__)

#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
Expand Down
4 changes: 4 additions & 0 deletions lib/filestream.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
typedef unsigned short mode_t;
#endif

#if defined(__MINGW32__)
#define S_IFSOCK 0xC000
#endif

#define KTX_FILE_STREAM_MAX (1 << (sizeof(ktx_off_t) - 1) - 1)

/**
Expand Down
45 changes: 45 additions & 0 deletions lib/internalexport_mingw.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
; Copyright 2019-2020 Mark Callow
; SPDX-License-Identifier: Apache-2.0

; Export internal functions used by internal test programs and the
; validator. Using this file avoids having to decorate those internal
; functions or updating such decorations as the tests evolve. Updating
; this feels less obnoxious.

LIBRARY libktx
EXPORTS
_ZN6basist34basis_get_bytes_per_block_or_pixelENS_25transcoder_texture_formatE
_ZN6basist39basis_transcoder_format_is_uncompressedENS_25transcoder_texture_formatE
_ZN6basist38basis_get_uncompressed_bytes_per_pixelENS_25transcoder_texture_formatE
_ZNK6basist17basisu_transcoder15validate_headerEPKvj
_ZNK6basist17basisu_transcoder16get_total_imagesEPKvj
_ZNK6basist17basisu_transcoder20get_image_level_descEPKvjjjRjS3_S3_
_ZNK6basist17basisu_transcoder14get_image_infoEPKvjRNS_17basisu_image_infoEj
_ZNK6basist17basisu_transcoder20get_image_level_infoEPKvjRNS_23basisu_image_level_infoEjj
_ZN6basist17basisu_transcoder17start_transcodingEPKvj
_ZNK6basist17basisu_transcoder21transcode_image_levelEPKvjjjPvjNS_25transcoder_texture_formatEjjPNS_23basisu_transcoder_stateEj
createDFDUnpacked
createDFDPacked
createDFDCompressed
findMapping
interpretDFD
isProhibitedFormat
isValidFormat
ktxCheckHeader1_
ktxMemStream_construct
ktxMemStream_construct_ro
ktxMemStream_destruct
ktxMemStream_getdata
ktxTexture_calcImageSize
ktxTexture_calcLevelSize
ktxTexture1_Destroy
ktxTexture1_SetImageFromMemory
ktxTexture1_WriteToMemory
ktxTexture1_calcLevelOffset
ktxTexture1_destruct
ktxTexture1_glTypeSize
ktxTexture2_GetImageOffset
ktxTexture2_calcLevelOffset
ktxTexture2_destruct
vk2dfd
vkFormatString
17 changes: 17 additions & 0 deletions lib/internalexport_write_mingw.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
; Copyright 2019-2020 Mark Callow
; SPDX-License-Identifier: Apache-2.0

; Export internal functions used by internal test programs and the
; validator. Using this file avoids having to decorate those internal
; functions or updating such decorations as the tests evolve. Updating
; this feels less obnoxious.

LIBRARY libktx
EXPORTS
_ZN6basisu9ResamplerD1Ev
_ZN6basisu9ResamplerC1EiiiiNS0_11Boundary_OpEffPKcPNS0_12Contrib_ListES5_ffff
_ZN6basisu9Resampler8put_lineEPKf
_ZN6basisu9Resampler8get_lineEv
_Z15swizzle_to_rgbaPhS_jyP9swizzle_e
appendLibId

0 comments on commit 1f07cb0

Please sign in to comment.