aboutsummaryrefslogtreecommitdiffstats
path: root/common/jpeg/CMakeLists.txt
blob: cd867e72d9dea8ea271c4769f3a3ee8af7ed9e6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#
# Setup
#

cmake_minimum_required(VERSION 2.6)

project(libjpeg-turbo)
set(VERSION 1.0.90)

if(NOT DEFINED WITH_SIMD)
  set(WITH_SIMD 1)
endif()

# Detect whether compiler is 64-bit
if(MSVC AND CMAKE_CL_64)
  set(SIMD_X86_64 1)
  set(64BIT 1)
elseif(CMAKE_SIZEOF_VOID_P MATCHES 8)
  set(SIMD_X86_64 1)
  set(64BIT 1)
endif()

if(64BIT)
  message(STATUS "64-bit build")
else()
  message(STATUS "32-bit build")
endif()

include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/win)


#
# Targets
#

set(JPEG_SOURCES jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.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 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)

if(WITH_SIMD)
  add_definitions(-DWITH_SIMD)
  add_subdirectory(simd)
  if(SIMD_X86_64)
    set(JPEG_SOURCES ${JPEG_SOURCES} simd/jsimd_x86_64.c)
  else()
    set(JPEG_SOURCES ${JPEG_SOURCES} simd/jsimd_i386.c)
  endif()
  # This tells CMake that the "source" files haven't been generated yet
  set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1)
else()
  set(JPEG_SOURCES ${JPEG_SOURCES} jsimd_none.c)
  message(STATUS "Not using SIMD acceleration")
endif()

add_library(jpeg STATIC ${JPEG_SOURCES} ${SIMD_OBJS})
if(WITH_SIMD)
  add_dependencies(jpeg simd)
endif()

add_executable(jpegut jpegut.c turbojpegl.c)
target_link_libraries(jpegut jpeg)

add_executable(jpgtest jpgtest.cxx bmp.c turbojpegl.c)
target_link_libraries(jpgtest jpeg)

add_executable(cjpeg cjpeg.c cdjpeg.c rdbmp.c rdgif.c rdppm.c rdswitch.c
  rdtarga.c)
set_property(TARGET cjpeg PROPERTY COMPILE_FLAGS
  "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED")
target_link_libraries(cjpeg jpeg)

add_executable(djpeg djpeg.c cdjpeg.c rdcolmap.c rdswitch.c wrbmp.c wrgif.c
  wrppm.c wrtarga.c)
set_property(TARGET djpeg PROPERTY COMPILE_FLAGS
  "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED")
target_link_libraries(djpeg jpeg)

add_executable(jpegtran jpegtran.c cdjpeg.c rdswitch.c transupp.c)
target_link_libraries(jpegtran jpeg)


#
# Tests
#

enable_testing()
add_test(jpegut jpegut)
add_test(cjpeg-int cjpeg -dct int -outfile testoutint.jpg ${CMAKE_CURRENT_SOURCE_DIR}/testorig.ppm)
add_test(cjpeg-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgint.jpg testoutint.jpg)
add_test(cjpeg-fast cjpeg -dct fast -opt -outfile testoutfst.jpg ${CMAKE_CURRENT_SOURCE_DIR}/testorig.ppm)
add_test(cjpeg-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgfst.jpg testoutfst.jpg)
add_test(cjpeg-float cjpeg -dct float -outfile testoutflt.jpg ${CMAKE_CURRENT_SOURCE_DIR}/testorig.ppm)
if(WITH_SIMD)
add_test(cjpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgflt.jpg testoutflt.jpg)
else()
add_test(cjpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgflt-nosimd.jpg testoutflt.jpg)
endif()
add_test(djpeg-int djpeg -dct int -fast -ppm -outfile testoutint.ppm ${CMAKE_CURRENT_SOURCE_DIR}/testorig.jpg)
add_test(djpeg-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgint.ppm testoutint.ppm)
add_test(djpeg-fast djpeg -dct fast -ppm -outfile testoutfst.ppm ${CMAKE_CURRENT_SOURCE_DIR}/testorig.jpg)
add_test(djpeg-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgfst.ppm testoutfst.ppm)
add_test(djpeg-float djpeg -dct float -ppm -outfile testoutflt.ppm ${CMAKE_CURRENT_SOURCE_DIR}/testorig.jpg)
if(WITH_SIMD)
add_test(djpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgflt.ppm testoutflt.ppm)
else()
add_test(djpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testorig.ppm testoutflt.ppm)
endif()
add_test(djpeg-256 djpeg -dct int -bmp -colors 256 -outfile testout.bmp  ${CMAKE_CURRENT_SOURCE_DIR}/testorig.jpg)
add_test(djpeg-256-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimg.bmp testout.bmp)
add_test(cjpeg-prog cjpeg -dct int -progressive -outfile testoutp.jpg ${CMAKE_CURRENT_SOURCE_DIR}/testorig.ppm)
add_test(cjpeg-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgp.jpg testoutp.jpg)
add_test(jpegtran-prog jpegtran -outfile testoutt.jpg testoutp.jpg)
add_test(jpegtran-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgint.jpg testoutt.jpg)
span>""); if (StringUtils.isEmpty(passphrase)) { logger.info("Federation passphrase is blank! This server can not be PULLED from."); validPassphrase = false; } if (validPassphrase) { // standard tokens for (FederationToken tokenType : FederationToken.values()) { logger.info(MessageFormat.format("Federation {0} token = {1}", tokenType.name(), gitblit.getFederationToken(tokenType))); } // federation set tokens for (String set : settings.getStrings(Keys.federation.sets)) { logger.info(MessageFormat.format("Federation Set {0} token = {1}", set, gitblit.getFederationToken(set))); } } // Schedule or run the federation executor List<FederationModel> registrations = gitblit.getFederationRegistrations(); if (registrations.size() > 0) { FederationPuller executor = new FederationPuller(registrations); scheduledExecutor.schedule(executor, 1, TimeUnit.MINUTES); } } protected void configureGitDaemon() { int port = settings.getInteger(Keys.git.daemonPort, 0); String bindInterface = settings.getString(Keys.git.daemonBindInterface, "localhost"); if (port > 0) { try { gitDaemon = new GitDaemon(gitblit); gitDaemon.start(); } catch (IOException e) { gitDaemon = null; logger.error(MessageFormat.format("Failed to start Git Daemon on {0}:{1,number,0}", bindInterface, port), e); } } else { logger.info("Git Daemon is disabled."); } } protected void configureSshDaemon() { int port = settings.getInteger(Keys.git.sshPort, 0); String bindInterface = settings.getString(Keys.git.sshBindInterface, "localhost"); if (port > 0) { try { sshDaemon = new SshDaemon(gitblit, workQueue); sshDaemon.start(); } catch (IOException e) { sshDaemon = null; logger.error(MessageFormat.format("Failed to start SSH daemon on {0}:{1,number,0}", bindInterface, port), e); } } } protected void configureFanout() { // startup Fanout PubSub service if (settings.getInteger(Keys.fanout.port, 0) > 0) { String bindInterface = settings.getString(Keys.fanout.bindInterface, null); int port = settings.getInteger(Keys.fanout.port, FanoutService.DEFAULT_PORT); boolean useNio = settings.getBoolean(Keys.fanout.useNio, true); int limit = settings.getInteger(Keys.fanout.connectionLimit, 0); if (useNio) { if (StringUtils.isEmpty(bindInterface)) { fanoutService = new FanoutNioService(port); } else { fanoutService = new FanoutNioService(bindInterface, port); } } else { if (StringUtils.isEmpty(bindInterface)) { fanoutService = new FanoutSocketService(port); } else { fanoutService = new FanoutSocketService(bindInterface, port); } } fanoutService.setConcurrentConnectionLimit(limit); fanoutService.setAllowAllChannelAnnouncements(false); fanoutService.start(); } else { logger.info("Fanout PubSub service is disabled."); } } public String getGitDaemonUrl(HttpServletRequest request, UserModel user, RepositoryModel repository) { if (gitDaemon != null) { String bindInterface = settings.getString(Keys.git.daemonBindInterface, "localhost"); if (bindInterface.equals("localhost") && (!request.getServerName().equals("localhost") && !request.getServerName().equals("127.0.0.1"))) { // git daemon is bound to localhost and the request is from elsewhere return null; } if (user.canClone(repository)) { String hostname = getHostname(request); String url = gitDaemon.formatUrl(hostname, repository.name); return url; } } return null; } public AccessPermission getGitDaemonAccessPermission(UserModel user, RepositoryModel repository) { if (gitDaemon != null && user.canClone(repository)) { AccessPermission gitDaemonPermission = user.getRepositoryPermission(repository).permission; if (gitDaemonPermission.atLeast(AccessPermission.CLONE)) { if (repository.accessRestriction.atLeast(AccessRestrictionType.CLONE)) { // can not authenticate clone via anonymous git protocol gitDaemonPermission = AccessPermission.NONE; } else if (repository.accessRestriction.atLeast(AccessRestrictionType.PUSH)) { // can not authenticate push via anonymous git protocol gitDaemonPermission = AccessPermission.CLONE; } else { // normal user permission } } return gitDaemonPermission; } return AccessPermission.NONE; } public String getSshDaemonUrl(HttpServletRequest request, UserModel user, RepositoryModel repository) { if (user == null || UserModel.ANONYMOUS.equals(user)) { // SSH always requires authentication - anonymous access prohibited return null; } if (sshDaemon != null) { String bindInterface = settings.getString(Keys.git.sshBindInterface, "localhost"); if (bindInterface.equals("localhost") && (!request.getServerName().equals("localhost") && !request.getServerName().equals("127.0.0.1"))) { // ssh daemon is bound to localhost and the request is from elsewhere return null; } if (user.canClone(repository)) { String hostname = getHostname(request); String url = sshDaemon.formatUrl(user.username, hostname, repository.name); return url; } } return null; } /** * Extract the hostname from the canonical url or return the * hostname from the servlet request. * * @param request * @return */ protected String getHostname(HttpServletRequest request) { String hostname = request.getServerName(); String canonicalUrl = gitblit.getSettings().getString(Keys.web.canonicalUrl, null); if (!StringUtils.isEmpty(canonicalUrl)) { try { URI uri = new URI(canonicalUrl); String host = uri.getHost(); if (!StringUtils.isEmpty(host) && !"localhost".equals(host)) { hostname = host; } } catch (Exception e) { } } return hostname; } private class FederationPuller extends FederationPullService { public FederationPuller(FederationModel registration) { super(gitblit, Arrays.asList(registration)); } public FederationPuller(List<FederationModel> registrations) { super(gitblit, registrations); } @Override public void reschedule(FederationModel registration) { // schedule the next pull int mins = TimeUtils.convertFrequencyToMinutes(registration.frequency); registration.nextPull = new Date(System.currentTimeMillis() + (mins * 60 * 1000L)); scheduledExecutor.schedule(new FederationPuller(registration), mins, TimeUnit.MINUTES); logger.info(MessageFormat.format( "Next pull of {0} @ {1} scheduled for {2,date,yyyy-MM-dd HH:mm}", registration.name, registration.url, registration.nextPull)); } } }