Skip to content
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
66 changes: 48 additions & 18 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: .NET Core
name: .NET

on:
push:
Expand All @@ -8,26 +8,56 @@ on:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Setup .NET 9.0
uses: actions/setup-dotnet@v1
- uses: actions/checkout@v4
- name: Setup .NET 10.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
dotnet-version: 10.0.x
# Temporarily disabled until packages.lock.json is added
# cache: true
- name: Restore
run: dotnet restore
- name: Peachpie.Runtime.Tests
run: dotnet test ./src/Tests/Peachpie.Runtime.Tests --verbosity normal
- name: Peachpie.DiagnosticTests
run: dotnet test ./src/Tests/Peachpie.DiagnosticTests --verbosity normal
# - name: Peachpie.ScriptTests
# run: dotnet test ./src/Tests/Peachpie.ScriptTests --verbosity normal
run: dotnet restore Peachpie.sln
- name: Build
run: dotnet build ./src/Peachpie.NET.Sdk/ -c Release --no-restore -p:VersionSuffix=ghaction${{github.run_number}}
run: dotnet build Peachpie.sln -c Release --no-restore
- name: Smoke Test Packaged SDK
shell: bash
run: |
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT

cat > "$tmpdir/NuGet.Config" <<EOF
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="Peachpie Debug Packages" value="${{ github.workspace }}/.nugs" />
</packageSources>
</configuration>
EOF

cat > "$tmpdir/smoke.msbuildproj" <<'EOF'
<Project Sdk="Peachpie.NET.Sdk/1.2.0-dev">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<StartupObject>program.php</StartupObject>
</PropertyGroup>

<ItemGroup>
<Compile Include="**/*.php" />
</ItemGroup>
</Project>
EOF

cat > "$tmpdir/program.php" <<'EOF'
<?php
echo "smoke";
EOF

dotnet run --project "$tmpdir/smoke.msbuildproj" --verbosity minimal > "$tmpdir/output.txt"
grep -q "smoke" "$tmpdir/output.txt"
- name: Test
run: dotnet test Peachpie.sln -c Release --no-build --verbosity normal
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<!-- version -->
<Version Condition=" '$(APPVEYOR_BUILD_VERSION)'!='' ">$(APPVEYOR_BUILD_VERSION)</Version>
<Version Condition=" '$(Version)'=='' ">1.2.0-dev</Version>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFramework>net10.0</TargetFramework>
<PackageVersion>$(Version)</PackageVersion>
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>

Expand Down Expand Up @@ -58,4 +58,4 @@
<NoWarn>$(NoWarn),NU5048</NoWarn>
</PropertyGroup>

</Project>
</Project>
1 change: 1 addition & 0 deletions Peachpie.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{ED9DAD46
Directory.Build.targets = Directory.Build.targets
MyGet.ps1 = MyGet.ps1
build\update-cache.ps1 = build\update-cache.ps1
build\update-cache.sh = build\update-cache.sh
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Library", "Library", "{30D6D91F-A671-4E73-A571-5614500FDE0B}"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ PeachPie is a member project of the [.NET Foundation](https://www.dotnetfoundati
|---|---|---|
| AppVeyor | Visual Studio 2019 | [![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/1ym8cd838l0od9oa?svg=true)](https://ci.appveyor.com/project/dotnetfoundation/peachpie) |
| Azure DevOps | Windows | ![VSTS Build Status](https://iolevel.visualstudio.com/_apis/public/build/definitions/bd7dcca1-8515-44f8-81d0-bb2acc03d949/1/badge)|
| GitHub Actions | Ubuntu 18 | ![.NET Core](https://github.com/peachpiecompiler/peachpie/workflows/.NET%20Core/badge.svg) |
| GitHub Actions | Ubuntu | ![.NET](https://github.com/peachpiecompiler/peachpie/actions/workflows/dotnet.yml/badge.svg) |

## What is PeachPie?

Expand Down
2 changes: 1 addition & 1 deletion build/dummy/dummy.msbuildproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Peachpie.NET.Sdk/1.2.0-dev">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>

<ItemGroup Condition=" '$(DisableImplicitPeachpieReferences)' != 'true' ">
Expand Down
7 changes: 4 additions & 3 deletions build/update-cache.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ param([string]$version = "1.2.0", [string]$suffix = "dev")
$rootDir = [System.IO.Path]::GetFullPath("$PSScriptRoot/..")
Write-Host "Root at" $rootDir
$packagesSource = (Resolve-Path "~/.nuget/packages").Path
$defaultArgs = "/p:VersionPrefix=$version,VersionSuffix=$suffix"
$peachpieVersion = "$version-$suffix"
$restoreArgs = @("/p:PeachpieVersion=$peachpieVersion", "/p:VersionPrefix=$version", "/p:VersionSuffix=$suffix")

## Delete old nuget packages
Write-Host -f green "Deleting '$version-$suffix' packages from '$packagesSource' ..."
@("Peachpie.Runtime", "Peachpie.Library", "Peachpie.Library.Scripting", "Peachpie.Library.MySql", "Peachpie.Library.MsSql", "Peachpie.Library.Graphics", "Peachpie.Library.Network", "Peachpie.Library.PDO", "Peachpie.Library.XmlDom", "Peachpie.App", "Peachpie.CodeAnalysis", "Peachpie.AspNetCore.Web", "Peachpie.RequestHandler", "Peachpie.AspNetCore.Mvc", "Peachpie.NET.Sdk", "Peachpie.Library.PDO.MySql", "Peachpie.Library.PDO.Sqlite", "Peachpie.Library.SqlSrv") | % {
@("Peachpie.Runtime", "Peachpie.Library", "Peachpie.Library.Scripting", "Peachpie.Library.MySql", "Peachpie.Library.MsSql", "Peachpie.Library.Graphics", "Peachpie.Library.Network", "Peachpie.Library.PDO", "Peachpie.Library.XmlDom", "Peachpie.App", "Peachpie.CodeAnalysis", "Peachpie.AspNetCore.Web", "Peachpie.RequestHandler", "Peachpie.AspNetCore.Mvc", "Peachpie.NET.Sdk", "Peachpie.Library.PDO.MySQL", "Peachpie.Library.PDO.Sqlite", "Peachpie.Library.PDO.SqlSrv") | % {
$installedFolder = "$packagesSource/$_/$version-$suffix"
if (Test-Path $installedFolder) {
Remove-Item -Recurse -Force $installedFolder
Expand All @@ -34,4 +35,4 @@ Write-Host -f green "Deleting '$version-$suffix' packages from '$packagesSource'

# Reinstall the packages by restoring a dummy project that depends on them
Write-Host -f green "Installing packages to nuget cache ..."
dotnet restore "$rootDir/build/dummy" --ignore-failed-sources
dotnet restore "$rootDir/build/dummy" @restoreArgs --ignore-failed-sources
66 changes: 66 additions & 0 deletions build/update-cache.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env bash
set -euo pipefail

# A script to update the NuGet cache with built packages

version="${1:-1.2.0}"
suffix="${2:-dev}"

script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
root_dir="$(realpath "$script_dir/..")"
peachpie_version="$version-$suffix"

echo "Root at $root_dir"

packages_source="$HOME/.nuget/packages"
restore_args=(
"/p:PeachpieVersion=$peachpie_version"
"/p:VersionPrefix=$version"
"/p:VersionSuffix=$suffix"
)

echo -e "\033[32mDeleting '$version-$suffix' packages from '$packages_source' ...\033[0m"

packages=(
"Peachpie.Runtime"
"Peachpie.Library"
"Peachpie.Library.Scripting"
"Peachpie.Library.MySql"
"Peachpie.Library.MsSql"
"Peachpie.Library.Graphics"
"Peachpie.Library.Network"
"Peachpie.Library.PDO"
"Peachpie.Library.XmlDom"
"Peachpie.App"
"Peachpie.CodeAnalysis"
"Peachpie.AspNetCore.Web"
"Peachpie.RequestHandler"
"Peachpie.AspNetCore.Mvc"
"Peachpie.NET.Sdk"
"Peachpie.Library.PDO.MySQL"
"Peachpie.Library.PDO.Sqlite"
"Peachpie.Library.PDO.SqlSrv"
)

for package in "${packages[@]}"; do
installed_folder="$packages_source/$package/$version-$suffix"

if [ -d "$installed_folder" ]; then
rm -rf "$installed_folder"
fi
done

# Clean up the installed tool settings so that no old dependencies hang in there
# tool_folder="$packages_source/.tools/Peachpie.Compiler.Tools/$version-$suffix"
# if [ -d "$tool_folder" ]; then
# rm -rf "$tool_folder"
# fi

# Restore top packages, dependencies restored recursively
# echo -e "\033[32mRestoring packages ...\033[0m"
# for package in "Peachpie.NET.Sdk" "Peachpie.Library.Scripting" "Peachpie.AspNetCore.Web"; do
# dotnet restore "$default_args" "$root_dir/src/$package"
# done

echo -e "\033[32mInstalling packages to nuget cache ...\033[0m"
dotnet restore "${restore_args[@]}" "$root_dir/build/dummy" --ignore-failed-sources
10 changes: 7 additions & 3 deletions docs/Building-Peachpie.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ The solution consists of a set of standard MSBuild 15.0 project files. The stand

## Prerequisites

- .NET 9.0 SDK
- .NET 10.0 SDK
- Visual Studio 2022 (Optional)

## Command Line
Expand All @@ -19,19 +19,23 @@ The build process outputs NuGet packages locally in `\.nugs\` directory. Package

The PeachPie platform is distributed as NuGet packages (`Peachpie.*`). After building Peachpie from sources, all the packages are located in `\.nugs\` directory with the suffix `-dev` by default.

In order to use your development packages, after a successful build run the helper script `.\update-cache.ps1`. It copies packages from `/.nugs` to your local NuGet packages cache.
In order to use your development packages, after a successful build run the helper script for your platform. It installs packages from `/.nugs` to your local NuGet packages cache.

```shell
PS \build\> .\update-cache.ps1
```

```shell
$ ./build/update-cache.sh
```

Reference the development packages by your projects, i.e.
```xml
<Project Sdk="Peachpie.NET.Sdk/1.2.0-dev">
```
or
```xml
<PackageReference Include="Peachpie.Library.PDO.MySql" Version="1.2.0-dev" />
<PackageReference Include="Peachpie.Library.PDO.MySQL" Version="1.2.0-dev" />
```
or when using `global.json` to specify Sdks versions:
```json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Data.Sqlite" Version="3.1.7" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="10.0.7" />
</ItemGroup>

</Project>
</Project>
4 changes: 3 additions & 1 deletion src/Peachpie.AspNetCore.Mvc/Peachpie.AspNetCore.Mvc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<PackageReference Include="Microsoft.AspNetCore.Html.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="System.Security.Cryptography.Xml" Version="10.0.7" />
</ItemGroup>

</Project>
</Project>
18 changes: 6 additions & 12 deletions src/Peachpie.AspNetCore.Web/HttpContextExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Hosting;
using Pchp.Core;

namespace Peachpie.AspNetCore.Web
Expand All @@ -16,18 +17,9 @@ public static class HttpContextExtension
/// <summary>
/// Gets default root path.
/// </summary>
[Obsolete]
internal static string GetDefaultRootPath(this IHostingEnvironment hostingEnv)
internal static string GetDefaultRootPath(this IHostEnvironment hostingEnv)
{
return hostingEnv.WebRootPath ?? hostingEnv.ContentRootPath ?? Directory.GetCurrentDirectory();
}

/// <summary>
/// Gets default root path.
/// </summary>
internal static string GetDefaultRootPath(this IWebHostEnvironment hostingEnv)
{
return hostingEnv.WebRootPath ?? hostingEnv.ContentRootPath ?? Directory.GetCurrentDirectory();
return (hostingEnv as IWebHostEnvironment)?.WebRootPath ?? hostingEnv.ContentRootPath ?? Directory.GetCurrentDirectory();
}

/// <summary>
Expand Down Expand Up @@ -82,7 +74,9 @@ static RequestContextCore CreateNewContext(this HttpContext httpctx)
{
var rootpath = httpctx.RequestServices.GetService(typeof(IWebHostEnvironment)) is IWebHostEnvironment webhost
? GetDefaultRootPath(webhost)
: GetDefaultRootPath((IHostingEnvironment)httpctx.RequestServices.GetService(typeof(IHostingEnvironment)));
: httpctx.RequestServices.GetService(typeof(IHostEnvironment)) is IHostEnvironment host
? GetDefaultRootPath(host)
: Directory.GetCurrentDirectory();

return new RequestContextCore(httpctx,
rootPath: rootpath,
Expand Down
2 changes: 1 addition & 1 deletion src/Peachpie.CodeAnalysis/CodeGen/Graph/BoundExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3522,7 +3522,7 @@ void EmitNewParametersArray(CodeGenerator cg, ReadOnlySpan<FormalParam> ps)
/// </summary>
TypeSymbol EmitCachedParametersArray(CodeGenerator cg, ReadOnlySpan<FormalParam> ps)
{
if (ps == null || ps.Length == 0)
if (ps.Length == 0)
{
// PhpArray.Empty
return cg.Emit_PhpArray_Empty();
Expand Down
17 changes: 2 additions & 15 deletions src/Peachpie.CodeAnalysis/Peachpie.CodeAnalysis.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFramework>net10.0</TargetFramework>
<OutputType>exe</OutputType>
<NoWarn>$(NoWarn);1591</NoWarn>
<AssemblyName>Peachpie.CodeAnalysis</AssemblyName>
Expand All @@ -16,20 +16,7 @@
<PackageReference Include="Devsense.Php.Phar" Version="1.0.40" />
<PackageReference Include="Peachpie.Microsoft.CodeAnalysis" Version="$(PeachpieMicrosoftCodeAnalysisVersion)" />
<PackageReference Include="Peachpie.Library.RegularExpressions" Version="$(PeachpieLibraryRegularExpressionsVersion)" />
<PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
<PackageReference Include="System.Memory" Version="4.5.4" />
<PackageReference Include="System.Reflection.Metadata" Version="1.6.0" />
<PackageReference Include="Peachpie.Compiler.Diagnostics" Version="1.0.10" Condition=" '$(Configuration)' == 'Release' " />

<!-- Prevent package downgrades -->
<PackageReference Include="System.Collections" Version="4.3.0" />
<PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" />
<PackageReference Include="System.Resources.ResourceManager" Version="4.3.0" />
<PackageReference Include="System.Runtime.Extensions" Version="4.3.0" />
<PackageReference Include="System.Runtime.Handles" Version="4.3.0" />
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
<PackageReference Include="System.Text.Encoding.Extensions" Version="4.3.0" />
<PackageReference Include="System.Threading" Version="4.3.0" />
</ItemGroup>

<ItemGroup>
Expand All @@ -56,4 +43,4 @@
</EmbeddedResource>
</ItemGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ bool DeclareConditionally(TypeDecl x)
bool IsDeclared(QualifiedName qname)
{
if (_declarations != null &&
_declarations.OfType<TypeDecl>().FirstOrDefault(t => t.QualifiedName == qname) != default)
_declarations.OfType<BoundTypeDeclStatement>().Any(t => t.TypeDecl.QualifiedName == qname))
{
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Peachpie.CodeAnalysis/Symbols/PE/PEFieldSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,12 @@ internal override bool HasRuntimeSpecialName

internal override bool IsNotSerialized
{
#pragma warning disable SYSLIB0050
get
{
return (_flags & FieldAttributes.NotSerialized) != 0;
}
#pragma warning restore SYSLIB0050
}

internal override MarshalPseudoCustomAttributeData MarshallingInformation
Expand Down
2 changes: 2 additions & 0 deletions src/Peachpie.CodeAnalysis/Symbols/PE/PENamedTypeSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,9 @@ public override bool IsSealed
}
}

#pragma warning disable SYSLIB0050
public override bool IsSerializable => (_flags & TypeAttributes.Serializable) != 0;
#pragma warning restore SYSLIB0050

internal override bool IsMetadataSealed => (_flags & TypeAttributes.Sealed) != 0;

Expand Down
Loading