Skip to content

Commit

Permalink
Merge branch 'main' into kant/infinite-loop-return
Browse files Browse the repository at this point in the history
  • Loading branch information
kant2002 committed Jul 26, 2024
2 parents 773b55c + 3e0ecd7 commit a5c0d78
Show file tree
Hide file tree
Showing 130 changed files with 3,321 additions and 365 deletions.
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"nuke.globaltool": {
"version": "8.0.0",
"commands": [
"nuke"
]
}
}
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build.sh eol=lf
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-FileCopyrightText: 2024 Friedrich von Never <[email protected]>
#
# SPDX-License-Identifier: MIT

# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "nuget"
directory: "/"
schedule:
interval: "daily"
12 changes: 8 additions & 4 deletions .github/workflows/perform-common-steps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ runs:
using: "composite"
steps:
- name: ⚙ Setup .NET SDK ⚙
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
global-json-file: global.json

- name: ♻ NuGet Cache ♻
uses: actions/cache@v2
with:
path: ${{ env.NUGET_PACKAGES }}
key: ${{ runner.os }}.nuget.${{ hashFiles('**/*.csproj') }}
key: ${{ runner.os }}.nuget.${{ hashFiles('**/*.csproj', 'Directory.Packages.props') }}

- name: 🛠️ Restore local .NET tools 🛠️
shell: bash
run: dotnet tool restore

- name: 🔄 Restore Nuget Packages 🔄
shell: bash
run: dotnet restore
run: dotnet nuke RestoreAll
14 changes: 11 additions & 3 deletions .github/workflows/run-build-and-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,23 @@ jobs:
NUGET_PACKAGES: ${{ github.workspace }}/.github/nuget-packages
steps:
- name: 📝 Fetch Sources 📝
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: 💡 Perform Common Steps 💡
uses: ./.github/workflows/perform-common-steps

- name: 🛠 Build Solution 🛠
shell: bash
run: dotnet build
run: dotnet nuke CompileAll

- name: 🚚 Publish Compiler Bundle 🚚
shell: bash
run: dotnet nuke PublishCompilerBundle

- name: 📦 Pack Compiler Bundle 📦
shell: bash
run: dotnet nuke PackCompilerBundle

- name: ✅ Run Unit Tests ✅
shell: bash
run: dotnet test
run: dotnet nuke TestAll
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@

bin/
obj/
artifacts/
/.nuke/temp

*.dll
*.exe
*.runtimeconfig.json
*.received.txt
*.user


150 changes: 150 additions & 0 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$ref": "#/definitions/build",
"title": "Build Schema",
"definitions": {
"build": {
"type": "object",
"properties": {
"Configuration": {
"type": "string",
"description": "Configuration to build - Default is 'Debug' or 'Release'",
"enum": [
"Debug",
"Release"
]
},
"Continue": {
"type": "boolean",
"description": "Indicates to continue a previously failed build attempt"
},
"Help": {
"type": "boolean",
"description": "Shows the help text for this build assembly"
},
"Host": {
"type": "string",
"description": "Host for execution. Default is 'automatic'",
"enum": [
"AppVeyor",
"AzurePipelines",
"Bamboo",
"Bitbucket",
"Bitrise",
"GitHubActions",
"GitLab",
"Jenkins",
"Rider",
"SpaceAutomation",
"TeamCity",
"Terminal",
"TravisCI",
"VisualStudio",
"VSCode"
]
},
"NoLogo": {
"type": "boolean",
"description": "Disables displaying the NUKE logo"
},
"Partition": {
"type": "string",
"description": "Partition to use on CI"
},
"Plan": {
"type": "boolean",
"description": "Shows the execution plan (HTML)"
},
"Profile": {
"type": "array",
"description": "Defines the profiles to load",
"items": {
"type": "string"
}
},
"PublishAot": {
"type": "boolean",
"description": "If set to true, publishes compiler packs in AOT mode"
},
"Root": {
"type": "string",
"description": "Root directory during build execution"
},
"RuntimeId": {
"type": "string",
"description": "If set, only executes targets for a specified runtime identifier. Provided RID must be included in <RuntimeIdentifiers> property of Cesium.Compiler project"
},
"Skip": {
"type": "array",
"description": "List of targets to be skipped. Empty list skips all dependencies",
"items": {
"type": "string",
"enum": [
"Clean",
"CompileAll",
"ForceClear",
"PackAllCompilerBundles",
"PackCompilerBundle",
"PackSdk",
"PackTemplates",
"PublishAllCompilerBundles",
"PublishCompilerBundle",
"RestoreAll",
"TestAll",
"TestCodeGen",
"TestCompiler",
"TestIntegration",
"TestParser",
"TestRuntime",
"TestSdk"
]
}
},
"SkipCaches": {
"type": "boolean",
"description": "If set to true, ignores all cached build results. Default: false"
},
"Solution": {
"type": "string",
"description": "Path to a solution file that is automatically loaded"
},
"Target": {
"type": "array",
"description": "List of targets to be invoked. Default is '{default_target}'",
"items": {
"type": "string",
"enum": [
"Clean",
"CompileAll",
"ForceClear",
"PackAllCompilerBundles",
"PackCompilerBundle",
"PackSdk",
"PackTemplates",
"PublishAllCompilerBundles",
"PublishCompilerBundle",
"RestoreAll",
"TestAll",
"TestCodeGen",
"TestCompiler",
"TestIntegration",
"TestParser",
"TestRuntime",
"TestSdk"
]
}
},
"Verbosity": {
"type": "string",
"description": "Logging verbosity during build execution. Default is 'Normal'",
"enum": [
"Minimal",
"Normal",
"Quiet",
"Verbose"
]
}
}
}
}
}
4 changes: 4 additions & 0 deletions .nuke/parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "./build.schema.json",
"Solution": "Cesium.sln"
}
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ There are two kinds of tests in Cesium: unit tests and integration tests.
Run the unit and integration tests using this shell command:

```console
$ dotnet test
$ dotnet restore
$ dotnet nuke TestAll
```

Publishing
Expand Down
3 changes: 2 additions & 1 deletion Cesium.Ast/Cesium.Ast.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 0 additions & 4 deletions Cesium.CodeGen.Tests/Cesium.CodeGen.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
18 changes: 18 additions & 0 deletions Cesium.CodeGen.Tests/CodeGenArrayTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,24 @@ int main() {
}
""");

[Fact]
public Task SignedByteArrayTest() => DoTest(@"
int main() {
signed char x[1] = { -1 };
signed char y = x[0];
int z = (int)y;
return z;
}");

[Fact]
public Task UnSignedByteArrayTest2() => DoTest(@"
int main() {
unsigned char a[1] = { 255 };
unsigned char b = a[0];
int c = (int)b;
return c;
}");

[Fact]
public Task PointerAsArray() => DoTest("""
int main(void)
Expand Down
15 changes: 14 additions & 1 deletion Cesium.CodeGen.Tests/CodeGenMethodTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ int main()
[Fact] public Task VoidParameterMain() => DoTest("int main(void){}");
[Fact] public Task PointerReceivingFunction() => DoTest("void foo(int *ptr){}");
[Fact] public Task StandardMain() => DoTest("int main(int argc, char *argv[]){}");
[Fact] public Task PointerPointerMain() => DoTest("int main(int argc, char **argv){}");
[Fact] public Task ConstConstMain() => DoTest("int main(int argc, const char * const *argv){}");
[Fact] public Task ConstArgcMain() => DoTest("int main(const int argc, char* argv[]){}");
[Fact, NoVerify] public void NonstandardMainDoesNotCompile1() => DoesNotCompile("void main(){}", "Invalid return type");
[Fact, NoVerify] public void NonstandardMainDoesNotCompile2() => DoesNotCompile("int main(int c){}", "Invalid parameter");
[Fact, NoVerify]
Expand Down Expand Up @@ -110,6 +113,16 @@ public Task Arithmetic() => DoTest(@"int main(void)
}
");

[Fact]
public Task UnaryPlusAndStart() => DoTest(@"
int main() {
short a = -2;
short* b = &a;
short c = *b;
int x = (+c) - (+1) - (-1);
return sizeof(+c);
} ");

[Fact]
public Task ReturnWithoutArgument() => DoTest(@"void console_read()
{
Expand Down Expand Up @@ -492,7 +505,7 @@ int console_read(struct struct1* s) {
return s->x;
}");

// TODO [#196]
// TODO[#196]
/* [Fact]
public Task VarargFunctionPointerCallTest() => DoTest(@"int foo(int a, ...) { return a; }
Expand Down
18 changes: 18 additions & 0 deletions Cesium.CodeGen.Tests/CodeGenNetInteropTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,22 @@ int main(void)
return Func(&myFunc) - 1;
}
""");

[Theory]
[InlineData(TargetArchitectureSet.Dynamic)]
[InlineData(TargetArchitectureSet.Wide)]
public Task TestEquivalentTypeAttribute(TargetArchitectureSet architecture) => DoTest(architecture,
@"using Cesium.Runtime;
public static unsafe class Test
{
public static int Func(UTF8String str) => (int)str.Length;
}",
@"
__cli_import(""Test::Func"")
int Func(char*);
int main(void)
{
return Func(""Hi"") - 2;
}");
}
Loading

0 comments on commit a5c0d78

Please sign in to comment.