Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use libjpeg-turbo in ext/libjpeg.cmd #1994

Merged
merged 3 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,13 @@ jobs:
-I.\apps\shared -I.\include -I.\third_party\iccjpeg
-external:W0
-external:I.\ext\libpng
-external:I.\ext\libjpeg
-external:I.\ext\libjpeg-turbo
-external:I.\ext\libjpeg-turbo\build.libavif
-external:I.\ext\zlib
-external:I.\build\ext\libpng
-external:I.\build\ext\zlib
/link
build\ext\libjpeg\jpeg.lib
ext\libjpeg-turbo\build.libavif\jpeg-static.lib
build\ext\libpng\libpng16_static.lib
build\ext\zlib\zlibstatic.lib
build\avif.lib
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/ext/gpac
/ext/libargparse
/ext/libjpeg
/ext/libjpeg-turbo
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we delete the /ext/libjpeg line?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I could leave it for now. If users update their local repositories instead of cloning fresh ones, it will avoid an eventual libjpeg entry popping into git status.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing the ext/libjpeg entry in the git status output could remind the user to delete the directory. That seems good.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing the ext/libjpeg entry in the git status output could remind the user to delete the directory.

Good point.
The case I had in mind was switching between the main and v1.0.x branches while keeping both ext/libjpeg and ext/libjpeg-turbo.

That seems good.

Not sure what this refers to.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant it seems good to have the ext/libjpeg entry in the git status output, because it could remind the user to delete the directory.

/ext/libgav1
/ext/libpng
/ext/libwebp
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Fix ID selection for artificial grid alpha item when decoding a grid of tiles
which each have an associated auxiliary alpha image item
(https://crbug.com/oss-fuzz/65657).
* ext/libjpeg.cmd now pulls libjpeg-turbo instead of libjpeg and AVIF_JPEG=LOCAL
now expects the library dependency in ext/libjpeg-turbo/build.libavif.

## [1.0.3] - 2023-12-03

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ if(WIN32)
avif_exclude_safe(minigzip)
endif()
if(AVIF_LOCAL_JPEG)
avif_set_folder_safe(jpeg "ext/libjpeg")
avif_set_folder_safe(JPEG::JPEG "ext/libjpeg-turbo")
endif()
if(AVIF_LOCAL_LIBXML2)
avif_set_folder_safe(xml2 "ext/libxml2")
Expand Down
21 changes: 16 additions & 5 deletions cmake/Modules/LocalJpeg.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
add_subdirectory(${AVIF_SOURCE_DIR}/ext/libjpeg EXCLUDE_FROM_ALL)
set(LIB_DIR "${AVIF_SOURCE_DIR}/ext/libjpeg-turbo/build.libavif")
if(WIN32)
set(LIB_FILENAME "${LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}jpeg-static${CMAKE_STATIC_LIBRARY_SUFFIX}")
wantehchang marked this conversation as resolved.
Show resolved Hide resolved
else()
set(LIB_FILENAME "${LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}jpeg${CMAKE_STATIC_LIBRARY_SUFFIX}")
endif()
if(NOT EXISTS "${LIB_FILENAME}")
message(FATAL_ERROR "libavif: ${LIB_FILENAME} is missing, bailing out")
endif()

set_property(TARGET jpeg PROPERTY AVIF_LOCAL ON)
set(JPEG_INCLUDE_DIR "${AVIF_SOURCE_DIR}/ext/libjpeg")
target_include_directories(jpeg INTERFACE ${JPEG_INCLUDE_DIR})
add_library(JPEG::JPEG STATIC IMPORTED GLOBAL)
set_target_properties(JPEG::JPEG PROPERTIES IMPORTED_LOCATION "${LIB_FILENAME}" AVIF_LOCAL ON)
set(JPEG_INCLUDE_DIR "${AVIF_SOURCE_DIR}/ext/libjpeg-turbo")
target_include_directories(JPEG::JPEG INTERFACE "${JPEG_INCLUDE_DIR}")

add_library(JPEG::JPEG ALIAS jpeg)
# Also add the build directory path because it contains jconfig.h,
# which is included by jpeglib.h.
target_include_directories(JPEG::JPEG INTERFACE "${LIB_DIR}")
9 changes: 6 additions & 3 deletions ext/libjpeg.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
: # If you want to use a local build of jpeg, you must clone the repos in this directory first,
: # then enable CMake's AVIF_LOCAL_JPEG.
: # This git tag isn't likely to move much, as libjpeg isn't actively developed anymore.
: # then set CMake's AVIF_JPEG=LOCAL.
: # The git tag below is known to work, and will occasionally be updated. Feel free to use a more recent commit.

: # The odd choice of comment style in this file is to try to share this script between *nix and win32.

git clone --depth 1 https://github.com/joedrago/libjpeg.git
git clone -b 3.0.2 --depth 1 https://github.com/libjpeg-turbo/libjpeg-turbo.git

cmake -S libjpeg-turbo -B libjpeg-turbo/build.libavif -G Ninja -DENABLE_SHARED=OFF -DENABLE_STATIC=ON -DCMAKE_BUILD_TYPE=Release -DWITH_TURBOJPEG=OFF
cmake --build libjpeg-turbo/build.libavif --parallel
2 changes: 1 addition & 1 deletion ext/zlibpng.cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
: # If you want to use a local build of zlib/libpng, you must clone the repos in this directory first,
: # then enable CMake's AVIF_LOCAL_ZLIBPNG.
: # then set CMake's AVIF_ZLIBPNG=LOCAL.
: # The git tags below are known to work, and will occasionally be updated. Feel free to use a more recent commit.

: # The odd choice of comment style in this file is to try to share this script between *nix and win32.
Expand Down
Loading