Module: ImagePackMozjpegSources

Defined in:
ext/image_pack/mozjpeg_sources.rb

Overview

Single source of truth for the vendored MozJPEG runtime file set.

Keep this file free of build-time side effects: it is required by image_pack.gemspec, ext/image_pack/extconf.rb, script/vendor_libs.rb, and packaging tests. Files listed as include templates are copied/packaged because MozJPEG includes them textually from other C/ASM files, but they must not be compiled as standalone translation units.

Constant Summary collapse

VERSION =
"4.1.5"
VERSION_NUMBER =
"4001005"
SHA256 =
"9fcbb7171f6ac383f5b391175d6fb3acde5e64c4c4727274eade84ed0998fcc1"
LICENSE_AND_DOC_FILES =
%w[
  LICENSE.md
  README.md
  README-mozilla.txt
  README-turbo.txt
  README.ijg
].freeze
TOPLEVEL_C_SOURCES =

Files compiled as standalone translation units in the scalar/runtime core.

%w[
  jcapimin.c
  jcapistd.c
  jccoefct.c
  jccolor.c
  jcdctmgr.c
  jchuff.c
  jcext.c
  jcicc.c
  jcinit.c
  jcmainct.c
  jcmarker.c
  jcmaster.c
  jcomapi.c
  jcparam.c
  jcphuff.c
  jcprepct.c
  jcsample.c
  jctrans.c
  jdapimin.c
  jdapistd.c
  jdatadst.c
  jdatasrc.c
  jdcoefct.c
  jdcolor.c
  jddctmgr.c
  jdhuff.c
  jdicc.c
  jdinput.c
  jdmainct.c
  jdmarker.c
  jdmaster.c
  jdmerge.c
  jdphuff.c
  jdpostct.c
  jdsample.c
  jdtrans.c
  jerror.c
  jfdctflt.c
  jfdctfst.c
  jfdctint.c
  jidctflt.c
  jidctfst.c
  jidctint.c
  jidctred.c
  jquant1.c
  jquant2.c
  jutils.c
  jmemmgr.c
  jmemnobs.c
].freeze
TOPLEVEL_INCLUDE_TEMPLATES =

MozJPEG/libjpeg-turbo uses these top-level .c files as textual include templates. They are required at compile time but must not be added to $srcs.

%w[
  jccolext.c
  jdcol565.c
  jdcolext.c
  jdmrg565.c
  jdmrgext.c
  jstdhuff.c
].freeze
TOPLEVEL_RUNTIME_C_FILES =
(TOPLEVEL_C_SOURCES + TOPLEVEL_INCLUDE_TEMPLATES + %w[jsimd_none.c]).freeze
NEON_AARCH64_C_SOURCES =
%w[
  simd/arm/aarch64/jsimd.c
  simd/arm/aarch64/jchuff-neon.c
  simd/arm/jccolor-neon.c
  simd/arm/jcgray-neon.c
  simd/arm/jcphuff-neon.c
  simd/arm/jcsample-neon.c
  simd/arm/jdcolor-neon.c
  simd/arm/jdmerge-neon.c
  simd/arm/jdsample-neon.c
  simd/arm/jfdctfst-neon.c
  simd/arm/jfdctint-neon.c
  simd/arm/jidctfst-neon.c
  simd/arm/jidctint-neon.c
  simd/arm/jidctred-neon.c
  simd/arm/jquanti-neon.c
].freeze
NEON_AARCH64_INCLUDE_TEMPLATES =

AArch64 NEON C include templates required by the NEON sources above.

%w[
  simd/arm/aarch64/jccolext-neon.c
  simd/arm/jcgryext-neon.c
  simd/arm/jdcolext-neon.c
  simd/arm/jdmrgext-neon.c
].freeze
X86_64_C_SOURCES =
%w[
  simd/x86_64/jsimd.c
].freeze
X86_64_ASM_SOURCES =
%w[
  simd/x86_64/jsimdcpu.asm
  simd/x86_64/jfdctflt-sse.asm
  simd/x86_64/jccolor-sse2.asm
  simd/x86_64/jcgray-sse2.asm
  simd/x86_64/jchuff-sse2.asm
  simd/x86_64/jcphuff-sse2.asm
  simd/x86_64/jcsample-sse2.asm
  simd/x86_64/jdcolor-sse2.asm
  simd/x86_64/jdmerge-sse2.asm
  simd/x86_64/jdsample-sse2.asm
  simd/x86_64/jfdctfst-sse2.asm
  simd/x86_64/jfdctint-sse2.asm
  simd/x86_64/jidctflt-sse2.asm
  simd/x86_64/jidctfst-sse2.asm
  simd/x86_64/jidctint-sse2.asm
  simd/x86_64/jidctred-sse2.asm
  simd/x86_64/jquantf-sse2.asm
  simd/x86_64/jquanti-sse2.asm
  simd/x86_64/jccolor-avx2.asm
  simd/x86_64/jcgray-avx2.asm
  simd/x86_64/jcsample-avx2.asm
  simd/x86_64/jdcolor-avx2.asm
  simd/x86_64/jdmerge-avx2.asm
  simd/x86_64/jdsample-avx2.asm
  simd/x86_64/jfdctint-avx2.asm
  simd/x86_64/jidctint-avx2.asm
  simd/x86_64/jquanti-avx2.asm
].freeze
GEM_RUNTIME_C_SOURCES =

.c files that must be shipped in the gem. This includes compile units and textual include templates; extconf decides which compile units to add to $srcs.

(
  TOPLEVEL_RUNTIME_C_FILES +
  NEON_AARCH64_C_SOURCES +
  NEON_AARCH64_INCLUDE_TEMPLATES +
  X86_64_C_SOURCES
).freeze
TOPLEVEL_EXTENSIONS =
%w[.h .in .txt .md].freeze
SIMD_EXTENSIONS =

‘.in` matters under simd/ too: simd/arm/neon-compat.h.in is the CMake-generated header template processed by extconf.rb at build time.

%w[.c .h .asm .inc .S .in].freeze

Class Method Summary collapse

Class Method Details

.mozjpeg_file?(relative_path) ⇒ Boolean

Returns:

  • (Boolean)


164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'ext/image_pack/mozjpeg_sources.rb', line 164

def self.mozjpeg_file?(relative_path)
  return false if relative_path.empty?

  if relative_path.include?("/")
    return false unless relative_path.start_with?("simd/")

    return SIMD_EXTENSIONS.include?(File.extname(relative_path))
  end

  basename = File.basename(relative_path)
  LICENSE_AND_DOC_FILES.include?(basename) ||
    TOPLEVEL_RUNTIME_C_FILES.include?(basename) ||
    TOPLEVEL_EXTENSIONS.include?(File.extname(basename))
end