forked from conan-io/conan-center-index
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Improve giflib 5.2.1 #1
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
cmake_minimum_required(VERSION 2.8.12) | ||
project(gif C) | ||
|
||
include(conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
set(SOURCE_FILES | ||
"source_subfolder/dgif_lib.c" | ||
"source_subfolder/egif_lib.c" | ||
"source_subfolder/gifalloc.c" | ||
"source_subfolder/gif_err.c" | ||
"source_subfolder/gif_font.c" | ||
"source_subfolder/gif_hash.c" | ||
"source_subfolder/openbsd-reallocarray.c" | ||
) | ||
|
||
add_library(${PROJECT_NAME} ${SOURCE_FILES}) | ||
target_include_directories(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder") | ||
|
||
install(TARGETS ${PROJECT_NAME} | ||
ARCHIVE DESTINATION "lib" | ||
LIBRARY DESTINATION "lib" | ||
RUNTIME DESTINATION "bin") | ||
install(FILES "source_subfolder/gif_lib.h" DESTINATION "include") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
sources: | ||
"5.2.1": | ||
url: "https://downloads.sourceforge.net/project/giflib/giflib-5.2.1.tar.gz" | ||
sha256: "31da5562f44c5f15d63340a09a4fd62b48c45620cd302f77a6d9acf0077879bd" | ||
patches: | ||
"5.2.1": | ||
- patch_file: "patches/0001-msvc-unistd.patch" | ||
base_path: source_subfolder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from conans import CMake, ConanFile, tools | ||
import os | ||
|
||
class GiflibConan(ConanFile): | ||
name = "giflib" | ||
description = "A library and utilities for reading and writing GIF images." | ||
url = "https://github.com/conan-io/conan-center-index" | ||
license = "MIT" | ||
homepage = "http://giflib.sourceforge.net" | ||
topics = ("conan", "giflib", "image", "multimedia", "format", "graphics") | ||
settings = "os", "arch", "compiler", "build_type" | ||
exports_sources = ["CMakeLists.txt", "patches/*"] | ||
generators = "cmake" | ||
_cmake = None | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
|
||
@property | ||
def _build_subfolder(self): | ||
return "build_subfolder" | ||
|
||
def configure(self): | ||
del self.settings.compiler.libcxx | ||
del self.settings.compiler.cppstd | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version]) | ||
os.rename("%s-%s" % (self.name, self.version), self._source_subfolder) | ||
|
||
def _configure_cmake(self): | ||
if self._cmake: | ||
return self._cmake | ||
self._cmake = CMake(self) | ||
self._cmake.configure(build_folder=self._build_subfolder) | ||
return self._cmake | ||
|
||
def _patch_sources(self): | ||
for patch in self.conan_data.get("patches", {}).get(self.version, []): | ||
tools.patch(**patch) | ||
|
||
def build(self): | ||
self._patch_sources() | ||
cmake = self._configure_cmake() | ||
cmake.build() | ||
|
||
def package(self): | ||
cmake = self._configure_cmake() | ||
cmake.install() | ||
|
||
self.copy("COPYING", src=self._source_subfolder, dst="licenses") | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = tools.collect_libs(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
diff --git a/gif_font.c b/gif_font.c | ||
index d90783c..0fd20ed 100644 | ||
--- a/gif_font.c | ||
+++ b/gif_font.c | ||
@@ -11,6 +11,10 @@ SPDX-License-Identifier: MIT | ||
|
||
#include "gif_lib.h" | ||
|
||
+#ifdef _MSC_VER | ||
+# define strtok_r strtok_s | ||
+#endif | ||
+ | ||
/***************************************************************************** | ||
Ascii 8 by 8 regular font - only first 128 characters are supported. | ||
*****************************************************************************/ | ||
diff --git a/gif_hash.h b/gif_hash.h | ||
index 6a1b585..6311cd1 100644 | ||
--- a/gif_hash.h | ||
+++ b/gif_hash.h | ||
@@ -9,7 +9,11 @@ SPDX-License-Identifier: MIT | ||
#ifndef _GIF_HASH_H_ | ||
#define _GIF_HASH_H_ | ||
|
||
+#ifdef _WIN32 | ||
+#else | ||
#include <unistd.h> | ||
+#endif | ||
+ | ||
#include <stdint.h> | ||
|
||
#define HT_SIZE 8192 /* 12bits = 4096 or twice as big! */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 2.8.12) | ||
project(test_package) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_executable(${PROJECT_NAME} test_package.c) | ||
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from conans import ConanFile, CMake, tools | ||
import os | ||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not tools.cross_building(self.settings): | ||
bin_path = os.path.join("bin", "test_package") | ||
command = "%s testimg.gif" % (bin_path) | ||
self.run(command, run_environment=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <ctype.h> | ||
#include <string.h> | ||
|
||
#include "gif_lib.h" | ||
|
||
|
||
#define LINE_LEN 40 | ||
#define IMAGEWIDTH LINE_LEN*GIF_FONT_WIDTH | ||
|
||
static int BackGround = 0; | ||
static void QuitGifError(GifFileType *GifFile); | ||
static void GenRasterTextLine(GifRowType *RasterBuffer, char *TextLine, | ||
int BufferWidth, int ForeGroundIndex); | ||
|
||
/****************************************************************************** | ||
Interpret the command line and generate the given GIF file. | ||
******************************************************************************/ | ||
int main(int argc, char **argv) | ||
{ | ||
int i, j, l, ColorMapSize, ErrorCode; | ||
char Line[LINE_LEN]; | ||
GifRowType RasterBuffer[GIF_FONT_HEIGHT]; | ||
ColorMapObject *ColorMap; | ||
GifFileType *GifFile; | ||
GifColorType ScratchMap[256]; | ||
|
||
/* Allocate the raster buffer for GIF_FONT_HEIGHT scan lines. */ | ||
for (i = 0; i < GIF_FONT_HEIGHT; i++) | ||
{ | ||
if ((RasterBuffer[i] = (GifRowType) malloc(sizeof(GifPixelType) * | ||
IMAGEWIDTH)) == NULL) | ||
exit(1); | ||
} | ||
|
||
/* Open stdout for the output file: */ | ||
if ((GifFile = EGifOpenFileName("out.gif", 0, &ErrorCode)) == NULL) { | ||
printf("error: %d\n", ErrorCode); | ||
exit(EXIT_FAILURE); | ||
} | ||
|
||
/* Read the color map in ColorFile into this color map: */ | ||
for (ColorMapSize = 0; ColorMapSize < 256; ColorMapSize++) | ||
{ | ||
ScratchMap[ColorMapSize].Red = ColorMapSize; | ||
ScratchMap[ColorMapSize].Green = ColorMapSize; | ||
ScratchMap[ColorMapSize].Blue = ColorMapSize; | ||
} | ||
|
||
if ((ColorMap = GifMakeMapObject(1 << GifBitSize(ColorMapSize), ScratchMap)) == NULL) | ||
exit(1); | ||
|
||
if (EGifPutScreenDesc(GifFile, | ||
IMAGEWIDTH, ColorMapSize * GIF_FONT_HEIGHT, | ||
GifBitSize(ColorMapSize), | ||
BackGround, ColorMap) == GIF_ERROR) | ||
QuitGifError(GifFile); | ||
|
||
/* Dump out the image descriptor: */ | ||
if (EGifPutImageDesc(GifFile, | ||
0, 0, IMAGEWIDTH, ColorMapSize * GIF_FONT_HEIGHT, false, NULL) == GIF_ERROR) | ||
QuitGifError(GifFile); | ||
|
||
printf("\n%s: Image 1 at (%d, %d) [%dx%d]: \n", | ||
"test_package", GifFile->Image.Left, GifFile->Image.Top, | ||
GifFile->Image.Width, GifFile->Image.Height); | ||
|
||
for (i = l = 0; i < ColorMap->ColorCount; i++) { | ||
(void)snprintf(Line, sizeof(Line), | ||
"Color %-3d: [%-3d, %-3d, %-3d] ", i, | ||
ColorMap->Colors[i].Red, | ||
ColorMap->Colors[i].Green, | ||
ColorMap->Colors[i].Blue); | ||
GenRasterTextLine(RasterBuffer, Line, IMAGEWIDTH, i); | ||
for (j = 0; j < GIF_FONT_HEIGHT; j++) { | ||
if (EGifPutLine(GifFile, RasterBuffer[j], IMAGEWIDTH) == GIF_ERROR) | ||
QuitGifError(GifFile); | ||
printf("\b\b\b\b%-4d", l++); | ||
} | ||
} | ||
|
||
if (EGifCloseFile(GifFile, &ErrorCode) == GIF_ERROR) | ||
{ | ||
printf("error: %d\n", ErrorCode); | ||
if (GifFile != NULL) { | ||
EGifCloseFile(GifFile, NULL); | ||
} | ||
exit(EXIT_FAILURE); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
/****************************************************************************** | ||
Close output file (if open), and exit. | ||
******************************************************************************/ | ||
static void GenRasterTextLine(GifRowType *RasterBuffer, char *TextLine, | ||
int BufferWidth, int ForeGroundIndex) | ||
{ | ||
unsigned char c; | ||
unsigned char Byte, Mask; | ||
int i, j, k, CharPosX, Len = (int)strlen(TextLine); | ||
|
||
for (i = 0; i < BufferWidth; i++) | ||
for (j = 0; j < GIF_FONT_HEIGHT; j++) RasterBuffer[j][i] = BackGround; | ||
|
||
for (i = CharPosX = 0; i < Len; i++, CharPosX += GIF_FONT_WIDTH) { | ||
c = TextLine[i]; | ||
for (j = 0; j < GIF_FONT_HEIGHT; j++) { | ||
Byte = GifAsciiTable8x8[(unsigned short)c][j]; | ||
for (k = 0, Mask = 128; k < GIF_FONT_WIDTH; k++, Mask >>= 1) | ||
if (Byte & Mask) | ||
RasterBuffer[j][CharPosX + k] = ForeGroundIndex; | ||
} | ||
} | ||
} | ||
|
||
/****************************************************************************** | ||
Close output file (if open), and exit. | ||
******************************************************************************/ | ||
static void QuitGifError(GifFileType *GifFile) | ||
{ | ||
if (GifFile != NULL) { | ||
printf("error: %d\n", GifFile->Error); | ||
EGifCloseFile(GifFile, NULL); | ||
} | ||
exit(EXIT_FAILURE); | ||
} | ||
|
||
/* vim: ts=8 sw=8 et */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
versions: | ||
"5.1.4": | ||
folder: all | ||
folder: "all" | ||
"5.2.1": | ||
folder: "5.2.x" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't patching be done in
source
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Source folder should be untouched. Why? Any change in the recipe will require a new download, which means more time. Keep all patches on build folder, which is a "build cache".