Skip to content

Commit

Permalink
Fix build on Mingw (KhronosGroup#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 68285b1 commit ad40cf7
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 8 deletions.
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
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 ad40cf7

Please sign in to comment.