diff options
Diffstat (limited to 'samples')
-rw-r--r-- | samples/BUILD.gn | 19 | ||||
-rw-r--r-- | samples/pdfium_test.cc | 11 | ||||
-rw-r--r-- | samples/samples.gyp | 25 |
3 files changed, 45 insertions, 10 deletions
diff --git a/samples/BUILD.gn b/samples/BUILD.gn index 957b1b6b91..f3bcbda418 100644 --- a/samples/BUILD.gn +++ b/samples/BUILD.gn @@ -16,8 +16,11 @@ config("pdfium_samples_config") { "PNGPREFIX_H", "PNG_USE_READ_MACROS", ] + if (pdf_enable_v8) { + defines += [ "PDF_ENABLE_V8", ] + } if (pdf_enable_xfa) { - defines += [ "PDF_ENABLE_XFA" ] + defines += [ "PDF_ENABLE_XFA", ] } } @@ -28,12 +31,16 @@ executable("pdfium_test") { ] deps = [ "//third_party/pdfium", - "//v8:v8_libplatform", - ] - include_dirs = [ - "//v8", - "//v8/include", ] + if (pdf_enable_v8) { + deps += [ + "//v8:v8_libplatform", + ] + include_dirs = [ + "//v8", + "//v8/include", + ] + } configs += [ ":pdfium_samples_config" ] } diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc index a17a85390d..0525f24067 100644 --- a/samples/pdfium_test.cc +++ b/samples/pdfium_test.cc @@ -20,9 +20,10 @@ #include "../public/fpdf_text.h" #include "../public/fpdfview.h" #include "image_diff_png.h" +#ifdef PDF_ENABLE_V8 #include "v8/include/libplatform/libplatform.h" #include "v8/include/v8.h" - +#endif #ifdef _WIN32 #define snprintf _snprintf @@ -81,6 +82,7 @@ static char* GetFileContents(const char* filename, size_t* retlen) { return buffer; } +#ifdef PDF_ENABLE_V8 #ifdef V8_USE_EXTERNAL_STARTUP_DATA // Returns the full path for an external V8 data file based on either // the currect exectuable path or an explicit override. @@ -118,6 +120,7 @@ static bool GetExternalData(const Options& options, return true; } #endif // V8_USE_EXTERNAL_STARTUP_DATA +#endif // PDF_ENABLE_V8 static bool CheckDimensions(int stride, int width, int height) { if (stride < 0 || width < 0 || height < 0) @@ -373,6 +376,7 @@ bool ParseCommandLine(const std::vector<std::string>& args, options->output_format = OUTPUT_BMP; } #endif // _WIN32 +#ifdef PDF_ENABLE_V8 #ifdef V8_USE_EXTERNAL_STARTUP_DATA else if (cur_arg.size() > 10 && cur_arg.compare(0, 10, "--bin-dir=") == 0) { if (!options->bin_directory.empty()) { @@ -382,6 +386,7 @@ bool ParseCommandLine(const std::vector<std::string>& args, options->bin_directory = cur_arg.substr(10); } #endif // V8_USE_EXTERNAL_STARTUP_DATA +#endif // PDF_ENABLE_V8 else if (cur_arg.size() > 8 && cur_arg.compare(0, 8, "--scale=") == 0) { if (!options->scale_factor_as_string.empty()) { fprintf(stderr, "Duplicate --scale argument\n"); @@ -605,6 +610,7 @@ int main(int argc, const char* argv[]) { return 1; } +#ifdef PDF_ENABLE_V8 v8::V8::InitializeICU(); v8::Platform* platform = v8::platform::CreateDefaultPlatform(); v8::V8::InitializePlatform(platform); @@ -620,6 +626,7 @@ int main(int argc, const char* argv[]) { v8::V8::SetNativesDataBlob(&natives); v8::V8::SetSnapshotDataBlob(&snapshot); #endif // V8_USE_EXTERNAL_STARTUP_DATA +#endif // PDF_ENABLE_V8 FPDF_LIBRARY_CONFIG config; config.version = 2; @@ -654,8 +661,10 @@ int main(int argc, const char* argv[]) { } FPDF_DestroyLibrary(); +#ifdef PDF_ENABLE_V8 v8::V8::ShutdownPlatform(); delete platform; +#endif // PDF_ENABLE_V8 return 0; } diff --git a/samples/samples.gyp b/samples/samples.gyp index 97497ee2d9..e39af20882 100644 --- a/samples/samples.gyp +++ b/samples/samples.gyp @@ -3,30 +3,49 @@ # found in the LICENSE file. { + 'variables': { + 'pdf_enable_v8%': 1, + }, 'target_defaults': { 'type': 'executable', 'dependencies': [ '../pdfium.gyp:pdfium', - '<(DEPTH)/v8/tools/gyp/v8.gyp:v8_libplatform', ], 'include_dirs': [ '<(DEPTH)', - '<(DEPTH)/v8', - '<(DEPTH)/v8/include', ], 'defines' : [ 'PNG_PREFIX', 'PNGPREFIX_H', 'PNG_USE_READ_MACROS', ], + 'conditions': [ + ['pdf_enable_v8==1', { + 'defines': [ + 'PDF_ENABLE_V8', + ], + 'include_dirs': [ + '<(DEPTH)/v8', + '<(DEPTH)/v8/include', + ], + }], + ], }, 'targets': [ { 'target_name': 'pdfium_test', + 'type': 'executable', 'sources': [ 'pdfium_test.cc', 'image_diff_png.cc', ], + 'conditions': [ + ['pdf_enable_v8==1', { + 'dependencies': [ + '<(DEPTH)/v8/tools/gyp/v8.gyp:v8_libplatform', + ], + }], + ], }, { 'target_name': 'pdfium_diff', |