Skip to content

Commit f77a952

Browse files
openKylinBotopenKylinBot
authored andcommitted
Import Upstream version 1.0.2
0 parents  commit f77a952

39 files changed

+5338
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.o
2+
*.a
3+
/woff2_compress
4+
/woff2_decompress
5+
/woff2_info

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "brotli"]
2+
path = brotli
3+
url = https://github.com/google/brotli.git

CMakeLists.txt

Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,285 @@
1+
# Copyright 2017 Igalia S.L. All Rights Reserved.
2+
#
3+
# Distributed under MIT license.
4+
# See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5+
6+
# Ubuntu 12.04 LTS has CMake 2.8.7, and is an important target since
7+
# several CI services, such as Travis and Drone, use it. Solaris 11
8+
# has 2.8.6, and it's not difficult to support if you already have to
9+
# support 2.8.7.
10+
cmake_minimum_required(VERSION 2.8.6)
11+
12+
project(woff2)
13+
14+
include(GNUInstallDirs)
15+
16+
# Build options
17+
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
18+
option(CANONICAL_PREFIXES "Canonical prefixes" OFF)
19+
option(NOISY_LOGGING "Noisy logging" ON)
20+
21+
# Version information
22+
set(WOFF2_VERSION 1.0.2)
23+
24+
# When building shared libraries it is important to set the correct rpath
25+
# See https://cmake.org/Wiki/CMake_RPATH_handling#Always_full_RPATH
26+
set(CMAKE_SKIP_BUILD_RPATH FALSE)
27+
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
28+
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
29+
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_LIBDIR}" isSystemDir)
30+
if ("${isSystemDir}" STREQUAL "-1")
31+
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}")
32+
endif()
33+
34+
# Find Brotli dependencies
35+
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
36+
find_package(BrotliDec)
37+
if (NOT BROTLIDEC_FOUND)
38+
message(FATAL_ERROR "librotlidec is needed to build woff2.")
39+
endif ()
40+
find_package(BrotliEnc)
41+
if (NOT BROTLIENC_FOUND)
42+
message(FATAL_ERROR "librotlienc is needed to build woff2.")
43+
endif ()
44+
45+
# Set compiler flags
46+
if (NOT CANONICAL_PREFIXES)
47+
add_definitions(-no-canonical-prefixes)
48+
endif ()
49+
if (NOISY_LOGGING)
50+
add_definitions(-DFONT_COMPRESSION_BIN)
51+
endif ()
52+
add_definitions(-D__STDC_FORMAT_MACROS)
53+
set(COMMON_FLAGS -fno-omit-frame-pointer)
54+
55+
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
56+
add_definitions(-DOS_MACOSX)
57+
else ()
58+
set(COMMON_FLAGS "${COMMON_FLAG} -fno-omit-frame-pointer")
59+
endif()
60+
61+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAG}")
62+
63+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAG}")
64+
set(CMAKE_CXX_STANDARD 11)
65+
66+
# Set search path for our private/public headers as well as Brotli headers
67+
include_directories("src" "include"
68+
"${BROTLIDEC_INCLUDE_DIRS}" "${BROTLIENC_INCLUDE_DIRS}")
69+
70+
# Common part used by decoder and encoder
71+
add_library(woff2common
72+
src/table_tags.cc
73+
src/variable_length.cc
74+
src/woff2_common.cc)
75+
76+
# WOFF2 Decoder
77+
add_library(woff2dec
78+
src/woff2_dec.cc
79+
src/woff2_out.cc)
80+
target_link_libraries(woff2dec woff2common "${BROTLIDEC_LIBRARIES}")
81+
add_executable(woff2_decompress src/woff2_decompress.cc)
82+
target_link_libraries(woff2_decompress woff2dec)
83+
84+
# WOFF2 Encoder
85+
add_library(woff2enc
86+
src/font.cc
87+
src/glyph.cc
88+
src/normalize.cc
89+
src/transform.cc
90+
src/woff2_enc.cc)
91+
target_link_libraries(woff2enc woff2common "${BROTLIENC_LIBRARIES}")
92+
add_executable(woff2_compress src/woff2_compress.cc)
93+
target_link_libraries(woff2_compress woff2enc)
94+
95+
# WOFF2 info
96+
add_executable(woff2_info src/woff2_info.cc)
97+
target_link_libraries(woff2_info woff2common)
98+
99+
foreach(lib woff2common woff2dec woff2enc)
100+
set_target_properties(${lib} PROPERTIES
101+
SOVERSION ${WOFF2_VERSION}
102+
VERSION ${WOFF2_VERSION}
103+
POSITION_INDEPENDENT_CODE TRUE)
104+
endforeach()
105+
106+
# Fuzzer libraries
107+
add_library(convert_woff2ttf_fuzzer STATIC src/convert_woff2ttf_fuzzer.cc)
108+
target_link_libraries(convert_woff2ttf_fuzzer woff2dec)
109+
add_library(convert_woff2ttf_fuzzer_new_entry STATIC src/convert_woff2ttf_fuzzer_new_entry.cc)
110+
target_link_libraries(convert_woff2ttf_fuzzer_new_entry woff2dec)
111+
112+
# PC files
113+
include(CMakeParseArguments)
114+
115+
function(generate_pkg_config_path outvar path)
116+
string(LENGTH "${path}" path_length)
117+
118+
set(path_args ${ARGV})
119+
list(REMOVE_AT path_args 0 1)
120+
list(LENGTH path_args path_args_remaining)
121+
122+
set("${outvar}" "${path}")
123+
124+
while(path_args_remaining GREATER 1)
125+
list(GET path_args 0 name)
126+
list(GET path_args 1 value)
127+
128+
get_filename_component(value_full "${value}" ABSOLUTE)
129+
string(LENGTH "${value}" value_length)
130+
131+
if(path_length EQUAL value_length AND path STREQUAL value)
132+
set("${outvar}" "\${${name}}")
133+
break()
134+
elseif(path_length GREATER value_length)
135+
# We might be in a subdirectory of the value, but we have to be
136+
# careful about a prefix matching but not being a subdirectory
137+
# (for example, /usr/lib64 is not a subdirectory of /usr/lib).
138+
# We'll do this by making sure the next character is a directory
139+
# separator.
140+
string(SUBSTRING "${path}" ${value_length} 1 sep)
141+
if(sep STREQUAL "/")
142+
string(SUBSTRING "${path}" 0 ${value_length} s)
143+
if(s STREQUAL value)
144+
string(SUBSTRING "${path}" "${value_length}" -1 suffix)
145+
set("${outvar}" "\${${name}}${suffix}")
146+
break()
147+
endif()
148+
endif()
149+
endif()
150+
151+
list(REMOVE_AT path_args 0 1)
152+
list(LENGTH path_args path_args_remaining)
153+
endwhile()
154+
155+
set("${outvar}" "${${outvar}}" PARENT_SCOPE)
156+
endfunction(generate_pkg_config_path)
157+
158+
function(generate_pkg_config output_file)
159+
set (options)
160+
set (oneValueArgs NAME DESCRIPTION URL VERSION PREFIX LIBDIR INCLUDEDIR)
161+
set (multiValueArgs DEPENDS DEPENDS_PRIVATE CFLAGS LIBRARIES)
162+
cmake_parse_arguments(GEN_PKG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
163+
unset (options)
164+
unset (oneValueArgs)
165+
unset (multiValueArgs)
166+
167+
if(NOT GEN_PKG_PREFIX)
168+
set(GEN_PKG_PREFIX "${CMAKE_INSTALL_PREFIX}")
169+
endif()
170+
171+
if(NOT GEN_PKG_LIBDIR)
172+
set(GEN_PKG_LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}")
173+
endif()
174+
generate_pkg_config_path(GEN_PKG_LIBDIR "${GEN_PKG_LIBDIR}"
175+
prefix "${GEN_PKG_PREFIX}")
176+
177+
if(NOT GEN_PKG_INCLUDEDIR)
178+
set(GEN_PKG_INCLUDEDIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
179+
endif()
180+
generate_pkg_config_path(GEN_PKG_INCLUDEDIR "${GEN_PKG_INCLUDEDIR}"
181+
prefix "${GEN_PKG_PREFIX}")
182+
183+
file(WRITE "${output_file}" "prefix=${GEN_PKG_PREFIX}\n")
184+
file(APPEND "${output_file}" "libdir=${GEN_PKG_LIBDIR}\n")
185+
file(APPEND "${output_file}" "includedir=${GEN_PKG_INCLUDEDIR}\n")
186+
file(APPEND "${output_file}" "\n")
187+
188+
if(GEN_PKG_NAME)
189+
file(APPEND "${output_file}" "Name: ${GEN_PKG_NAME}\n")
190+
else()
191+
file(APPEND "${output_file}" "Name: ${CMAKE_PROJECT_NAME}\n")
192+
endif()
193+
194+
if(GEN_PKG_DESCRIPTION)
195+
file(APPEND "${output_file}" "Description: ${GEN_PKG_DESCRIPTION}\n")
196+
endif()
197+
198+
if(GEN_PKG_URL)
199+
file(APPEND "${output_file}" "URL: ${GEN_PKG_URL}\n")
200+
endif()
201+
202+
if(GEN_PKG_VERSION)
203+
file(APPEND "${output_file}" "Version: ${GEN_PKG_VERSION}\n")
204+
endif()
205+
206+
if(GEN_PKG_DEPENDS)
207+
file(APPEND "${output_file}" "Requires: ${GEN_PKG_DEPENDS}\n")
208+
endif()
209+
210+
if(GEN_PKG_DEPENDS_PRIVATE)
211+
file(APPEND "${output_file}" "Requires.private:")
212+
foreach(lib ${GEN_PKG_DEPENDS_PRIVATE})
213+
file(APPEND "${output_file}" " ${lib}")
214+
endforeach()
215+
file(APPEND "${output_file}" "\n")
216+
endif()
217+
218+
if(GEN_PKG_LIBRARIES)
219+
set(libs)
220+
221+
file(APPEND "${output_file}" "Libs: -L\${libdir}")
222+
foreach(lib ${GEN_PKG_LIBRARIES})
223+
file(APPEND "${output_file}" " -l${lib}")
224+
endforeach()
225+
file(APPEND "${output_file}" "\n")
226+
endif()
227+
228+
file(APPEND "${output_file}" "Cflags: -I\${includedir}")
229+
if(GEN_PKG_CFLAGS)
230+
foreach(cflag ${GEN_PKG_CFLAGS})
231+
file(APPEND "${output_file}" " ${cflag}")
232+
endforeach()
233+
endif()
234+
file(APPEND "${output_file}" "\n")
235+
endfunction(generate_pkg_config)
236+
237+
generate_pkg_config ("${CMAKE_CURRENT_BINARY_DIR}/libwoff2common.pc"
238+
NAME libwoff2common
239+
DESCRIPTION "Shared data used by libwoff2 and libwoff2dec libraries"
240+
URL "https://github.com/google/woff2"
241+
VERSION "${WOFF2_VERSION}"
242+
LIBRARIES woff2common)
243+
244+
generate_pkg_config ("${CMAKE_CURRENT_BINARY_DIR}/libwoff2dec.pc"
245+
NAME libwoff2dec
246+
DESCRIPTION "WOFF2 decoder library"
247+
URL "https://github.com/google/woff2"
248+
VERSION "${WOFF2_VERSION}"
249+
DEPENDS libbrotlidec
250+
DEPENDS_PRIVATE libwoff2common
251+
LIBRARIES woff2dec)
252+
253+
generate_pkg_config ("${CMAKE_CURRENT_BINARY_DIR}/libwoff2enc.pc"
254+
NAME libwoff2enc
255+
DESCRIPTION "WOFF2 encoder library"
256+
URL "https://github.com/google/woff2"
257+
VERSION "${WOFF2_VERSION}"
258+
DEPENDS libbrotlienc
259+
DEPENDS_PRIVATE libwoff2common
260+
LIBRARIES woff2enc)
261+
262+
# Installation
263+
if (NOT BUILD_SHARED_LIBS)
264+
install(
265+
TARGETS woff2_decompress woff2_compress woff2_info
266+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
267+
)
268+
endif()
269+
270+
install(
271+
TARGETS woff2common woff2dec woff2enc
272+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
273+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
274+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
275+
)
276+
install(
277+
DIRECTORY include/woff2
278+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
279+
)
280+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libwoff2common.pc"
281+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
282+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libwoff2dec.pc"
283+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
284+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libwoff2enc.pc"
285+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")

CONTRIBUTING.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Want to contribute? Great! First, read this page (including the small print at
2+
the end).
3+
4+
### Before you contribute
5+
Before we can use your code, you must sign the
6+
[Google Individual Contributor License Agreement]
7+
(https://cla.developers.google.com/about/google-individual)
8+
(CLA), which you can do online. The CLA is necessary mainly because you own the
9+
copyright to your changes, even after your contribution becomes part of our
10+
codebase, so we need your permission to use and distribute your code. We also
11+
need to be sure of various other things—for instance that you'll tell us if you
12+
know that your code infringes on other people's patents. You don't have to sign
13+
the CLA until after you've submitted your code for review and a member has
14+
approved it, but you must do it before we can put your code into our codebase.
15+
Before you start working on a larger contribution, you should get in touch with
16+
us first through the issue tracker with your idea so that we can help out and
17+
possibly guide you. Coordinating up front makes it much easier to avoid
18+
frustration later on.
19+
20+
### Code reviews
21+
All submissions, including submissions by project members, require review. We
22+
use Github pull requests for this purpose.
23+
24+
### The small print
25+
Contributions made by corporations are covered by a different agreement than
26+
the one above, the [Software Grant and Corporate Contributor License Agreement]
27+
(https://cla.developers.google.com/about/google-corporate).

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2013-2017 by the WOFF2 Authors.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

0 commit comments

Comments
 (0)