Skip to content

Commit

Permalink
c-API: fix a whole bunch of build regressions
Browse files Browse the repository at this point in the history
 * disable c-api for ubsan build to omit linking error in zxing-c-test
 * don't include zxing-c.* in build with BUILD_C_API=OFF
 * fix winrt msvc complaint about -1u
 * make stbi_image not include math.h -> no more -lm dependency
  • Loading branch information
axxel committed Jan 12, 2024
1 parent 9366dc1 commit b8cfdad
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ jobs:
run: cmake -E make_directory ${{runner.workspace}}/build

- name: Configure
run: cmake -S $GITHUB_WORKSPACE -B ${{runner.workspace}}/build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_BLACKBOX_TESTS=ON -DBUILD_UNIT_TESTS=ON -DBUILD_PYTHON_MODULE=OFF -DBUILD_C_API=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-march=native -fsanitize=address,undefined -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer"
run: >
cmake -S $GITHUB_WORKSPACE -B ${{runner.workspace}}/build -DCMAKE_BUILD_TYPE=RelWithDebInfo
-DBUILD_BLACKBOX_TESTS=ON -DBUILD_UNIT_TESTS=ON -DBUILD_PYTHON_MODULE=OFF -DBUILD_C_API=OFF
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_CXX_FLAGS="-march=native -fsanitize=address,undefined -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer"
- name: Build
run: cmake --build ${{runner.workspace}}/build -j8
Expand Down Expand Up @@ -175,7 +179,11 @@ jobs:

- name: Configure CMake
shell: cmd
run: cmake -S ${{github.workspace}}/wrappers/winrt -B ${{runner.workspace}}/build -A ARM64 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0 -DCMAKE_BUILD_TYPE=Release -DBUILD_WINRT_LIB=ON -DBUILD_EXAMPLES=OFF -DBUILD_BLACKBOX_TESTS=OFF -DEXTENSION_SDK_OUTPUT=dist/UAP/v0.8.0.0/ExtensionSDKs/ZXingWinRT/1.0.0.0
run: >
cmake -S ${{github.workspace}}/wrappers/winrt -B ${{runner.workspace}}/build -A ARM64
-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0 -DCMAKE_BUILD_TYPE=Release
-DBUILD_WINRT_LIB=ON -DBUILD_EXAMPLES=OFF -DBUILD_BLACKBOX_TESTS=OFF
-DEXTENSION_SDK_OUTPUT=dist/UAP/v0.8.0.0/ExtensionSDKs/ZXingWinRT/1.0.0.0
- name: Build
shell: cmd
Expand Down
6 changes: 3 additions & 3 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ if (BUILD_READERS)
src/ThresholdBinarizer.h
src/WhiteRectDetector.h
src/WhiteRectDetector.cpp
../wrappers/c/zxing-c.h
../wrappers/c/zxing-c.cpp
$<$<BOOL:${BUILD_C_API}>:${CMAKE_SOURCE_DIR}/wrappers/c/zxing-c.h>
$<$<BOOL:${BUILD_C_API}>:${CMAKE_SOURCE_DIR}/wrappers/c/zxing-c.cpp>
)
endif()
if (BUILD_WRITERS)
Expand All @@ -165,7 +165,6 @@ set (PUBLIC_HEADERS
src/TextUtfEncoding.h # [[deprecated]]
src/ZXAlgorithms.h
src/ZXConfig.h
../wrappers/c/zxing-c.h
)
if (BUILD_READERS)
set (PUBLIC_HEADERS ${PUBLIC_HEADERS}
Expand All @@ -179,6 +178,7 @@ if (BUILD_READERS)
src/ReaderOptions.h
src/Result.h
src/StructuredAppend.h
$<$<BOOL:${BUILD_C_API}>:${CMAKE_SOURCE_DIR}/wrappers/c/zxing-c.h>
)
endif()
if (BUILD_WRITERS)
Expand Down
2 changes: 1 addition & 1 deletion wrappers/c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ zxing_add_package_stb()

if (BUILD_READERS)
add_executable (zxing-c-test zxing-c-test.c)
target_link_libraries (zxing-c-test ZXing::ZXing stb::stb m)
target_link_libraries (zxing-c-test ZXing::ZXing stb::stb)
add_test(NAME zxing-c-test COMMAND zxing-c-test ${CMAKE_SOURCE_DIR}/test/samples/qrcode-1/1.png)
endif()
2 changes: 2 additions & 0 deletions wrappers/c/zxing-c-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <stdlib.h>

#define STB_IMAGE_IMPLEMENTATION
#define STBI_NO_LINEAR // prevent dependency on -lm
#define STBI_NO_HDR
#include <stb_image.h>

int usage(char* pname)
Expand Down
2 changes: 1 addition & 1 deletion wrappers/c/zxing-c.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ typedef enum
| zxing_BarcodeFormat_RMQRCode,
zxing_BarcodeFormat_Any = zxing_BarcodeFormat_LinearCodes | zxing_BarcodeFormat_MatrixCodes,

zxing_BarcodeFormat_Invalid = -1u /* return value when BarcodeFormatsFromString() throws */
zxing_BarcodeFormat_Invalid = 0xFFFFFFFFu /* return value when BarcodeFormatsFromString() throws */
} zxing_BarcodeFormat;

typedef zxing_BarcodeFormat zxing_BarcodeFormats;
Expand Down

0 comments on commit b8cfdad

Please sign in to comment.