diff options
author | Dominique Leuenberger <dimstar@opensuse.org> | 2022-10-24 16:30:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-24 16:30:18 +0200 |
commit | 9d3ee2936e2ab521748973aed9c4aad0e62f72fc (patch) | |
tree | 9ebd98a4f01c15f2ee387f645f9206ee06cddbc5 | |
parent | 7c97571dfbb6bc188d0e7c286fb5f1e143e76d81 (diff) | |
parent | b45477dfc47794a5897cc807f88ada7dd99305fc (diff) | |
download | libproxy-git-9d3ee2936e2ab521748973aed9c4aad0e62f72fc.tar.gz |
Merge pull request #194 from illera88/enable_duktape_windows
Enable the use of ducktape in Windows systems
-rw-r--r-- | libproxy/cmake/modules/pacrunner_duktape.cmk | 12 | ||||
-rw-r--r-- | libproxy/modules/pacrunner_duktape.cpp | 11 |
2 files changed, 21 insertions, 2 deletions
diff --git a/libproxy/cmake/modules/pacrunner_duktape.cmk b/libproxy/cmake/modules/pacrunner_duktape.cmk index a468125..0f2c323 100644 --- a/libproxy/cmake/modules/pacrunner_duktape.cmk +++ b/libproxy/cmake/modules/pacrunner_duktape.cmk @@ -1,11 +1,19 @@ +option(WITH_DUKTAPE "Search for Duktape package" ON) + if(WIN32) set(DUKTAPE_FOUND 0) + if(WITH_DUKTAPE) + find_package(duktape QUIET) + if(DUKTAPE_FOUND) + include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${DUKTAPE_INCLUDE_DIRS}) + link_libraries(${DUKTAPE_LIBRARY}) + set(DUKTAPE_FOUND 1) # find_package sets DUKTAPE_FOUND to True and not 0 + endif() + endif() else() set(DUKTAPE_INCLUDE_DIR "DUKTAPE_INCLUDE_DIR-NOTFOUND" CACHE PATH "Path to Duktape headers") set(DUKTAPE_LIBRARIES "DUKTAPE_LIBRARIES-NOTFOUND" CACHE FILEPATH "Path to Duktape libraries") - option(WITH_DUKTAPE "Search for Duktape package" ON) - if(WITH_DUKTAPE) px_check_modules(DUKTAPE "duktape") diff --git a/libproxy/modules/pacrunner_duktape.cpp b/libproxy/modules/pacrunner_duktape.cpp index 8288e13..a32d946 100644 --- a/libproxy/modules/pacrunner_duktape.cpp +++ b/libproxy/modules/pacrunner_duktape.cpp @@ -19,7 +19,10 @@ ******************************************************************************/ #include "../extension_pacrunner.hpp" +#ifndef WIN32 #include <unistd.h> // gethostname +#endif + using namespace libproxy; #include <duktape.h> @@ -75,6 +78,11 @@ static duk_ret_t myIpAddress(duk_context *ctx) { class duktape_pacrunner : public pacrunner { public: duktape_pacrunner(string pac, const url& pacurl) : pacrunner(pac, pacurl) { +#ifdef WIN32 + // On windows, we need to initialize the winsock dll first. + WSADATA WsaData; + WSAStartup(MAKEWORD(2, 0), &WsaData); +#endif this->ctx = duk_create_heap_default(); if (!this->ctx) goto error; duk_push_c_function(this->ctx, dnsResolve, 1); @@ -103,6 +111,9 @@ public: ~duktape_pacrunner() { duk_destroy_heap(this->ctx); +#ifdef WIN32 + WSACleanup(); +#endif } string run(const url& url_) override { |