Skip to content

Commit

Permalink
Preliminary script for building 32-bit Nuget package (#1015)
Browse files Browse the repository at this point in the history
  • Loading branch information
aybe authored and tritao committed Jan 14, 2018
1 parent d8b5372 commit 066e8fc
Show file tree
Hide file tree
Showing 7 changed files with 551 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,8 @@ src/generator/generator
/site
/wip
/.vs

# Nuget: do not include produced packages
/build/nuget/*.nupkg
/build/nuget/tools/*

23 changes: 23 additions & 0 deletions build/nuget/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"name": "Cake: Debug Script (CoreCLR)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceRoot}/tools/Cake.CoreCLR/Cake.dll",
"args": [
"${workspaceRoot}/build.cake",
"--debug",
"--verbosity=diagnostic"
],
"cwd": "${workspaceRoot}",
"stopAtEntry": true,
"externalConsole": false
}
]
}
17 changes: 17 additions & 0 deletions build/nuget/TODO.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Notes and TODOs

- Microsoft.VisualStudio.Setup.Configuration.Interop has been added to nuspec,
but for some reason it never copies itself to output, it has to be done manually.
Additionally, the 64-bit nuget package does not need that (TODO Confirm this).

- Baseclass.Contrib.Nuget.Output is problematic, whenever you update it,
Visual Studio complains and says it must restart, over and over.

- Nuget package warnings should be fixed/suppressed.

- Should there be two packages : x86 and x64 ?

- Only Visual Studio 2017 32-bit solution is supported, once a 64-bit solution
is available, build.cake should be enhanced.

- Whatever else I've missed ...
125 changes: 125 additions & 0 deletions build/nuget/build.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
///////////////////////////////////////////////////////////////////////////////

var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");

///////////////////////////////////////////////////////////////////////////////
// SETUP / TEARDOWN
///////////////////////////////////////////////////////////////////////////////

Setup(ctx =>
{
// Executed BEFORE the first task.
Information("Running tasks...");
});

Teardown(ctx =>
{
// Executed AFTER the last task.
Information("Finished running tasks.");
});

///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////

Task("Build")
.Does(() => {
if (!IsRunningOnWindows())
throw new NotImplementedException("TODO Implement other platforms");
// TODO update this when there's a 64-bit solution
var settings = new MSBuildSettings();
settings.SetConfiguration("Release");
settings.SetPlatformTarget(PlatformTarget.x86);
MSBuild("../vs2017/CppSharp.sln", settings);
});

Task("Package")
.Does(() => {
var scratchDir = new DirectoryPath("temp");
// clear previous session
if (DirectoryExists(scratchDir))
DeleteDirectory(scratchDir, true);
var files = new Dictionary<string,string>()
{
{ "CppSharp.dll", "lib" },
{ "CppSharp.AST.dll", "lib" },
{ "CppSharp.Generator.dll", "lib" },
{ "CppSharp.Parser.dll", "lib" },
{ "CppSharp.Parser.CLI.dll", "lib" },
{ "CppSharp.Runtime.dll", "lib" },
{ "CppSharp.CLI.exe", "tools"},
{ "CppSharp.CppParser.dll", "output"},
{ "clang", "output/lib/clang"},
};
var path = new DirectoryPath("../vs2017/lib/Release_x86/");
CreateDirectory(scratchDir);
foreach (var file in files)
{
var tgt = scratchDir.Combine(file.Value);
CreateDirectory(tgt);
var isDirPath = path.Combine(file.Key);
var isDir = DirectoryExists(isDirPath);
if (isDir)
{
var src = path.Combine(file.Key);
CopyDirectory(src, tgt);
}
else
{
var src = path.CombineWithFilePath(file.Key);
CopyFileToDirectory(src, tgt);
}
}
var nuspec = "cppsharp.nuspec";
var settings = new NuGetPackSettings()
{
OutputDirectory = ".",
BasePath = scratchDir,
NoPackageAnalysis = false,
};
NuGetPack(nuspec, settings);
// clear current session
DeleteDirectory(scratchDir, true);
});

Task("CppSharpBuildAndPackage")
.IsDependentOn("Build")
.IsDependentOn("Package")
.Does(() => {
});

Task("CppSharpPackageOnly")
.IsDependentOn("Package")
.Does(() => {
});

Task("Default")
.IsDependentOn("CppSharpPackageOnly")
.Does(() => {
});


RunTarget(target);
Loading

0 comments on commit 066e8fc

Please sign in to comment.