mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Fixed patch command in cmake. Fixed style
This commit is contained in:
parent
0bc5c28cb5
commit
9bc3d123a9
1
oss-internship-2020/sapi_lodepng/.gitignore
vendored
1
oss-internship-2020/sapi_lodepng/.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
build/
|
||||
.clang-format
|
||||
|
|
|
@ -20,36 +20,24 @@ set(CMAKE_CXX_STANDARD 17)
|
|||
set(CMAKE_CXX_STANDARD_REQUIRED 17)
|
||||
|
||||
# Apply the patches to the header file.
|
||||
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/patches")
|
||||
|
||||
# Move the original header to a new folder to use as target, apply the patch
|
||||
# and move it back to build the library.
|
||||
add_custom_command(
|
||||
OUTPUT "${PROJECT_BINARY_DIR}/patches/lodepng.h"
|
||||
OUTPUT "${PROJECT_BINARY_DIR}/lodepng/lodepng.h" "${PROJECT_BINARY_DIR}/lodepng/lodepng.cpp"
|
||||
COMMENT "Applying patch to header file."
|
||||
COMMAND cp "${PROJECT_SOURCE_DIR}/patches/header.patch" "${PROJECT_BINARY_DIR}/patches/"
|
||||
COMMAND cp "${PROJECT_SOURCE_DIR}/lodepng/lodepng.h" "${PROJECT_BINARY_DIR}/patches/"
|
||||
COMMAND cd "${PROJECT_BINARY_DIR}/patches" && patch < header.patch
|
||||
COMMAND cp "${PROJECT_BINARY_DIR}/patches/lodepng.h" "${PROJECT_SOURCE_DIR}/lodepng/"
|
||||
COMMAND cp -r "${PROJECT_SOURCE_DIR}/lodepng" "${PROJECT_BINARY_DIR}/"
|
||||
COMMAND cp "${PROJECT_SOURCE_DIR}/patches/header.patch" "${PROJECT_BINARY_DIR}/lodepng/"
|
||||
COMMAND cd "${PROJECT_BINARY_DIR}/lodepng" && patch < header.patch
|
||||
)
|
||||
|
||||
set_property(
|
||||
SOURCE
|
||||
"${PROJECT_SOURCE_DIR}/lodepng/lodepng.h"
|
||||
APPEND PROPERTY OBJECT_DEPENDS
|
||||
"${PROJECT_BINARY_DIR}/patches/lodepng.h"
|
||||
)
|
||||
|
||||
|
||||
# Build static library.
|
||||
add_library(lodepng STATIC
|
||||
"${PROJECT_SOURCE_DIR}/lodepng/lodepng.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/lodepng/lodepng.h"
|
||||
"${PROJECT_BINARY_DIR}/lodepng/lodepng.cpp"
|
||||
"${PROJECT_BINARY_DIR}/lodepng/lodepng.h"
|
||||
)
|
||||
|
||||
# Build SAPI library
|
||||
set(SAPI_ROOT "" CACHE PATH "Path to the Sandboxed API source tree")
|
||||
target_include_directories(lodepng PUBLIC "${PROJECT_BINARY_DIR}/lodepng")
|
||||
|
||||
# Build SAPI library
|
||||
set(SAPI_ROOT "${PROJECT_SOURCE_DIR}/../.." CACHE PATH "Path to the Sandboxed API source tree")
|
||||
|
||||
add_subdirectory("${SAPI_ROOT}"
|
||||
"${CMAKE_BINARY_DIR}/sandboxed-api-build"
|
||||
|
@ -79,7 +67,7 @@ add_sapi_library(
|
|||
lodepng_save_file
|
||||
lodepng_load_file
|
||||
|
||||
INPUTS "${PROJECT_SOURCE_DIR}/lodepng/lodepng.h"
|
||||
INPUTS "${PROJECT_BINARY_DIR}/lodepng/lodepng.h"
|
||||
LIBRARY lodepng
|
||||
LIBRARY_NAME Lodepng
|
||||
NAMESPACE ""
|
||||
|
|
|
@ -39,3 +39,4 @@ std::string CreateTempDirAtCWD() {
|
|||
CHECK(result.ok()) << "Could not create temporary directory";
|
||||
return result.value();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
#include "sandboxed_api/sandbox2/util/fileops.h"
|
||||
#include "sandboxed_api/sandbox2/util/temp_file.h"
|
||||
|
||||
constexpr size_t kWidth = 512;
|
||||
constexpr size_t kHeight = 512;
|
||||
constexpr size_t kImgLen = kWidth * kHeight * 4;
|
||||
inline constexpr size_t kWidth = 512;
|
||||
inline constexpr size_t kHeight = 512;
|
||||
inline constexpr size_t kImgLen = kWidth * kHeight * 4;
|
||||
|
||||
// Returns a vector that contains values used for testing.
|
||||
// This part of code is taken from
|
||||
|
@ -37,3 +37,4 @@ std::vector<uint8_t> GenerateValues();
|
|||
std::string CreateTempDirAtCWD();
|
||||
|
||||
#endif // SAPI_LODEPNG_HELPERS_H
|
||||
|
||||
|
|
|
@ -192,3 +192,4 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -211,3 +211,4 @@ TEST(LodePngTest, EncodeDecodeTwoSteps) {
|
|||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#include "../lodepng/lodepng.h"
|
||||
#include "helpers.h"
|
||||
#include "lodepng.h"
|
||||
#include "sandboxed_api/sandbox2/util/fileops.h"
|
||||
|
||||
void EncodeDecodeOneStep(const std::string& images_path) {
|
||||
|
@ -112,3 +112,4 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,3 +47,4 @@ class SapiLodepngSandbox : public LodepngSandbox {
|
|||
};
|
||||
|
||||
#endif // SAPI_LODEPNG_SANDBOX_H_
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user