diff --git a/.gitmodules b/.gitmodules index 32ded09..7b743ea 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "oss-internship-2020/sapi_lodepng/lodepng"] path = oss-internship-2020/sapi_lodepng/lodepng - url = https://github.com/andreimedar/lodepng + url = https://github.com/lvandeve/lodepng diff --git a/oss-internship-2020/sapi_lodepng/CMakeLists.txt b/oss-internship-2020/sapi_lodepng/CMakeLists.txt index 822f497..c1765be 100644 --- a/oss-internship-2020/sapi_lodepng/CMakeLists.txt +++ b/oss-internship-2020/sapi_lodepng/CMakeLists.txt @@ -19,14 +19,23 @@ project(lodepng_sapi CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED 17) -# Build static library +# Apply the patches to the header file. +add_custom_command( + OUTPUT "${PROJECT_SOURCE_DIR}/lodepng/lodepng.h" + COMMAND cp "${PROJECT_SOURCE_DIR}/lodepng/lodepng.h" "${PROJECT_SOURCE_DIR}/patches/" + COMMAND cd "${PROJECT_SOURCE_DIR}/patches" && patch < header.patch + COMMAND mv "${PROJECT_SOURCE_DIR}/patches/lodepng.h" "${PROJECT_SOURCE_DIR}/lodepng/" +) + +# Build static library. add_library(lodepng STATIC - lodepng/lodepng.cpp - lodepng/lodepng.h + "${PROJECT_SOURCE_DIR}/lodepng/lodepng.cpp" + "${PROJECT_SOURCE_DIR}/lodepng/lodepng.h" ) # Build SAPI library -set(SAPI_ROOT "" CACHE PATH "Path to the Sandboxed API source tree") +#set(SAPI_ROOT "" CACHE PATH "Path to the Sandboxed API source tree") +set(SAPI_ROOT "/usr/local/google/home/amedar/internship/sandboxed-api" CACHE PATH "Path to the Sandboxed API source tree") add_subdirectory("${SAPI_ROOT}" "${CMAKE_BINARY_DIR}/sandboxed-api-build" @@ -56,7 +65,7 @@ add_sapi_library( lodepng_save_file lodepng_load_file - INPUTS lodepng/lodepng.h + INPUTS "${PROJECT_SOURCE_DIR}/lodepng/lodepng.h" LIBRARY lodepng LIBRARY_NAME Lodepng NAMESPACE "" diff --git a/oss-internship-2020/sapi_lodepng/lodepng b/oss-internship-2020/sapi_lodepng/lodepng index aa6cc42..34628e8 160000 --- a/oss-internship-2020/sapi_lodepng/lodepng +++ b/oss-internship-2020/sapi_lodepng/lodepng @@ -1 +1 @@ -Subproject commit aa6cc42db701b01d6d2afad001ad286556988061 +Subproject commit 34628e89e80cd007179b25b0b2695e6af0f57fac diff --git a/oss-internship-2020/sapi_lodepng/patches/header.patch b/oss-internship-2020/sapi_lodepng/patches/header.patch new file mode 100644 index 0000000..dad11dc --- /dev/null +++ b/oss-internship-2020/sapi_lodepng/patches/header.patch @@ -0,0 +1,86 @@ +--- lodepng.h 2020-09-11 08:41:22.280259945 +0000 ++++ lodepng2.h 2020-09-11 08:45:17.134266042 +0000 +@@ -89,6 +89,8 @@ + #endif + #endif + ++ ++ + #ifdef LODEPNG_COMPILE_CPP + #include + #include +@@ -126,6 +128,9 @@ + bitdepth: the desired bit depth for the raw output image. See explanation on PNG color types. + Return value: LodePNG error code (0 means no error). + */ ++ ++extern "C" { ++ + unsigned lodepng_decode_memory(unsigned char** out, unsigned* w, unsigned* h, + const unsigned char* in, size_t insize, + LodePNGColorType colortype, unsigned bitdepth); +@@ -154,10 +159,12 @@ + /*Same as lodepng_decode_file, but always decodes to 24-bit RGB raw image.*/ + unsigned lodepng_decode24_file(unsigned char** out, unsigned* w, unsigned* h, + const char* filename); ++ + #endif /*LODEPNG_COMPILE_DISK*/ + #endif /*LODEPNG_COMPILE_DECODER*/ + + ++ + #ifdef LODEPNG_COMPILE_ENCODER + /* + Converts raw pixel data into a PNG image in memory. The colortype and bitdepth +@@ -204,6 +211,9 @@ + /*Same as lodepng_encode_file, but always encodes from 24-bit RGB raw image.*/ + unsigned lodepng_encode24_file(const char* filename, + const unsigned char* image, unsigned w, unsigned h); ++ ++} ++ + #endif /*LODEPNG_COMPILE_DISK*/ + #endif /*LODEPNG_COMPILE_ENCODER*/ + +@@ -219,6 +229,8 @@ + unsigned decode(std::vector& out, unsigned& w, unsigned& h, + const std::vector& in, + LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8); ++ ++ + #ifdef LODEPNG_COMPILE_DISK + /* + Converts PNG file from disk to raw pixel data in memory. +@@ -251,6 +263,7 @@ + unsigned encode(const std::string& filename, + const std::vector& in, unsigned w, unsigned h, + LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8); ++ + #endif /* LODEPNG_COMPILE_DISK */ + #endif /* LODEPNG_COMPILE_ENCODER */ + } /* namespace lodepng */ +@@ -318,6 +331,7 @@ + + extern const LodePNGCompressSettings lodepng_default_compress_settings; + void lodepng_compress_settings_init(LodePNGCompressSettings* settings); ++ + #endif /*LODEPNG_COMPILE_ENCODER*/ + + #ifdef LODEPNG_COMPILE_PNG +@@ -943,6 +957,8 @@ + #endif /*LODEPNG_COMPILE_ZLIB*/ + + #ifdef LODEPNG_COMPILE_DISK ++ ++extern "C" { + /* + Load a file from disk into buffer. The function allocates the out buffer, and + after usage you should free it. +@@ -962,6 +978,7 @@ + return value: error code (0 means ok) + */ + unsigned lodepng_save_file(const unsigned char* buffer, size_t buffersize, const char* filename); ++} + #endif /*LODEPNG_COMPILE_DISK*/ + + #ifdef LODEPNG_COMPILE_CPP