mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +00:00
Merge branch 'ci'
This commit is contained in:
commit
f310a51dfb
26
.travis.yml
Normal file
26
.travis.yml
Normal file
@ -0,0 +1,26 @@
|
||||
language: cpp
|
||||
|
||||
compiler:
|
||||
- clang
|
||||
- gcc
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- SHARED=OFF
|
||||
- SHARED=ON
|
||||
|
||||
before_install:
|
||||
- if [ "$CXX" = "g++" ]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test; fi
|
||||
- sudo apt-get update -qq
|
||||
- if [ "$SHARED" == "ON" ]; then sudo apt-get install -y libcurl4-openssl-dev libgif-dev libjpeg-dev libz-dev libpng-dev libtinyxml-dev libpixman-1-dev liballegro4.2-dev ; fi
|
||||
- if [ "$CXX" = "g++" ]; then sudo apt-get install -y -qq g++-4.8; fi
|
||||
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8"; fi
|
||||
|
||||
before_script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake .. -DUSE_SHARED_CURL=$SHARED -DUSE_SHARED_GIFLIB=$SHARED -DUSE_SHARED_JPEGLIB=$SHARED -DUSE_SHARED_ZLIB=$SHARED -DUSE_SHARED_LIBPNG=$SHARED -DUSE_SHARED_TINYXML=$SHARED -DUSE_SHARED_PIXMAN=$SHARED -DUSE_SHARED_ALLEGRO4=$SHARED
|
||||
|
||||
script:
|
||||
- "make"
|
||||
- "make -k run_non_ui_tests"
|
@ -41,7 +41,6 @@ option(USE_SHARED_ZLIB "Use your installed copy of zlib" off)
|
||||
option(USE_SHARED_LIBPNG "Use your installed copy of libpng" off)
|
||||
option(USE_SHARED_LIBLOADPNG "Use your installed copy of libloadpng" off)
|
||||
option(USE_SHARED_TINYXML "Use your installed copy of tinyxml" off)
|
||||
option(USE_SHARED_GTEST "Use your installed copy of gtest" off)
|
||||
option(USE_SHARED_PIXMAN "Use your installed copy of pixman" off)
|
||||
option(USE_SHARED_ALLEGRO4 "Use shared Allegro 4 library (without resize support)" off)
|
||||
option(USE_ALLEG4_BACKEND "Use Allegro 4 backend" on)
|
||||
@ -113,14 +112,6 @@ set(SIMPLEINI_DIR ${CMAKE_SOURCE_DIR}/third_party/simpleini)
|
||||
set(TINYXML_DIR ${CMAKE_SOURCE_DIR}/third_party/tinyxml)
|
||||
set(ZLIB_DIR ${CMAKE_SOURCE_DIR}/third_party/zlib)
|
||||
|
||||
# Zlib generated zconf.h file
|
||||
include_directories(${CMAKE_BINARY_DIR}/third_party/zlib)
|
||||
|
||||
# We need private libpng header files so it doesn't matter if we use
|
||||
# the shared version of libpng or not, we need to find header files in
|
||||
# "third_party/libpng"" directory.
|
||||
include_directories(${LIBPNG_DIR})
|
||||
|
||||
# Search in the "cmake" directory for additional CMake modules.
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
|
||||
@ -128,10 +119,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
|
||||
|
||||
######################################################################
|
||||
# Common definitions to compile all sources
|
||||
|
||||
# Do not use MMX optimizations in PNG code
|
||||
add_definitions(-DPNG_NO_MMX_CODE)
|
||||
# Common definitions to compile all sources (app code and third party)
|
||||
|
||||
# Debug C/C++ flags
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
@ -141,16 +129,37 @@ else()
|
||||
endif()
|
||||
|
||||
# Fix to compile gtest with VC11 (2012)
|
||||
if(NOT USE_SHARED_GTEST)
|
||||
if (MSVC_VERSION EQUAL 1700)
|
||||
add_definitions(-D_VARIADIC_MAX=10)
|
||||
endif()
|
||||
if(MSVC_VERSION EQUAL 1700)
|
||||
add_definitions(-D_VARIADIC_MAX=10)
|
||||
endif()
|
||||
|
||||
if(NOT WIN32 AND NOT APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu89")
|
||||
endif()
|
||||
|
||||
if(NOT USE_SHARED_CURL)
|
||||
set(CURL_STATICLIB ON BOOL)
|
||||
endif()
|
||||
|
||||
if(NOT USE_SHARED_ZLIB)
|
||||
# Zlib generated zconf.h file
|
||||
include_directories(${CMAKE_BINARY_DIR}/third_party/zlib)
|
||||
endif()
|
||||
|
||||
if(USE_SHARED_LIBPNG)
|
||||
find_package(PNG)
|
||||
if(NOT PNG_FOUND)
|
||||
message(FATAL_ERROR "libpng not found")
|
||||
endif()
|
||||
add_definitions(${PNG_DEFINITIONS})
|
||||
include_directories(${PNG_INCLUDE_DIR})
|
||||
else()
|
||||
include_directories(${LIBPNG_DIR})
|
||||
endif()
|
||||
|
||||
# Do not use MMX optimizations in PNG code
|
||||
add_definitions(-DPNG_NO_MMX_CODE)
|
||||
|
||||
######################################################################
|
||||
# Allegro 4 backend
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
# Aseprite
|
||||
*Copyright (C) 2001-2015 David Capello*
|
||||
|
||||
[](https://travis-ci.org/aseprite/aseprite)
|
||||
[](https://gitter.im/aseprite/aseprite?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
> THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY<br/>
|
||||
|
@ -86,12 +86,7 @@ else()
|
||||
endif()
|
||||
|
||||
if(USE_SHARED_LIBPNG)
|
||||
find_package(PNG)
|
||||
if(PNG_FOUND)
|
||||
set(libs3rdparty ${libs3rdparty} ${PNG_LIBRARIES})
|
||||
add_definitions(${PNG_DEFINITIONS})
|
||||
include_directories(${PNG_INCLUDE_DIR})
|
||||
endif(PNG_FOUND)
|
||||
set(libs3rdparty ${libs3rdparty} ${PNG_LIBRARIES})
|
||||
else()
|
||||
set(libs3rdparty ${libs3rdparty} libpng)
|
||||
endif()
|
||||
@ -132,8 +127,8 @@ if(USE_ALLEG4_BACKEND)
|
||||
endif()
|
||||
|
||||
if(USE_SHARED_PIXMAN)
|
||||
find_library(LIBPIXMAN_LIBRARY NAMES pixman)
|
||||
find_path(LIBPIXMAN_INCLUDE_DIR NAMES pixman.h)
|
||||
find_library(LIBPIXMAN_LIBRARY NAMES pixman pixman-1)
|
||||
find_path(LIBPIXMAN_INCLUDE_DIR NAMES pixman.h PATH_SUFFIXES pixman-1)
|
||||
|
||||
set(libs3rdparty ${libs3rdparty} ${LIBPIXMAN_LIBRARY})
|
||||
include_directories(${LIBPIXMAN_INCLUDE_DIR})
|
||||
@ -293,10 +288,8 @@ function(find_tests dir dependencies)
|
||||
file(GLOB tests ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/*_tests.cpp)
|
||||
list(REMOVE_AT ARGV 0)
|
||||
|
||||
if(NOT USE_SHARED_GTEST)
|
||||
# Add gtest include directory so we can #include <gtest/gtest.h> in tests source code
|
||||
include_directories(${CMAKE_SOURCE_DIR}/third_party/gtest/include)
|
||||
endif()
|
||||
# Add gtest include directory so we can #include <gtest/gtest.h> in tests source code
|
||||
include_directories(${CMAKE_SOURCE_DIR}/third_party/gtest/include)
|
||||
|
||||
# See if the test is linked with "she" library.
|
||||
list(FIND dependencies she link_with_she)
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "app/file/file.h"
|
||||
#include "app/file/file_formats_manager.h"
|
||||
#include "doc/doc.h"
|
||||
#include "she/she.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@ -23,7 +22,6 @@ using namespace app;
|
||||
|
||||
TEST(File, SeveralSizes)
|
||||
{
|
||||
she::ScopedHandle<she::System> system(she::create_system());
|
||||
// Register all possible image formats.
|
||||
FileFormatsManager::instance()->registerAllFormats();
|
||||
std::vector<char> fn(256);
|
||||
|
@ -31,6 +31,10 @@
|
||||
|
||||
#include <gif_lib.h>
|
||||
|
||||
#if GIFLIB_MAJOR < 5
|
||||
#define GifMakeMapObject MakeMapObject
|
||||
#endif
|
||||
|
||||
namespace app {
|
||||
|
||||
using namespace base;
|
||||
@ -106,15 +110,23 @@ static int interlaced_jumps[] = { 8, 8, 4, 2 };
|
||||
|
||||
struct GifFilePtr {
|
||||
public:
|
||||
#if GIFLIB_MAJOR >= 5
|
||||
typedef int (*CloseFunc)(GifFileType*, int*);
|
||||
#else
|
||||
typedef int (*CloseFunc)(GifFileType*);
|
||||
#endif
|
||||
|
||||
GifFilePtr(GifFileType* ptr, CloseFunc closeFunc) :
|
||||
m_ptr(ptr), m_closeFunc(closeFunc) {
|
||||
}
|
||||
|
||||
~GifFilePtr() {
|
||||
#if GIFLIB_MAJOR >= 5
|
||||
int errCode;
|
||||
m_closeFunc(m_ptr, &errCode);
|
||||
#else
|
||||
m_closeFunc(m_ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
operator GifFileType*() {
|
||||
@ -132,8 +144,14 @@ private:
|
||||
|
||||
bool GifFormat::onLoad(FileOp* fop)
|
||||
{
|
||||
int errCode;
|
||||
GifFilePtr gif_file(DGifOpenFileHandle(open_file_descriptor_with_exception(fop->filename, "rb"), &errCode), &DGifCloseFile);
|
||||
#if GIFLIB_MAJOR >= 5
|
||||
int errCode = 0;
|
||||
#endif
|
||||
GifFilePtr gif_file(DGifOpenFileHandle(open_file_descriptor_with_exception(fop->filename, "rb")
|
||||
#if GIFLIB_MAJOR >= 5
|
||||
, &errCode
|
||||
#endif
|
||||
), &DGifCloseFile);
|
||||
|
||||
if (!gif_file) {
|
||||
fop_error(fop, "Error loading GIF header.\n");
|
||||
@ -244,7 +262,13 @@ bool GifFormat::onLoad(FileOp* fop)
|
||||
for (int y = 0; y < frame_h; ++y) {
|
||||
addr = frame_image->getPixelAddress(0, y);
|
||||
if (DGifGetLine(gif_file, addr, frame_w) == GIF_ERROR)
|
||||
throw Exception("Invalid image data (%d).\n", gif_file->Error);
|
||||
throw Exception("Invalid image data (%d).\n"
|
||||
#if GIFLIB_MAJOR >= 5
|
||||
, gif_file->Error
|
||||
#else
|
||||
, GifLastError()
|
||||
#endif
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -522,8 +546,14 @@ void GifFormat::onDestroyData(FileOp* fop)
|
||||
#ifdef ENABLE_SAVE
|
||||
bool GifFormat::onSave(FileOp* fop)
|
||||
{
|
||||
int errCode;
|
||||
GifFilePtr gif_file(EGifOpenFileHandle(open_file_descriptor_with_exception(fop->filename, "wb"), &errCode), &EGifCloseFile);
|
||||
#if GIFLIB_MAJOR >= 5
|
||||
int errCode = 0;
|
||||
#endif
|
||||
GifFilePtr gif_file(EGifOpenFileHandle(open_file_descriptor_with_exception(fop->filename, "wb")
|
||||
#if GIFLIB_MAJOR >= 5
|
||||
, &errCode
|
||||
#endif
|
||||
), &EGifCloseFile);
|
||||
|
||||
if (!gif_file)
|
||||
throw Exception("Error creating GIF file.\n");
|
||||
@ -682,6 +712,7 @@ bool GifFormat::onSave(FileOp* fop)
|
||||
|
||||
// Specify loop extension.
|
||||
if (frame_num == 0 && loop >= 0) {
|
||||
#if GIFLIB_MAJOR >= 5
|
||||
if (EGifPutExtensionLeader(gif_file, APPLICATION_EXT_FUNC_CODE) == GIF_ERROR)
|
||||
throw Exception("Error writing GIF graphics extension record (header section).");
|
||||
|
||||
@ -698,6 +729,23 @@ bool GifFormat::onSave(FileOp* fop)
|
||||
|
||||
if (EGifPutExtensionTrailer(gif_file) == GIF_ERROR)
|
||||
throw Exception("Error writing GIF graphics extension record (trailer section).");
|
||||
|
||||
#else
|
||||
unsigned char extension_bytes[11];
|
||||
|
||||
memcpy(extension_bytes, "NETSCAPE2.0", 11);
|
||||
if (EGifPutExtensionFirst(gif_file, APPLICATION_EXT_FUNC_CODE, 11, extension_bytes) == GIF_ERROR)
|
||||
throw Exception("Error writing GIF graphics extension record for frame %d.\n", (int)frame_num);
|
||||
|
||||
extension_bytes[0] = 1;
|
||||
extension_bytes[1] = (loop & 0xff);
|
||||
extension_bytes[2] = (loop >> 8) & 0xff;
|
||||
if (EGifPutExtensionNext(gif_file, APPLICATION_EXT_FUNC_CODE, 3, extension_bytes) == GIF_ERROR)
|
||||
throw Exception("Error writing GIF graphics extension record for frame %d.\n", (int)frame_num);
|
||||
|
||||
if (EGifPutExtensionLast(gif_file, APPLICATION_EXT_FUNC_CODE, 0, NULL) == GIF_ERROR)
|
||||
throw Exception("Error writing GIF graphics extension record for frame %d.\n", (int)frame_num);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Write graphics extension record (to save the duration of the
|
||||
@ -770,8 +818,8 @@ bool GifFormat::onSave(FileOp* fop)
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
base::SharedPtr<FormatOptions> GifFormat::onGetFormatOptions(FileOp* fop)
|
||||
{
|
||||
|
@ -14,20 +14,17 @@
|
||||
#include "app/file/gif_options.h"
|
||||
#include "doc/doc.h"
|
||||
#include "doc/test_context.h"
|
||||
#include "she/scoped_handle.h"
|
||||
#include "she/system.h"
|
||||
|
||||
using namespace app;
|
||||
|
||||
class GifFormat : public ::testing::Test {
|
||||
public:
|
||||
GifFormat() : m_system(she::create_system()) {
|
||||
GifFormat() {
|
||||
FileFormatsManager::instance()->registerAllFormats();
|
||||
}
|
||||
|
||||
protected:
|
||||
doc::TestContextT<app::Context> m_ctx;
|
||||
she::ScopedHandle<she::System> m_system;
|
||||
};
|
||||
|
||||
TEST_F(GifFormat, Dimensions)
|
||||
|
@ -404,7 +404,7 @@ bool PngFormat::onSave(FileOp* fop)
|
||||
#endif
|
||||
|
||||
// Save the color palette.
|
||||
palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color));
|
||||
palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH * sizeof(png_color));
|
||||
for (c = 0; c < PNG_MAX_PALETTE_LENGTH; c++) {
|
||||
fop_sequence_get_color(fop, c, &r, &g, &b);
|
||||
palette[c].red = r;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "she/she.h"
|
||||
|
||||
#include "base/concurrent_queue.h"
|
||||
#include "base/exception.h"
|
||||
#include "base/string.h"
|
||||
#include "base/unique_ptr.h"
|
||||
#include "she/alleg4/surface.h"
|
||||
@ -679,10 +680,12 @@ public:
|
||||
Alleg4System()
|
||||
{
|
||||
if (allegro_init() < 0)
|
||||
throw std::runtime_error("Cannot initialize Allegro library");
|
||||
throw base::Exception("Cannot initialize Allegro library: %s", allegro_error);
|
||||
|
||||
set_uformat(U_UTF8);
|
||||
#if MAKE_VERSION(ALLEGRO_VERSION, ALLEGRO_SUB_VERSION, ALLEGRO_WIP_VERSION) >= MAKE_VERSION(4, 4, 0)
|
||||
_al_detect_filename_encoding();
|
||||
#endif
|
||||
install_timer();
|
||||
|
||||
// Register PNG as a supported bitmap type
|
||||
|
13
third_party/CMakeLists.txt
vendored
13
third_party/CMakeLists.txt
vendored
@ -1,8 +1,6 @@
|
||||
# ASEPRITE
|
||||
# Copyright (C) 2001-2015 David Capello
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
|
||||
include_directories(.)
|
||||
|
||||
if(MSVC)
|
||||
@ -30,20 +28,13 @@ if(NOT USE_SHARED_TINYXML)
|
||||
add_subdirectory(tinyxml)
|
||||
endif()
|
||||
|
||||
if(NOT USE_SHARED_GTEST AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/gtest/CMakeLists.txt)
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/gtest/CMakeLists.txt)
|
||||
# We don't use add_subdirectory(gtest) because the gtest
|
||||
# CMakeLists.txt modifies some MSVC flags.
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/gtest ${CMAKE_CURRENT_SOURCE_DIR}/gtest/include)
|
||||
add_library(gtest ${CMAKE_CURRENT_SOURCE_DIR}/gtest/src/gtest-all.cc)
|
||||
else()
|
||||
find_library(gtest)
|
||||
check_cxx_source_compiles("
|
||||
#include <gtest/gtest.h>
|
||||
int main() { }
|
||||
" HAVE_GTEST_GTEST_H)
|
||||
if(NOT HAVE_GTEST_GTEST_H)
|
||||
message(FATAL_ERROR "gtest/gtest.h is missing. Set USE_SHARED_GTEST=OFF and initialize submodules: git submodule update --init --recursive")
|
||||
endif()
|
||||
message(FATAL_ERROR "gtest/gtest.h is missing. Initialize submodules: git submodule update --init --recursive")
|
||||
endif()
|
||||
|
||||
if(NOT USE_SHARED_CURL)
|
||||
|
5
third_party/loadpng/CMakeLists.txt
vendored
5
third_party/loadpng/CMakeLists.txt
vendored
@ -1,10 +1,7 @@
|
||||
# ASEPRITE
|
||||
# Copyright (C) 2001-2013 David Capello
|
||||
# Copyright (C) 2001-2013, 2015 David Capello
|
||||
|
||||
add_library(loadpng
|
||||
loadpng.c
|
||||
savepng.c
|
||||
regpng.c)
|
||||
|
||||
set_target_properties(loadpng PROPERTIES
|
||||
COMPILE_FLAGS "-DDEBUGMODE -DALLEGRO_STATICLINK")
|
||||
|
Loading…
x
Reference in New Issue
Block a user