mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
compile djvu
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
SET SCRIPTPATH=%~dp0
|
||||
CD /D %~dp0
|
||||
|
||||
call ../emsdk/emsdk_env.bat
|
||||
call emsdk/emsdk_env.bat
|
||||
|
||||
call em++ -o djvu.js^
|
||||
call emcc -o djvu.js^
|
||||
-O3^
|
||||
-fno-rtti^
|
||||
-s WASM=1^
|
||||
@ -12,61 +12,61 @@ call em++ -o djvu.js^
|
||||
-s ENVIRONMENT='web'^
|
||||
-s ERROR_ON_UNDEFINED_SYMBOLS=0^
|
||||
-s EXPORTED_FUNCTIONS="['_malloc', '_free', '_DJVU_Load', '_DJVU_Close', '_DJVU_GetInfo', '_DJVU_GetPixmap', '_DJVU_Delete']"^
|
||||
"libdjvu/Arrays.cpp"^
|
||||
"libdjvu/BSByteStream.cpp"^
|
||||
"libdjvu/BSEncodeByteStream.cpp"^
|
||||
"libdjvu/ByteStream.cpp"^
|
||||
"libdjvu/DataPool.cpp"^
|
||||
"libdjvu/debug.cpp"^
|
||||
"libdjvu/DjVmDir.cpp"^
|
||||
"libdjvu/DjVmDir0.cpp"^
|
||||
"libdjvu/DjVmDoc.cpp"^
|
||||
"libdjvu/DjVmNav.cpp"^
|
||||
"libdjvu/DjVuAnno.cpp"^
|
||||
"libdjvu/DjVuDocEditor.cpp"^
|
||||
"libdjvu/DjVuDocument.cpp"^
|
||||
"libdjvu/DjVuDumpHelper.cpp"^
|
||||
"libdjvu/DjVuErrorList.cpp"^
|
||||
"libdjvu/DjVuFile.cpp"^
|
||||
"libdjvu/DjVuFileCache.cpp"^
|
||||
"libdjvu/DjVuGlobal.cpp"^
|
||||
"libdjvu/DjVuGlobalMemory.cpp"^
|
||||
"libdjvu/DjVuImage.cpp"^
|
||||
"libdjvu/DjVuInfo.cpp"^
|
||||
"libdjvu/DjVuMessageLite.cpp"^
|
||||
"libdjvu/DjVuNavDir.cpp"^
|
||||
"libdjvu/DjVuPalette.cpp"^
|
||||
"libdjvu/DjVuPort.cpp"^
|
||||
"libdjvu/DjVuText.cpp"^
|
||||
"libdjvu/DjVuToPS.cpp"^
|
||||
"libdjvu/GBitmap.cpp"^
|
||||
"libdjvu/GContainer.cpp"^
|
||||
"libdjvu/GException.cpp"^
|
||||
"libdjvu/GIFFManager.cpp"^
|
||||
"libdjvu/GMapAreas.cpp"^
|
||||
"libdjvu/GPixmap.cpp"^
|
||||
"libdjvu/GRect.cpp"^
|
||||
"libdjvu/GScaler.cpp"^
|
||||
"libdjvu/GSmartPointer.cpp"^
|
||||
"libdjvu/GString.cpp"^
|
||||
"libdjvu/GThreads.cpp"^
|
||||
"libdjvu/GUnicode.cpp"^
|
||||
"libdjvu/IFFByteStream.cpp"^
|
||||
"libdjvu/IW44EncodeCodec.cpp"^
|
||||
"libdjvu/IW44Image.cpp"^
|
||||
"libdjvu/JB2EncodeCodec.cpp"^
|
||||
"libdjvu/JB2Image.cpp"^
|
||||
"libdjvu/JPEGDecoder.cpp"^
|
||||
"libdjvu/MMRDecoder.cpp"^
|
||||
"libdjvu/MMX.cpp"^
|
||||
"libdjvu/UnicodeByteStream.cpp"^
|
||||
"libdjvu/XMLParser.cpp"^
|
||||
"libdjvu/XMLTags.cpp"^
|
||||
"libdjvu/ZPCodec.cpp"^
|
||||
"libdjvu/wasm/atomic.cpp"^
|
||||
"libdjvu/wasm/DjVuMessage.cpp"^
|
||||
"libdjvu/wasm/GOS.cpp"^
|
||||
"libdjvu/wasm/GURL.cpp"^
|
||||
"../libdjvu/Arrays.cpp"^
|
||||
"../libdjvu/BSByteStream.cpp"^
|
||||
"../libdjvu/BSEncodeByteStream.cpp"^
|
||||
"../libdjvu/ByteStream.cpp"^
|
||||
"../libdjvu/DataPool.cpp"^
|
||||
"../libdjvu/debug.cpp"^
|
||||
"../libdjvu/DjVmDir.cpp"^
|
||||
"../libdjvu/DjVmDir0.cpp"^
|
||||
"../libdjvu/DjVmDoc.cpp"^
|
||||
"../libdjvu/DjVmNav.cpp"^
|
||||
"../libdjvu/DjVuAnno.cpp"^
|
||||
"../libdjvu/DjVuDocEditor.cpp"^
|
||||
"../libdjvu/DjVuDocument.cpp"^
|
||||
"../libdjvu/DjVuDumpHelper.cpp"^
|
||||
"../libdjvu/DjVuErrorList.cpp"^
|
||||
"../libdjvu/DjVuFile.cpp"^
|
||||
"../libdjvu/DjVuFileCache.cpp"^
|
||||
"../libdjvu/DjVuGlobal.cpp"^
|
||||
"../libdjvu/DjVuGlobalMemory.cpp"^
|
||||
"../libdjvu/DjVuImage.cpp"^
|
||||
"../libdjvu/DjVuInfo.cpp"^
|
||||
"../libdjvu/DjVuMessageLite.cpp"^
|
||||
"../libdjvu/DjVuNavDir.cpp"^
|
||||
"../libdjvu/DjVuPalette.cpp"^
|
||||
"../libdjvu/DjVuPort.cpp"^
|
||||
"../libdjvu/DjVuText.cpp"^
|
||||
"../libdjvu/DjVuToPS.cpp"^
|
||||
"../libdjvu/GBitmap.cpp"^
|
||||
"../libdjvu/GContainer.cpp"^
|
||||
"../libdjvu/GException.cpp"^
|
||||
"../libdjvu/GIFFManager.cpp"^
|
||||
"../libdjvu/GMapAreas.cpp"^
|
||||
"../libdjvu/GPixmap.cpp"^
|
||||
"../libdjvu/GRect.cpp"^
|
||||
"../libdjvu/GScaler.cpp"^
|
||||
"../libdjvu/GSmartPointer.cpp"^
|
||||
"../libdjvu/GString.cpp"^
|
||||
"../libdjvu/GThreads.cpp"^
|
||||
"../libdjvu/GUnicode.cpp"^
|
||||
"../libdjvu/IFFByteStream.cpp"^
|
||||
"../libdjvu/IW44EncodeCodec.cpp"^
|
||||
"../libdjvu/IW44Image.cpp"^
|
||||
"../libdjvu/JB2EncodeCodec.cpp"^
|
||||
"../libdjvu/JB2Image.cpp"^
|
||||
"../libdjvu/JPEGDecoder.cpp"^
|
||||
"../libdjvu/MMRDecoder.cpp"^
|
||||
"../libdjvu/MMX.cpp"^
|
||||
"../libdjvu/UnicodeByteStream.cpp"^
|
||||
"../libdjvu/XMLParser.cpp"^
|
||||
"../libdjvu/XMLTags.cpp"^
|
||||
"../libdjvu/ZPCodec.cpp"^
|
||||
"libdjvu/atomic.cpp"^
|
||||
"libdjvu/DjVuMessage.cpp"^
|
||||
"libdjvu/GOS.cpp"^
|
||||
"libdjvu/GURL.cpp"^
|
||||
"djvu_common.cpp"^
|
||||
-DWIN32^
|
||||
-DNDEBUG^
|
||||
@ -82,7 +82,7 @@ echo "finalize..."
|
||||
|
||||
call powershell -Command "(Get-Content ./djvu.js) -replace 'function getBinaryPromise\(\){', 'function getBinaryPromise2(){' | Set-Content ./djvu.js"
|
||||
|
||||
if not exist "./deploy/djvu" mkdir "./../deploy/djvu"
|
||||
if not exist "./../deploy/djvu" mkdir "./../deploy/djvu"
|
||||
|
||||
call powershell -Command "(Get-Content ./djvu_base.js) -replace '//module', (Get-Content ./djvu.js) | Set-Content ./../deploy/djvu/djvu.js"
|
||||
call echo f | xcopy /b/v/y/f "djvu.wasm" "./../deploy/djvu/djvu.wasm"
|
||||
|
||||
@ -90,7 +90,7 @@
|
||||
CFile.prototype = Object.create(AscViewer.IFile.prototype);
|
||||
CFile.prototype.constructor = CFile;
|
||||
|
||||
CFile.prototype.load = function(arrayBuffer)
|
||||
CFile.prototype.loadFromData = function(arrayBuffer)
|
||||
{
|
||||
var data = new Uint8Array(arrayBuffer);
|
||||
var _stream = Module["_malloc"](data.length);
|
||||
|
||||
@ -87,9 +87,9 @@ unsigned char* DJVU_GetPixmap(CDjvuFile* file, int page_index, int w, int h)
|
||||
|
||||
for (int i = 0; i < w; ++i, pixmap_cur += 4, ++pLine)
|
||||
{
|
||||
pixmap_cur[0] = pLine->b;
|
||||
pixmap_cur[0] = pLine->r;
|
||||
pixmap_cur[1] = pLine->g;
|
||||
pixmap_cur[2] = pLine->r;
|
||||
pixmap_cur[2] = pLine->b;
|
||||
pixmap_cur[3] = 255;
|
||||
}
|
||||
}
|
||||
@ -146,9 +146,9 @@ unsigned char* DJVU_GetPixmap(CDjvuFile* file, int page_index, int w, int h)
|
||||
|
||||
for (int i = 0; i < w; ++i, pixmap_cur += 4, ++pLine)
|
||||
{
|
||||
pixmap_cur[0] = pLine->b;
|
||||
pixmap_cur[0] = pLine->r;
|
||||
pixmap_cur[1] = pLine->g;
|
||||
pixmap_cur[2] = pLine->r;
|
||||
pixmap_cur[2] = pLine->b;
|
||||
pixmap_cur[3] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,12 +66,12 @@
|
||||
// From: Leon Bottou, 1/31/2002
|
||||
// All these XML messages are Lizardtech innovations.
|
||||
|
||||
#include "./../libdjvu/DjVuMessage.h"
|
||||
#include "./../libdjvu/GOS.h"
|
||||
#include "./../libdjvu/XMLTags.h"
|
||||
#include "./../libdjvu/ByteStream.h"
|
||||
#include "./../libdjvu/GURL.h"
|
||||
#include "./../libdjvu/debug.h"
|
||||
#include "./../../libdjvu/DjVuMessage.h"
|
||||
#include "./../../libdjvu/GOS.h"
|
||||
#include "./../../libdjvu/XMLTags.h"
|
||||
#include "./../../libdjvu/ByteStream.h"
|
||||
#include "./../../libdjvu/GURL.h"
|
||||
#include "./../../libdjvu/debug.h"
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -63,7 +63,7 @@
|
||||
# pragma implementation
|
||||
#endif
|
||||
|
||||
#include "./../libdjvu/GOS.h"
|
||||
#include "./../../libdjvu/GOS.h"
|
||||
|
||||
// basename(filename[, suffix])
|
||||
// -- returns the last component of filename and removes suffix
|
||||
|
||||
@ -70,10 +70,10 @@
|
||||
// mixture of code for syntactically parsing the urls (which it was)
|
||||
// and file status code (only for local file: urls).
|
||||
|
||||
#include "./../libdjvu/GException.h"
|
||||
#include "./../libdjvu/GOS.h"
|
||||
#include "./../libdjvu/GURL.h"
|
||||
#include "./../libdjvu/debug.h"
|
||||
#include "./../../libdjvu/GException.h"
|
||||
#include "./../../libdjvu/GOS.h"
|
||||
#include "./../../libdjvu/GURL.h"
|
||||
#include "./../../libdjvu/debug.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "../libdjvu/atomic.h"
|
||||
#include "../../libdjvu/atomic.h"
|
||||
|
||||
int
|
||||
atomicAcquire(int volatile *lock)
|
||||
|
||||
96
DjVuFile/wasm/make.py
Normal file
96
DjVuFile/wasm/make.py
Normal file
@ -0,0 +1,96 @@
|
||||
import sys
|
||||
sys.path.append("../../../build_tools/scripts")
|
||||
import base
|
||||
import os
|
||||
|
||||
base.configure_common_apps()
|
||||
|
||||
# remove previous version
|
||||
if base.is_dir("./deploy"):
|
||||
base.delete_dir("./deploy")
|
||||
base.create_dir("./deploy")
|
||||
base.create_dir("./deploy/djvu")
|
||||
|
||||
# fetch emsdk
|
||||
command_prefix = "" if ("windows" == base.host_platform()) else "./"
|
||||
if not base.is_dir("emsdk"):
|
||||
base.cmd("git", ["clone", "https://github.com/emscripten-core/emsdk.git"])
|
||||
os.chdir("emsdk")
|
||||
base.cmd(command_prefix + "emsdk", ["install", "latest"])
|
||||
base.cmd(command_prefix + "emsdk", ["activate", "latest"])
|
||||
os.chdir("../")
|
||||
|
||||
# compile
|
||||
compiler_flags = ["-O3",
|
||||
"-fno-rtti",
|
||||
"-s WASM=1",
|
||||
"-s ALLOW_MEMORY_GROWTH=1",
|
||||
"-s FILESYSTEM=0",
|
||||
"-s ENVIRONMENT='web'",
|
||||
"-s ERROR_ON_UNDEFINED_SYMBOLS=0"]
|
||||
|
||||
exported_functions = ["_malloc",
|
||||
"_free",
|
||||
"_DJVU_Load",
|
||||
"_DJVU_Close",
|
||||
"_DJVU_GetInfo",
|
||||
"_DJVU_GetPixmap",
|
||||
"_DJVU_Delete"]
|
||||
|
||||
libDjVu_src_path = "../libdjvu/"
|
||||
input_djvu_sources = ["Arrays.cpp", "BSByteStream.cpp", "BSEncodeByteStream.cpp", "ByteStream.cpp", "DataPool.cpp", "debug.cpp", "DjVmDir.cpp", "DjVmDir0.cpp", "DjVmDoc.cpp", "DjVmNav.cpp", "DjVuAnno.cpp", "DjVuDocEditor.cpp", "DjVuDocument.cpp", "DjVuDumpHelper.cpp", "DjVuErrorList.cpp", "DjVuFile.cpp", "DjVuFileCache.cpp", "DjVuGlobal.cpp", "DjVuGlobalMemory.cpp", "DjVuImage.cpp", "DjVuInfo.cpp", "DjVuMessageLite.cpp", "DjVuNavDir.cpp", "DjVuPalette.cpp", "DjVuPort.cpp", "DjVuText.cpp", "DjVuToPS.cpp", "GBitmap.cpp", "GContainer.cpp", "GException.cpp", "GIFFManager.cpp", "GMapAreas.cpp", "GPixmap.cpp", "GRect.cpp", "GScaler.cpp", "GSmartPointer.cpp", "GString.cpp", "GThreads.cpp", "GUnicode.cpp", "IFFByteStream.cpp", "IW44EncodeCodec.cpp", "IW44Image.cpp", "JB2EncodeCodec.cpp", "JB2Image.cpp", "JPEGDecoder.cpp", "MMRDecoder.cpp", "MMX.cpp", "UnicodeByteStream.cpp", "XMLParser.cpp", "XMLTags.cpp", "ZPCodec.cpp"]
|
||||
|
||||
libWasmDjVu_src_path = "libdjvu/"
|
||||
input_wasmdjvu_sources = ["atomic.cpp", "DjVuMessage.cpp", "GOS.cpp", "GURL.cpp"]
|
||||
|
||||
# sources
|
||||
sources = []
|
||||
for item in input_djvu_sources:
|
||||
sources.append(libDjVu_src_path + item)
|
||||
for item in input_wasmdjvu_sources:
|
||||
sources.append(libWasmDjVu_src_path + item)
|
||||
sources.append("djvu_common.cpp")
|
||||
|
||||
compiler_flags.append("-DWIN32 -DNDEBUG -D_LIB -D_CRT_SECURE_NO_WARNINGS -DWASM_MODE -Derrno=0 \"-DUINT=unsigned int\" -DTHREADMODEL=0 -DDEBUGLVL=0")
|
||||
|
||||
# arguments
|
||||
arguments = ""
|
||||
for item in compiler_flags:
|
||||
arguments += (item + " ")
|
||||
arguments += "-s EXPORTED_FUNCTIONS=\"["
|
||||
for item in exported_functions:
|
||||
arguments += ("'" + item + "',")
|
||||
arguments = arguments[:-1]
|
||||
arguments += "]\" "
|
||||
|
||||
for item in sources:
|
||||
arguments += (item + " ")
|
||||
|
||||
# command
|
||||
windows_bat = []
|
||||
if base.host_platform() == "windows":
|
||||
windows_bat.append("call emsdk/emsdk_env.bat")
|
||||
windows_bat.append("call emcc -o djvu.js " + arguments)
|
||||
else:
|
||||
windows_bat.append("#!/bin/bash")
|
||||
windows_bat.append("source ./emsdk/emsdk_env.sh")
|
||||
windows_bat.append("emcc -o djvu.js " + arguments)
|
||||
base.run_as_bat(windows_bat)
|
||||
|
||||
# finalize
|
||||
base.replaceInFile("./djvu.js", "function getBinaryPromise(){", "function getBinaryPromise2(){")
|
||||
|
||||
djvu_js_content = base.readFile("./djvu.js")
|
||||
engine_base_js_content = base.readFile("./djvu_base.js")
|
||||
engine_js_content = engine_base_js_content.replace("//module", djvu_js_content)
|
||||
|
||||
# write new version
|
||||
base.writeFile("./deploy/djvu/djvu.js", engine_js_content)
|
||||
base.copy_file("./djvu.wasm", "./deploy/djvu/djvu.wasm")
|
||||
base.copy_file("./all_files_test/index.html", "./deploy/index.html")
|
||||
base.copy_file("./all_files_test/code.js", "./deploy/code.js")
|
||||
base.copy_file("./all_files_test/file.js", "./deploy/file.js")
|
||||
base.copy_dir("./all_files_test/pdf", "./deploy/pdf")
|
||||
|
||||
base.delete_file("djvu.js")
|
||||
base.delete_file("djvu.wasm")
|
||||
Reference in New Issue
Block a user