From ba378e4c5236b3df956f55c97e635dc24e52198e Mon Sep 17 00:00:00 2001 From: neptoess Date: Wed, 16 Dec 2020 11:47:36 -0500 Subject: [PATCH 1/5] Support MSYS2 MinGW64 builds --- cgo.go | 5 ++++- v8go.cc | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cgo.go b/cgo.go index 2ac6c24a..e00044b6 100644 --- a/cgo.go +++ b/cgo.go @@ -1,7 +1,10 @@ package v8go -// #cgo CXXFLAGS: -fno-rtti -fpic -std=c++14 -I${SRCDIR}/deps/include +// #cgo CXXFLAGS: -fno-rtti -fpic -std=c++14 +// #cgo !windows CXXFLAGS: -I${SRCDIR}/deps/include +// #cgo windows CXXFLAGS: -DV8_COMPRESS_POINTERS -DV8_31BIT_SMIS_ON_64BIT_ARCH // #cgo LDFLAGS: -pthread -lv8 +// #cgo windows LDFLAGS: -lv8_libplatform // #cgo darwin LDFLAGS: -L${SRCDIR}/deps/darwin-x86_64 // #cgo linux LDFLAGS: -L${SRCDIR}/deps/linux-x86_64 import "C" diff --git a/v8go.cc b/v8go.cc index 2ea3c1de..b393dfb1 100644 --- a/v8go.cc +++ b/v8go.cc @@ -85,6 +85,9 @@ extern "C" /********** Isolate **********/ void Init() { +#ifdef _WIN32 + V8::InitializeExternalStartupData("."); +#endif V8::InitializePlatform(default_platform.get()); V8::Initialize(); return; From 458d4c7ef1f7927c44aae7f6a9b12f9d7a190bd1 Mon Sep 17 00:00:00 2001 From: neptoess Date: Wed, 16 Dec 2020 16:45:53 -0500 Subject: [PATCH 2/5] Update README.md to include instructions for setting up Windows dev environments --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 39af9acd..866d99e9 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,18 @@ are included for Linux and OSX ie. you *should not* require to build V8 yourself V8 requires 64-bit, therefore will not work on 32-bit systems. +## Windows +While no prebuilt static V8 library is included for Windows, MSYS2 provides a package containing +a dynamically linked V8 library that works. + +To set this up: +1. Install MSYS2 (https://www.msys2.org/) +2. Add the Mingw-w64 bin to your PATH environment variable (`C:\msys64\mingw64\bin` by default) +3. Open MSYS2 MSYS and execute `pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-v8` +4. This will allow building projects that depend on `v8go`, but, in order to actually run them, + you will need to copy the `snapshot_blob.bin` file from the Mingw-w64 bin folder to your program's + working directory (which is typically whereever `main.go` is) + --- V8 Gopher image based on original artwork from the amazing [Renee French](http://reneefrench.blogspot.com). From bc276562dc1509cc15971b8116836efb927a1431 Mon Sep 17 00:00:00 2001 From: Bill Rose Date: Wed, 16 Dec 2020 17:31:54 -0500 Subject: [PATCH 3/5] Update README.md Co-authored-by: Roger Chapman --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 866d99e9..d6468e76 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ To set this up: 3. Open MSYS2 MSYS and execute `pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-v8` 4. This will allow building projects that depend on `v8go`, but, in order to actually run them, you will need to copy the `snapshot_blob.bin` file from the Mingw-w64 bin folder to your program's - working directory (which is typically whereever `main.go` is) + working directory (which is typically wherever `main.go` is) --- From 4ad0dfad2429850d1c49a61f2c491349e2a3973d Mon Sep 17 00:00:00 2001 From: neptoess Date: Thu, 17 Dec 2020 17:49:21 -0500 Subject: [PATCH 4/5] Switch up #cgo flags to match master --- cgo.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cgo.go b/cgo.go index e00044b6..4f30f29a 100644 --- a/cgo.go +++ b/cgo.go @@ -1,8 +1,7 @@ package v8go -// #cgo CXXFLAGS: -fno-rtti -fpic -std=c++14 -// #cgo !windows CXXFLAGS: -I${SRCDIR}/deps/include -// #cgo windows CXXFLAGS: -DV8_COMPRESS_POINTERS -DV8_31BIT_SMIS_ON_64BIT_ARCH +// #cgo CXXFLAGS: -fno-rtti -fpic -std=c++14 -DV8_COMPRESS_POINTERS -DV8_31BIT_SMIS_ON_64BIT_ARCH +// #cgo (darwin OR linux) CXXFLAGS: -I${SRCDIR}/deps/include // #cgo LDFLAGS: -pthread -lv8 // #cgo windows LDFLAGS: -lv8_libplatform // #cgo darwin LDFLAGS: -L${SRCDIR}/deps/darwin-x86_64 From b4162ebf5f88aada98e67360ab362b3f8a465e0a Mon Sep 17 00:00:00 2001 From: neptoess Date: Thu, 17 Dec 2020 18:20:08 -0500 Subject: [PATCH 5/5] Use correct syntax for #cgo constraints --- cgo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cgo.go b/cgo.go index 4f30f29a..199181f4 100644 --- a/cgo.go +++ b/cgo.go @@ -1,7 +1,7 @@ package v8go // #cgo CXXFLAGS: -fno-rtti -fpic -std=c++14 -DV8_COMPRESS_POINTERS -DV8_31BIT_SMIS_ON_64BIT_ARCH -// #cgo (darwin OR linux) CXXFLAGS: -I${SRCDIR}/deps/include +// #cgo darwin linux CXXFLAGS: -I${SRCDIR}/deps/include // #cgo LDFLAGS: -pthread -lv8 // #cgo windows LDFLAGS: -lv8_libplatform // #cgo darwin LDFLAGS: -L${SRCDIR}/deps/darwin-x86_64