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

C windows CI setup #458

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/windows-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Set up the environment
run: cmd.exe /c "powershell .\tools\metacall-environment.ps1 $Env:METACALL_INSTALL_OPTIONS"
env:
METACALL_INSTALL_OPTIONS: python nodejs java ruby typescript wasm # netcore5 file rpc java c cobol rust rapidjson funchook swig pack # clangformat v8rep51 coverage
METACALL_INSTALL_OPTIONS: python nodejs c java ruby typescript wasm # netcore5 file rpc java c cobol rust rapidjson funchook swig pack # clangformat v8rep51 coverage

- name: Configure
run: |
Expand All @@ -55,7 +55,7 @@ jobs:
cd "$METACALL_PATH\build"
cmd.exe /c "powershell ..\tools\metacall-configure.ps1 $Env:METACALL_BUILD_OPTIONS"
env:
METACALL_BUILD_OPTIONS: ${{ matrix.options.build }} ${{ matrix.options.sanitizer }} scripts ports tests python nodejs java ruby typescript wasm # netcore5 file rpc java c cobol rust examples install pack benchmarks # v8 coverage
METACALL_BUILD_OPTIONS: ${{ matrix.options.buildtype }} ${{ matrix.options.sanitizer }} scripts ports tests python nodejs c java ruby typescript wasm # netcore5 file rpc java c cobol rust examples install pack benchmarks # v8 coverage

- name: Build
working-directory: ./build
Expand Down
87 changes: 87 additions & 0 deletions tools/metacall-environment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,76 @@ function Set-Ruby {
Write-Output "-DRuby_LIBRARY=""$RubyDir/lib/x64-vcruntime140-ruby310.lib""" >> $Env_Opts
}

function Set-C {
Write-Output "Install C depenendencies"

Set-Location $ROOT_DIR

$DepsDir = "$ROOT_DIR\dependencies"
$repositoryUrl = "https://github.com/newlawrence/Libffi.git"
$destinationPath = "$DepsDir\libffi"
Clone-GitRepository -repositoryUrl $repositoryUrl -destinationPath $destinationPath


mkdir "$destinationPath\build"
Set-Location "$destinationPath\build"

cmake .. -G"Visual Studio 16 2019"

cmake --build . --target ffi

Set-Choco

# choco install llvm -y
choco install llvm -y


$Env_Opts = "$ROOT_DIR\build\CMakeConfig.txt"

$LLVM_Dir1 = "$env:ProgramW6432/LLVM".Replace('\', '/')
# find a way to pass multiple locations to cmake
# $LLVM_Dir2 = "$env:ProgramFiles/LLVM".Replace('\', '/')
$LibFFI_Dir = $destinationPath.Replace('\','/')

Write-Output "-DLIBFFI_LIBRARY=""$LibFFI_Dir/build/lib/libffi.lib""" >> $Env_Opts
Write-Output "-DLIBFFI_INCLUDE_DIR=""$LibFFI_Dir/build/include/""" >> $Env_Opts
Write-Output "-DLibClang_INCLUDE_DIR=""$LLVM_Dir1/include/clang""" >> $Env_Opts

}


function Clone-GitRepository {
param (
[string]$repositoryUrl,
[string]$destinationPath
)

# Check if Git is installed
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
Write-Error "Git is not installed. Please install Git and try again."
return
}

# Check if the destination path already exists
if (Test-Path $destinationPath) {
Write-Error "Destination path already exists. Please provide a different path."
return
}

# Clone the repository using Git
& git clone $repositoryUrl $destinationPath

# Check if the cloning was successful
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to clone the repository."
return
}

Write-Output "Repository cloned successfully."
}



function Add-to-Path {
$GivenPath = $args[0]

Expand Down Expand Up @@ -203,6 +273,22 @@ function Set-TypeScript {
npm i react-dom@latest -g
}

function Set-Choco {
# Set directory for installation - Chocolatey does not lock
# down the directory if not the default
$InstallDir='C:\ProgramData\chocoportable'
$env:ChocolateyInstall="$InstallDir"

# If your PowerShell Execution policy is restrictive, you may
# not be able to get around that. Try setting your session to
# Bypass.
Set-ExecutionPolicy Bypass -Scope Process -Force;

# All install options - offline, proxy, etc at
# https://chocolatey.org/install
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
}

# Configure
function Configure {
# Create option variables file
Expand Down Expand Up @@ -275,6 +361,7 @@ function Configure {
}
if ( "$var" -eq 'c' ) {
Write-Output "c selected"
Set-C
}
if ( "$var" -eq 'cobol' ) {
Write-Output "cobol selected"
Expand Down
Loading