Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Update windows build #143

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build
.vscode/
build/
/stable/test/integration/tmp/**
!/stable/test/integration/tmp/.gitkeep
# generated
Expand Down
57 changes: 0 additions & 57 deletions make.bat

This file was deleted.

177 changes: 177 additions & 0 deletions make.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
Param(
[Parameter(Position=0, Mandatory=$true, HelpMessage="The action to take (build, test, install, package, clean).")]
[string]
$Command,

[Parameter(HelpMessage="The build configuration (Release, Debug).")]
[string]
$Config = "Release",

[Parameter(HelpMessage="The version number to set.")]
[string]
$Version = "",

[Parameter(HelpMessage="Architecture (native, x64).")]
[string]
$Arch = "x86-64",

[Parameter(HelpMessage="Directory to install to.")]
[string]
$Destdir = "build/install"
)

$ErrorActionPreference = "Stop"

$rootDir = Split-Path $script:MyInvocation.MyCommand.Path
$srcDir = Join-Path -Path $rootDir -ChildPath "stable"

if ($Config -ieq "Release")
{
$configFlag = ""
$buildDir = Join-Path -Path $rootDir -ChildPath "build/release"
}
elseif ($Config -ieq "Debug")
{
$configFlag = "--debug"
$buildDir = Join-Path -Path $rootDir -ChildPath "build/debug"
}
else
{
throw "Invalid -Config path '$Config'; must be one of (Debug, Release)."
}

if ($Version -eq "")
{
$Version = (Get-Content "$rootDir\VERSION") + "-" + (git rev-parse --short --verify HEAD^)
}

Write-Output "Configuration: $Config"
Write-Output "Version: $Version"
Write-Output "Root directory: $rootDir"
Write-Output "Source directory: $srcDir"
Write-Output "Build directory: $buildDir"

# generate pony templated files if necessary
if ($Command -ne "clean")
{
$versionTimestamp = (Get-ChildItem -Path "$rootDir\VERSION").LastWriteTimeUtc
Get-ChildItem -Path $srcDir -Include "*.pony.in" -Recurse | ForEach-Object {
$templateFile = $_.FullName
$ponyFile = $templateFile.Substring(0, $templateFile.Length - 3)
$ponyFileTimestamp = [DateTime]::MinValue
if (Test-Path $ponyFile)
{
$ponyFileTimestamp = (Get-ChildItem -Path $ponyFile).LastWriteTimeUtc
}
if (($ponyFileTimestamp -lt $versionTimestamp) -or ($ponyFileTimestamp -lt $_.LastWriteTimeUtc))
{
Write-Output "$templateFile -> $ponyFile"
((Get-Content -Path $templateFile) -replace '%%VERSION%%', $Version) | Set-Content -Path $ponyFile
}
}
}

function BuildStable
{
$binaryFile = Join-Path -Path $buildDir -ChildPath "stable.exe"
$binaryTimestamp = [DateTime]::MinValue
if (Test-Path $binaryFile)
{
$binaryTimestamp = (Get-ChildItem -Path $binaryFile).LastWriteTimeUtc
}

:buildFiles foreach ($file in (Get-ChildItem -Path $srcDir -Include "*.pony" -Recurse))
{
if ($binaryTimestamp -lt $file.LastWriteTimeUtc)
{
ponyc.exe "$configFlag" --cpu "$Arch" --output "$buildDir" "$srcDir"
break buildFiles
}
}
}

function BuildTest
{
$testFile = Join-Path -Path $buildDir -ChildPath "test.exe"
$testTimestamp = [DateTime]::MinValue
if (Test-Path $testFile)
{
$testTimestamp = (Get-ChildItem -Path $testFile).LastWriteTimeUtc
}

:testFiles foreach ($file in (Get-ChildItem -Path $srcDir -Include "*.pony" -Recurse))
{
if ($testTimestamp -lt $file.LastWriteTimeUtc)
{
$testDir = Join-Path -Path $srcDir -ChildPath "test"
Write-Output "ponyc `"$configFlag`" --cpu `"$Arch`" --output `"$buildDir`" `"$testDir`""
ponyc "$configFlag" --cpu "$Arch" --output "$buildDir" "$testDir"
break testFiles
}
}

Write-Output "test.exe is built"
return $testFile
}

switch ($Command.ToLower())
{
"build"
{
BuildStable
break
}

"test"
{
BuildStable
$testFile = (BuildTest)[-1]

Write-Output "testFile == $testFile"

& "$testFile" --exclude=integration --sequential

$env:STABLE_BIN = Join-Path -Path $buildDir -ChildPath "stable.exe"
Write-Output "STABLE_BIN=$env:STABLE_BIN"
& "$testFile" --only=integration --sequential
break
}

"clean"
{
if (Test-Path "$buildDir")
{
Remove-Item -Path "$buildDir" -Recurse -Force
}
break
}

"install"
{
$binDir = Join-Path -Path $Destdir -ChildPath "bin"

if (-not (Test-Path $binDir))
{
mkdir "$binDir"
}

$stable = Join-Path -Path $buildDir -ChildPath "stable.exe"
Copy-Item -Path $stable -Destination $binDir -Force
break
}

"package"
{
$binDir = Join-Path -Path $Destdir -ChildPath "bin"
$package = "stable-x86-64-pc-windows-msvc.zip"
Write-Output "Creating $package..."

Compress-Archive -Path $binDir -DestinationPath "$buildDir\..\$package" -Force
break
}

default
{
throw "Unknown command '$Command'; must be one of (build, test, install, clean)"
}
}
6 changes: 3 additions & 3 deletions stable/_test.pony
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ class _TestBundleLocator is UnitTest
Path.join("stable/test/testdata", subpath).string()

fun apply(h: TestHelper) ? =>
h.assert_eq[String]("stable/test/testdata/nested",
h.assert_eq[String](Path.clean("stable/test/testdata/nested"),
_BundleLocator(h.env, bundle("nested")) as String)

// nested has one, but so does nested/deeply
h.assert_eq[String]("stable/test/testdata/nested/deeply",
h.assert_eq[String](Path.clean("stable/test/testdata/nested/deeply"),
_BundleLocator(h.env, bundle("nested/deeply")) as String)

// nested/empty has no bundle.json
h.assert_eq[String]("stable/test/testdata/nested",
h.assert_eq[String](Path.clean("stable/test/testdata/nested"),
_BundleLocator(h.env, bundle("nested/empty")) as String)

// stable itself has no bundle.json, so this ancestor-checking
Expand Down
3 changes: 3 additions & 0 deletions stable/main.pony
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ actor Main
cmd.append(" ")
cmd.append(arg)
end
if rest.size() == 0 then
cmd.append("set")
end
cmd.append("\"")
Shell(consume cmd, env.exitcode)?
else
Expand Down
43 changes: 26 additions & 17 deletions stable/test/integration/_exec.pony
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use "process"
actor _Exec
new create(
h: TestHelper,
cmdline: String,
args: Array[String] val,
tmp: String,
notifier: ProcessNotify iso)
=>
Expand All @@ -19,34 +19,43 @@ actor _Exec
return
end
try
let args = cmdline.split_by(" ")
let path = FilePath(h.env.root as AmbientAuth,
"stable/test/integration/helper.sh")?
let auth = h.env.root as AmbientAuth
let vars: Array[String] iso = [
"CWD=" + tmp
"STABLE_BIN=" + stable_bin
]
let pm: ProcessMonitor = ProcessMonitor(auth, auth, consume notifier,
path, consume args, consume vars)
let binPath = FilePath(h.env.root as AmbientAuth, stable_bin)?
let tmpPath = FilePath(h.env.root as AmbientAuth, tmp)?

let args' =
recover val
let args'' = args.clone()
ifdef windows then
args''.unshift(stable_bin)
else
args''.unshift("stable")
end
args''
end

let pm = ProcessMonitor(auth, auth, consume notifier, binPath, args',
h.env.vars, tmpPath)
pm.done_writing()
h.dispose_when_done(pm)
else
h.fail("Could not create FilePath!")
h.fail("Could not run stable!")
h.complete(false)
end

fun _env_var(vars: Array[String] val, key: String): String ? =>
for v in vars.values() do
if v.contains(key) then
return v.substring(
ISize.from[USize](key.size()) + 1,
ISize.from[USize](v.size()))
try
if v.find(key)? == 0 then
return v.substring(
ISize.from[USize](key.size() + 1),
ISize.from[USize](v.size()))
end
end
end

error


class _ExpectClient is ProcessNotify
let _h: TestHelper
let _out: Array[String] val
Expand Down Expand Up @@ -83,7 +92,7 @@ class _ExpectClient is ProcessNotify
_stderr = _stderr.add(String.from_array(consume data))

fun ref failed(process: ProcessMonitor ref, err: ProcessError) =>
_h.fail("ProcessError")
_h.fail(err.string())
_h.complete(false)

fun ref dispose(process: ProcessMonitor ref, child_exit_code: I32) =>
Expand Down
4 changes: 0 additions & 4 deletions stable/test/integration/helper.sh

This file was deleted.

Loading