prt_ps: Remove build time ghostscript dependency

Also took the opportunity to rename the immediate PS dumps to .tmp
This commit is contained in:
David Hrdlička 2020-04-04 01:52:08 +02:00
parent b9905ca3c8
commit 8bcacb1a59
2 changed files with 34 additions and 25 deletions

View file

@ -33,7 +33,7 @@ guide:
1. Install the [MSYS2](https://www.msys2.org/) environment. The rest of the guide will refer to the directory that you install it to (C:\msys32 or C:\msys64 by default) as the MSYS2 root.
2. Launch your MSYS2 environment using the `MSYS2 MinGW 32-bit` shortcut. If you do not want to use the shortcut, launch it with `<MSYS2 root>\mingw32.exe`.
3. Once launched, run `pacman -Syu` in order to update the environment. You may need to do this twice, just follow the on-screen instructions. Make sure you re-run `pacman -Syu` periodically to keep the environment up-to-date.
4. Run the following command to install all of the dependencies: `pacman -S gdb make git mingw-w64-i686-toolchain mingw-w64-i686-openal mingw-w64-i686-freetype mingw-w64-i686-SDL2 mingw-w64-i686-zlib mingw-w64-i686-libpng mingw-w64-i686-ghostscript`. Additionally, you will need to download the developer's pack of WinPcap [from here](https://www.winpcap.org/devel.htm), and extract it into `<MSYS2 root>\mingw32\`.
4. Run the following command to install all of the dependencies: `pacman -S gdb make git mingw-w64-i686-toolchain mingw-w64-i686-openal mingw-w64-i686-freetype mingw-w64-i686-SDL2 mingw-w64-i686-zlib mingw-w64-i686-libpng`. Additionally, you will need to download the developer's pack of WinPcap [from here](https://www.winpcap.org/devel.htm), and extract it into `<MSYS2 root>\mingw32\`.
5. Once the environment is fully updated and all dependencies are installed, `cd` into your cloned `86box\src`
directory.
6. Run `make -jN -f win/makefile.mingw` to start the actual compilation process.

View file

@ -32,32 +32,41 @@
#include <86box/ui.h>
#include <86box/prt_devs.h>
#if defined(_WIN32) && !defined(__WINDOWS__)
#define __WINDOWS__
#ifdef _WIN32
# define GSDLLAPI __stdcall
#else
# define GSDLLAPI
#endif
#include <ghostscript/iapi.h>
#include <ghostscript/ierrors.h>
#define GS_ARG_ENCODING_UTF16LE 2
#define gs_error_Quit -101
#define PATH_GHOSTSCRIPT_DLL "gsdll32.dll"
#define PATH_GHOSTSCRIPT_SO "libgs.so"
#define POSTSCRIPT_BUFFER_LENGTH 65536
static GSDLLAPI int (*ghostscript_revision)(gsapi_revision_t *pr, int len);
static GSDLLAPI int (*ghostscript_new_instance)(void **pinstance, void *caller_handle);
static GSDLLAPI void (*ghostscript_delete_instance)(void *instance);
static GSDLLAPI int (*ghostscript_set_arg_encoding)(void *instance, int encoding);
static GSDLLAPI int (*ghostscript_init_with_args)(void *instance, int argc, char **argv);
static GSDLLAPI int (*ghostscript_exit)(void *instance);
typedef struct gsapi_revision_s {
const char *product;
const char *copyright;
long revision;
long revisiondate;
} gsapi_revision_t;
static GSDLLAPI int (*gsapi_revision)(gsapi_revision_t *pr, int len);
static GSDLLAPI int (*gsapi_new_instance)(void **pinstance, void *caller_handle);
static GSDLLAPI void (*gsapi_delete_instance)(void *instance);
static GSDLLAPI int (*gsapi_set_arg_encoding)(void *instance, int encoding);
static GSDLLAPI int (*gsapi_init_with_args)(void *instance, int argc, char **argv);
static GSDLLAPI int (*gsapi_exit)(void *instance);
static dllimp_t ghostscript_imports[] = {
{ "gsapi_revision", &ghostscript_revision },
{ "gsapi_new_instance", &ghostscript_new_instance },
{ "gsapi_delete_instance", &ghostscript_delete_instance },
{ "gsapi_set_arg_encoding", &ghostscript_set_arg_encoding },
{ "gsapi_init_with_args", &ghostscript_init_with_args },
{ "gsapi_exit", &ghostscript_exit },
{ "gsapi_revision", &gsapi_revision },
{ "gsapi_new_instance", &gsapi_new_instance },
{ "gsapi_delete_instance", &gsapi_delete_instance },
{ "gsapi_set_arg_encoding", &gsapi_set_arg_encoding },
{ "gsapi_init_with_args", &gsapi_init_with_args },
{ "gsapi_exit", &gsapi_exit },
{ NULL, NULL }
};
@ -143,24 +152,24 @@ convert_to_pdf(ps_t *dev)
gsargv[7] = output_fn;
gsargv[8] = input_fn;
code = ghostscript_new_instance(&instance, dev);
code = gsapi_new_instance(&instance, dev);
if (code < 0) {
return code;
}
code = ghostscript_set_arg_encoding(instance, GS_ARG_ENCODING_UTF16LE);
code = gsapi_set_arg_encoding(instance, GS_ARG_ENCODING_UTF16LE);
if (code == 0) {
code = ghostscript_init_with_args(instance, 9, (char **) gsargv);
code = gsapi_init_with_args(instance, 9, (char **) gsargv);
}
if (code == 0 || code == gs_error_Quit) {
code = ghostscript_exit(instance);
code = gsapi_exit(instance);
} else {
ghostscript_exit(instance);
gsapi_exit(instance);
}
ghostscript_delete_instance(instance);
gsapi_delete_instance(instance);
if (code == 0) {
plat_remove(input_fn);
@ -192,7 +201,7 @@ write_buffer(ps_t *dev, bool newline)
}
if (dev->filename[0] == 0) {
plat_tempfile(dev->filename, NULL, L".ps");
plat_tempfile(dev->filename, NULL, L".tmp");
}
path[0] = 0;
@ -351,7 +360,7 @@ ps_init(void *lpt)
if (ghostscript_handle == NULL) {
ui_msgbox(MBX_ERROR, (wchar_t *) IDS_2123);
} else {
if (ghostscript_revision(&rev, sizeof(rev)) == 0) {
if (gsapi_revision(&rev, sizeof(rev)) == 0) {
pclog("Loaded %s, rev %ld (%ld)\n", rev.product, rev.revision, rev.revisiondate);
} else {
dynld_close(ghostscript_handle);