Skip to content

Commit 066e8fc

Browse files
aybetritao
authored andcommitted
Preliminary script for building 32-bit Nuget package (#1015)
1 parent d8b5372 commit 066e8fc

File tree

7 files changed

+551
-0
lines changed

7 files changed

+551
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,8 @@ src/generator/generator
4949
/site
5050
/wip
5151
/.vs
52+
53+
# Nuget: do not include produced packages
54+
/build/nuget/*.nupkg
55+
/build/nuget/tools/*
56+

build/nuget/.vscode/launch.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
8+
{
9+
"name": "Cake: Debug Script (CoreCLR)",
10+
"type": "coreclr",
11+
"request": "launch",
12+
"program": "${workspaceRoot}/tools/Cake.CoreCLR/Cake.dll",
13+
"args": [
14+
"${workspaceRoot}/build.cake",
15+
"--debug",
16+
"--verbosity=diagnostic"
17+
],
18+
"cwd": "${workspaceRoot}",
19+
"stopAtEntry": true,
20+
"externalConsole": false
21+
}
22+
]
23+
}

build/nuget/TODO.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Notes and TODOs
2+
3+
- Microsoft.VisualStudio.Setup.Configuration.Interop has been added to nuspec,
4+
but for some reason it never copies itself to output, it has to be done manually.
5+
Additionally, the 64-bit nuget package does not need that (TODO Confirm this).
6+
7+
- Baseclass.Contrib.Nuget.Output is problematic, whenever you update it,
8+
Visual Studio complains and says it must restart, over and over.
9+
10+
- Nuget package warnings should be fixed/suppressed.
11+
12+
- Should there be two packages : x86 and x64 ?
13+
14+
- Only Visual Studio 2017 32-bit solution is supported, once a 64-bit solution
15+
is available, build.cake should be enhanced.
16+
17+
- Whatever else I've missed ...

build/nuget/build.cake

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
///////////////////////////////////////////////////////////////////////////////
2+
// ARGUMENTS
3+
///////////////////////////////////////////////////////////////////////////////
4+
5+
var target = Argument("target", "Default");
6+
var configuration = Argument("configuration", "Release");
7+
8+
///////////////////////////////////////////////////////////////////////////////
9+
// SETUP / TEARDOWN
10+
///////////////////////////////////////////////////////////////////////////////
11+
12+
Setup(ctx =>
13+
{
14+
// Executed BEFORE the first task.
15+
Information("Running tasks...");
16+
});
17+
18+
Teardown(ctx =>
19+
{
20+
// Executed AFTER the last task.
21+
Information("Finished running tasks.");
22+
});
23+
24+
///////////////////////////////////////////////////////////////////////////////
25+
// TASKS
26+
///////////////////////////////////////////////////////////////////////////////
27+
28+
Task("Build")
29+
.Does(() => {
30+
31+
if (!IsRunningOnWindows())
32+
throw new NotImplementedException("TODO Implement other platforms");
33+
34+
// TODO update this when there's a 64-bit solution
35+
36+
var settings = new MSBuildSettings();
37+
settings.SetConfiguration("Release");
38+
settings.SetPlatformTarget(PlatformTarget.x86);
39+
MSBuild("../vs2017/CppSharp.sln", settings);
40+
41+
});
42+
43+
Task("Package")
44+
.Does(() => {
45+
46+
var scratchDir = new DirectoryPath("temp");
47+
48+
// clear previous session
49+
if (DirectoryExists(scratchDir))
50+
DeleteDirectory(scratchDir, true);
51+
52+
var files = new Dictionary<string,string>()
53+
{
54+
{ "CppSharp.dll", "lib" },
55+
{ "CppSharp.AST.dll", "lib" },
56+
{ "CppSharp.Generator.dll", "lib" },
57+
{ "CppSharp.Parser.dll", "lib" },
58+
{ "CppSharp.Parser.CLI.dll", "lib" },
59+
{ "CppSharp.Runtime.dll", "lib" },
60+
61+
{ "CppSharp.CLI.exe", "tools"},
62+
63+
{ "CppSharp.CppParser.dll", "output"},
64+
{ "clang", "output/lib/clang"},
65+
};
66+
67+
var path = new DirectoryPath("../vs2017/lib/Release_x86/");
68+
69+
CreateDirectory(scratchDir);
70+
71+
foreach (var file in files)
72+
{
73+
var tgt = scratchDir.Combine(file.Value);
74+
CreateDirectory(tgt);
75+
76+
var isDirPath = path.Combine(file.Key);
77+
var isDir = DirectoryExists(isDirPath);
78+
if (isDir)
79+
{
80+
var src = path.Combine(file.Key);
81+
CopyDirectory(src, tgt);
82+
}
83+
else
84+
{
85+
var src = path.CombineWithFilePath(file.Key);
86+
CopyFileToDirectory(src, tgt);
87+
}
88+
}
89+
90+
var nuspec = "cppsharp.nuspec";
91+
92+
var settings = new NuGetPackSettings()
93+
{
94+
OutputDirectory = ".",
95+
BasePath = scratchDir,
96+
NoPackageAnalysis = false,
97+
};
98+
99+
NuGetPack(nuspec, settings);
100+
101+
// clear current session
102+
DeleteDirectory(scratchDir, true);
103+
});
104+
105+
Task("CppSharpBuildAndPackage")
106+
.IsDependentOn("Build")
107+
.IsDependentOn("Package")
108+
.Does(() => {
109+
110+
});
111+
112+
Task("CppSharpPackageOnly")
113+
.IsDependentOn("Package")
114+
.Does(() => {
115+
116+
});
117+
118+
Task("Default")
119+
.IsDependentOn("CppSharpPackageOnly")
120+
.Does(() => {
121+
122+
});
123+
124+
125+
RunTarget(target);

0 commit comments

Comments
 (0)