Skip to content

Commit 62e9119

Browse files
josetrtritao
authored andcommitted
Create a single nuget package that supports windows / linux / macos
1 parent fa7e76f commit 62e9119

File tree

19 files changed

+159
-555
lines changed

19 files changed

+159
-555
lines changed

.github/workflows/main.yml

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,46 @@ jobs:
5454
shell: bash
5555
run: build/test.sh -platform $PLATFORM
5656

57-
- name: 'Upload Artifact'
58-
uses: actions/upload-artifact@v2
59-
if: github.ref == 'refs/heads/master'
57+
- name: Pack
58+
shell: bash
59+
run: build/build.sh prepack -platform $PLATFORM
60+
61+
- uses: actions/upload-artifact@v2
6062
with:
61-
name: cppsharp-${{ matrix.config.os }}-${{ matrix.config.platform }}-${{ matrix.config.cc }}
63+
name: intermediate
6264
path: |
63-
bin/**/CppSharp*
64-
bin/**/Std-symbols*
65-
bin/**/lib/**
65+
artifacts
6666
include/**/*.h
67+
68+
create_package:
69+
runs-on: windows-2019
70+
needs: build
71+
if: |
72+
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || contains(github.ref, 'nuget'))) ||
73+
(github.event.pull_request.head.repo.full_name != github.repository && contains(github.event.pull_request.head.ref, 'nuget'))
74+
75+
env:
76+
DOTNET_NOLOGO: true
77+
DOTNET_CLI_TELEMETRY_OPTOUT: true
78+
79+
steps:
80+
- uses: actions/checkout@v2
81+
82+
- uses: actions/download-artifact@v2
83+
with:
84+
name: intermediate
85+
86+
- name: Setup
87+
shell: bash
88+
run: build/build.sh generate_config
89+
90+
- name: Create package
91+
shell: bash
92+
run: build/build.sh pack
93+
94+
- name: Upload package
95+
uses: actions/upload-artifact@v2
96+
with:
97+
name: CppSharp.nupkg
98+
path: |
99+
artifacts/*.nupkg

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ src/generator/generator
4545
/build/config.props
4646
/build/premake/premake5*
4747
/build/gen
48+
/artifacts
4849
/deps/llvm
4950
/extra
5051
/include/include

Directory.Build.props

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,36 @@
55
<RootDir>$(MSBuildThisFileDirectory)</RootDir>
66
<Platforms>x86;x64</Platforms>
77
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
8-
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
8+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
9+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
10+
<RepositoryUrl>https://github.com/mono/CppSharp</RepositoryUrl>
11+
<RepositoryCommit>$(GITHUB_SHA)</RepositoryCommit>
12+
<Authors>João Matos, Dimitar Dobrev, Jose Torres</Authors>
13+
<Copyright>João Matos, Dimitar Dobrev</Copyright>
14+
<Version>0.10.6</Version>
15+
<IsPackable>false</IsPackable>
916
<BuildDir>$(RootDir)build\</BuildDir>
1017
<ObjDir>$(BuildDir)obj\</ObjDir>
1118
<GenDir>$(BuildDir)gen\</GenDir>
1219
<SrcDir>$(RootDir)src\</SrcDir>
20+
<GlobalTargetFramework>$(TargetFramework)</GlobalTargetFramework>
1321
<BaseIntermediateOutputPath>$(ObjDir)$(MSBuildProjectName)\</BaseIntermediateOutputPath>
1422
<BaseOutputPath>$(RootDir)bin\</BaseOutputPath>
1523
<OutputPath>$(BaseOutputPath)$(Configuration)_$(PlatformTarget)\</OutputPath>
1624
<ActionDir>$(BuildDir)$(PremakeAction)\</ActionDir>
1725
<NativeProjectsDir>$(ActionDir)projects\</NativeProjectsDir>
26+
<PackageDir>$(RootDir)artifacts\package\</PackageDir>
1827
<TargetDir>$(OutputPath)</TargetDir>
1928
<LangVersion>8.0</LangVersion>
2029
<WarningLevel>4</WarningLevel>
2130
<DotNetCmd>dotnet</DotNetCmd>
2231
<GeneratorFileExtension>dll</GeneratorFileExtension>
2332
<DotNetCmd Condition="'$(PlatformTarget)' == 'x86' AND Exists('$(MSBuildProgramFiles32)\dotnet\dotnet.exe')">"$(MSBuildProgramFiles32)\dotnet\dotnet.exe"</DotNetCmd>
2433
<DotNetCmd Condition="'$(PlatformTarget)' == 'x64' AND Exists('$(ProgramW6432)\dotnet\dotnet.exe')">"$(ProgramW6432)\dotnet\dotnet.exe"</DotNetCmd>
34+
<RID Condition="$(IsWindows)">win</RID>
35+
<RID Condition="$(IsLinux)">linux</RID>
36+
<RID Condition="$(IsMacOSX)">osx</RID>
37+
<RID>$(RID)-$(PlatformTarget)</RID>
2538
</PropertyGroup>
2639

2740
<PropertyGroup Condition="'$(CPPSHARP_RELEASE)' != 'true'">
@@ -34,4 +47,9 @@
3447
<GeneratorFileExtension>exe</GeneratorFileExtension>
3548
<DotNetCmd></DotNetCmd>
3649
</PropertyGroup>
50+
51+
<Target Name="prepack" DependsOnTargets="Build" Condition="'$(IsPackable)' == 'true'">
52+
<Copy SourceFiles="$(TargetDir)ref\$(TargetFileName)" DestinationFolder="$(PackageDir)ref\$(GlobalTargetFramework)" Condition="'$(ProduceReferenceAssembly)' == 'true' AND '$(RID)' == 'win-x64'" />
53+
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(PackageDir)runtimes\$(RID)\lib\$(GlobalTargetFramework)" />
54+
</Target>
3755
</Project>

build/Helpers.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ newoption {
3838
}
3939
}
4040

41+
newoption {
42+
trigger = "config_only",
43+
description = "Only generate configuration file",
44+
}
45+
4146
rootdir = path.getabsolute("../")
4247
srcdir = path.join(rootdir, "src");
4348
incdir = path.join(rootdir, "include");

build/build.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ bindir="$rootdir/bin"
1212
objdir="$builddir/obj"
1313
gendir="$builddir/gen"
1414
slnpath="$rootdir/CppSharp.sln"
15+
artifacts="$rootdir/artifacts"
1516
oshost=""
1617
os=""
1718
test=
@@ -43,6 +44,11 @@ build()
4344
fi
4445
}
4546

47+
generate_config()
48+
{
49+
$builddir/premake.sh --file=$builddir/premake5.lua $vs --os=$os --arch=$platform --configuration=$configuration --config_only
50+
}
51+
4652
generate()
4753
{
4854
download_llvm
@@ -60,6 +66,19 @@ restore()
6066
$msbuild $slnpath -p:Configuration=$configuration -p:Platform=$platform -v:$verbosity -t:restore -nologo
6167
}
6268

69+
prepack()
70+
{
71+
find_msbuild
72+
$msbuild $slnpath -t:prepack -p:Configuration=$configuration -p:Platform=$platform -v:$verbosity -nologo
73+
}
74+
75+
pack()
76+
{
77+
find_msbuild
78+
$msbuild -t:restore $rootdir/src/Package/CppSharp.Package.csproj -p:Configuration=$configuration -p:Platform=$platform
79+
$msbuild -t:pack $rootdir/src/Package/CppSharp.Package.csproj -p:Configuration=$configuration -p:Platform=$platform -p:PackageOutputPath=$rootdir/artifacts
80+
}
81+
6382
test()
6483
{
6584
dotnet test {$bindir/${configuration}_$platform,$gendir/*}/*.Tests*.dll --nologo
@@ -172,6 +191,7 @@ while [[ $# > 0 ]]; do
172191
;;
173192
-ci)
174193
ci=true
194+
export CI=true
175195
;;
176196
-build_only)
177197
build_only=true
@@ -187,6 +207,15 @@ case "$cmd" in
187207
generate)
188208
generate
189209
;;
210+
generate_config)
211+
generate_config
212+
;;
213+
prepack)
214+
prepack
215+
;;
216+
pack)
217+
pack
218+
;;
190219
restore)
191220
restore
192221
;;

build/nuget/.vscode/launch.json

Lines changed: 0 additions & 23 deletions
This file was deleted.

build/nuget/TODO.txt

Lines changed: 0 additions & 17 deletions
This file was deleted.

build/nuget/build.cake

Lines changed: 0 additions & 125 deletions
This file was deleted.

0 commit comments

Comments
 (0)