Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instruction to build for Windows #240

Open
Wulfheart opened this issue Nov 26, 2021 · 4 comments
Open

Instruction to build for Windows #240

Wulfheart opened this issue Nov 26, 2021 · 4 comments

Comments

@Wulfheart
Copy link

Even though windows support was removed in #234 it would be great to provide instructions on how to use it with an older version.

Do I understand it correctly that it works fine with v0.6.0? Are there any extra steps needed to make it run on Windows?

@dylanahsmith
Copy link
Collaborator

Yes, it should work fine on v0.6.0. https://pkg.go.dev/rogchap.com/v8go@v0.6.0#readme-windows has the instructions for using it with that version. I suppose we could like to that in the README

@Wulfheart
Copy link
Author

Wulfheart commented Nov 26, 2021

This would be helpful.

However, is it possible to build it from Linux with mingw-w64 installed? It should also work with any gcc compiler, shouldn't it?

@dylanahsmith
Copy link
Collaborator

I had trouble cross-compiling V8 for Windows from macOS. There wasn't ever any instructions for cross-compiling for Windows, so I'm not sure if different patches to the V8 build system would be needed, similar to how patches were needed to compile v8 with MinGW on Windows. Although, I didn't put much time getting it to work before deciding it would be easier to just trying to compile for windows on windows.

Ideally, any patches needed to compile V8 with MinGW would be done upstream in V8 itself. The alternative being to use Visual Studio's C/C++ compiler, which is what V8/chromium supports for compiling on Windows (https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/windows_build_instructions.md).

@Wulfheart
Copy link
Author

For future reference: The following GitHub Action worked for me.

# This is a basic workflow to help you get started with Actions

name: Win Build

# Controls when the workflow will run
on:
  workflow_dispatch:

  # Triggers the workflow on push or pull request events but only for the main branch
  #push:
   # branches: [ main ]
  #pull_request:
   # branches: [ main ]

  # Allows you to run this workflow manually from the Actions tab
 
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: windows-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2
      - uses: actions/setup-go@v2
        with:
          go-version: '^1.17.3' # The Go version to download (if necessary) and use.
      - uses: msys2/setup-msys2@v2
        with:
          msystem: MINGW64
          update: true
          install: git mingw-w64-x86_64-toolchain
          
          
      - name: Add MSYS2 to PATH
        run: echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
        shell: bash
        
      # Runs a set of commands using the runners shell
      - name: Build
        run: GOARCH=amd64 GOOS=windows go build -o req-win.exe  
        shell: bash
        
      - name: Archive production artifacts
        uses: actions/upload-artifact@v2
        with:
          name: req-win.exe
          path: ./req-win.exe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants