mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Updated README
This commit is contained in:
parent
0639b18cba
commit
7c52e77c85
|
@ -1,16 +1,16 @@
|
||||||
// Copyright 2020 Google LLC
|
# Copyright 2020 Google LLC
|
||||||
//
|
#
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
# You may obtain a copy of the License at
|
||||||
//
|
#
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
//
|
#
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
// See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.10)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
|
||||||
|
@ -19,6 +19,11 @@ project(test CXX C)
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||||
|
|
||||||
|
find_package(PNG REQUIRED)
|
||||||
|
find_package(PkgConfig REQUIRED)
|
||||||
|
pkg_check_modules(libpcre REQUIRED IMPORTED_TARGET libpcre)
|
||||||
|
#pkg_check_modules(libproj REQUIRED IMPORTED_TARGET libproj)
|
||||||
|
|
||||||
set(SAPI_ROOT "${PROJECT_SOURCE_DIR}/../.." CACHE PATH "Path to the Sandboxed API source tree")
|
set(SAPI_ROOT "${PROJECT_SOURCE_DIR}/../.." CACHE PATH "Path to the Sandboxed API source tree")
|
||||||
# cmake .. -G Ninja -DSAPI_ROOT=$HOME/sapi_root
|
# cmake .. -G Ninja -DSAPI_ROOT=$HOME/sapi_root
|
||||||
|
|
||||||
|
@ -32,12 +37,10 @@ add_subdirectory("${SAPI_ROOT}"
|
||||||
add_library(libgdal STATIC IMPORTED)
|
add_library(libgdal STATIC IMPORTED)
|
||||||
set_property(TARGET libgdal PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/lib/libgdal.a")
|
set_property(TARGET libgdal PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/lib/libgdal.a")
|
||||||
|
|
||||||
find_package(PNG REQUIRED)
|
|
||||||
|
|
||||||
target_link_libraries(libgdal INTERFACE
|
target_link_libraries(libgdal INTERFACE
|
||||||
crypto expat jpeg
|
crypto expat jpeg
|
||||||
/usr/lib/x86_64-linux-gnu/libproj.so
|
PkgConfig::libpcre
|
||||||
/usr/lib/x86_64-linux-gnu/libpcre.so
|
/usr/lib/libproj.so
|
||||||
sqlite3 tiff z pthread m rt dl curl
|
sqlite3 tiff z pthread m rt dl curl
|
||||||
PNG::PNG)
|
PNG::PNG)
|
||||||
|
|
||||||
|
@ -51,7 +54,7 @@ add_sapi_library(gdal_sapi
|
||||||
|
|
||||||
INPUTS "/usr/include/gdal/gdal.h"
|
INPUTS "/usr/include/gdal/gdal.h"
|
||||||
LIBRARY libgdal
|
LIBRARY libgdal
|
||||||
LIBRARY_NAME gdal
|
LIBRARY_NAME GDAL
|
||||||
|
|
||||||
NAMESPACE ""
|
NAMESPACE ""
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,6 +5,26 @@ Build Tools: CMake/Ninja
|
||||||
OS: Linux
|
OS: Linux
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### For installing GDAL:
|
||||||
|
`sudo apt-get install python3.6-dev`
|
||||||
|
|
||||||
|
`sudo add-apt-repository ppa:ubuntugis/ppa && sudo apt update`
|
||||||
|
|
||||||
|
`sudo apt-get install gdal-bin`
|
||||||
|
|
||||||
|
`sudo apt-get install libgdal-dev`
|
||||||
|
|
||||||
|
### Dependencies:
|
||||||
|
PNG: `sudo apt-get install libpng-dev`
|
||||||
|
|
||||||
|
PCRE: `sudo apt-get install libpcre3 libpcre3-dev`
|
||||||
|
|
||||||
|
PROJ: `sudo apt-get install libproj-dev`
|
||||||
|
|
||||||
|
### Initializing GDAL submodule:
|
||||||
|
`git submodule add https://github.com/OSGeo/gdal/tree/master/gdal`
|
||||||
|
|
||||||
|
|
||||||
### For testing:
|
### For testing:
|
||||||
`mkdir build && cd build`
|
`mkdir build && cd build`
|
||||||
|
|
||||||
|
@ -12,13 +32,13 @@ OS: Linux
|
||||||
|
|
||||||
`ninja`
|
`ninja`
|
||||||
|
|
||||||
`./raster`
|
`./raster <your_absolute_tiff_file_path>`
|
||||||
|
|
||||||
## About the project
|
## About the project
|
||||||
GDAL is a translator library for raster and vector
|
GDAL is a translator library for raster and vector
|
||||||
geospatial data format.
|
geospatial data format.
|
||||||
The project consist in rastering a GeoTIFF file format
|
The project consist in rastering a GeoTIFF file format
|
||||||
using GDAL functionalities and sandboxed methods.
|
using GDAL functionalities and sandboxed methods.
|
||||||
|
|
||||||
## Implementation
|
## Implementation
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,13 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "gdal_sapi.sapi.h"
|
#include "gdal_sapi.sapi.h" // NOLINT(build/include)
|
||||||
#include "sandboxed_api/sandbox2/util/fileops.h"
|
#include "sandboxed_api/sandbox2/util/fileops.h"
|
||||||
|
|
||||||
class GdalSapiSandbox : public gdalSandbox {
|
class GdalSapiSandbox : public GDALSandbox {
|
||||||
public:
|
public:
|
||||||
std::string filePath;
|
|
||||||
|
|
||||||
GdalSapiSandbox(std::string path)
|
GdalSapiSandbox(std::string path)
|
||||||
: gdalSandbox(), filePath(std::move(path)) {}
|
: GDALSandbox(), file_path_(std::move(path)) {}
|
||||||
|
|
||||||
std::unique_ptr<sandbox2::Policy> ModifyPolicy(
|
std::unique_ptr<sandbox2::Policy> ModifyPolicy(
|
||||||
sandbox2::PolicyBuilder*) override {
|
sandbox2::PolicyBuilder*) override {
|
||||||
|
@ -52,16 +50,20 @@ class GdalSapiSandbox : public gdalSandbox {
|
||||||
__NR_ftruncate,
|
__NR_ftruncate,
|
||||||
__NR_unlink,
|
__NR_unlink,
|
||||||
})
|
})
|
||||||
.AddFile(filePath)
|
.AddFile(file_path_)
|
||||||
.BuildOrDie();
|
.BuildOrDie();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string file_path_;
|
||||||
};
|
};
|
||||||
|
|
||||||
absl::Status GdalMain(std::string filename) {
|
absl::Status GdalMain(std::string filename) {
|
||||||
// Reading GDALDataset from a (local, specific) file.
|
// Reading GDALDataset from a (local, specific) file.
|
||||||
GdalSapiSandbox sandbox(filename);
|
GdalSapiSandbox sandbox(filename);
|
||||||
|
|
||||||
SAPI_RETURN_IF_ERROR(sandbox.Init());
|
SAPI_RETURN_IF_ERROR(sandbox.Init());
|
||||||
gdalApi api(&sandbox);
|
GDALApi api(&sandbox);
|
||||||
|
|
||||||
sapi::v::CStr s(filename.data());
|
sapi::v::CStr s(filename.data());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user