Skip to content

Commit

Permalink
Merge pull request #980 from vktr/feature/better-builds
Browse files Browse the repository at this point in the history
Better builds
  • Loading branch information
vktr committed Oct 17, 2020
2 parents 3b20888 + c1eca0f commit 578ead0
Show file tree
Hide file tree
Showing 40 changed files with 135 additions and 425 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": {
"cake.tool": {
"version": "0.38.5",
"commands": [
"dotnet-cake"
]
}
}
}
22 changes: 15 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,46 @@ jobs:
- name: Setup Git
run: |
git fetch --prune --unshallow
git ls-tree HEAD vendor/crashpad vendor/fmt vendor/libtorrent vendor/loguru vendor/nlohmann-json vendor/wx > .vendor-status
git ls-tree HEAD vendor/fmt vendor/libtorrent vendor/loguru vendor/nlohmann-json vendor/sentry-crashpad vendor/wx > .vendor-status
- name: Restore cache
uses: actions/cache@v2
with:
path: |
build-${{ matrix.arch }}/vendor
build-${{ matrix.arch }}
!build-${{ matrix.arch }}/PicoTorrent-coredb.dir
!build-${{ matrix.arch }}/PicoTorrent.dir
!build-${{ matrix.arch }}/Plugin_Filters.dir
!build-${{ matrix.arch }}/Plugin_Updater.dir
!build-${{ matrix.arch }}/Release
!build-${{ matrix.arch }}/CMakeCache.txt
key: ${{ runner.os }}-${{ matrix.arch }}-${{ hashFiles('.vendor-status') }}

- name: Prepare
run: |
git submodule update --init --recursive
- name: Install OpenSSL
- name: Install dependencies
run: |
if ('${{ matrix.arch }}' -eq 'x64') {
choco install openssl --no-progress
} elseif ('${{ matrix.arch }}' -eq 'x86') {
choco install openssl --no-progress --x86
}
dotnet tool restore
- name: Set environment variables
run: |
echo "::set-env name=BOOST_ROOT::$env:BOOST_ROOT_1_72_0"
echo "BOOST_ROOT=$env:BOOST_ROOT_1_72_0" >> $GITHUB_ENV
if ('${{ matrix.arch }}' -eq 'x64') {
echo "::set-env name=OPENSSL_ROOT_DIR::$env:ProgramFiles\OpenSSL-Win64"
echo "OPENSSL_ROOT_DIR=$env:ProgramFiles\OpenSSL-Win64" >> $GITHUB_ENV
} elseif ('${{ matrix.arch }}' -eq 'x86') {
echo "::set-env name=OPENSSL_ROOT_DIR::${env:ProgramFiles(x86)}\OpenSSL-Win32"
echo "OPENSSL_ROOT_DIR=${env:ProgramFiles(x86)}\OpenSSL-Win32" >> $GITHUB_ENV
}
- name: Build
run: .\build.ps1 -Configuration Release -Platform ${{ matrix.arch }}
run: dotnet cake --platform=${{ matrix.arch }} --target=Publish

- name: Upload artifacts
uses: actions/upload-artifact@v2
Expand Down
17 changes: 2 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
build-x64/
build-x86/
build/
docs/build
packaging/AppX/PicoTorrent.mapping
packaging/AppX/PicoTorrentManifest.xml
packaging/Chocolatey/tools/chocolateyinstall.ps1
src/VersionInformation.cpp
src/core/version_info.cpp
src/picotorrent/buildinfo.cpp
tools/Cake
tools/Cake.CMake
tools/gitversion*
tools/Microsoft.ChakraCore.vc140
tools/nuget.exe
tools/Rasterbar-libtorrent
tools/PicoTorrent.Crashpad.vc142
tools/UnidentifiedDeveloper.Crashpad.vc142
tools/WiX
tools/wxWidgets
tools
.vscode
[D|d]ebug
[R|r]elease
Expand Down
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_policy(SET CMP0092 NEW) # don't add /W3 as default

project("PicoTorrent")

Expand Down Expand Up @@ -64,7 +65,7 @@ configure_file("${CMAKE_SOURCE_DIR}/src/picotorrent/buildinfo.cpp.in" "${CMAKE_S
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Zi")

# Release flags
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GUARD:CF /Zi")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /INCREMENTAL:NO /MAP /OPT:REF /OPT:ICF")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "/DEBUG /INCREMENTAL:NO /MAP /OPT:REF /OPT:ICF")

Expand Down Expand Up @@ -232,6 +233,8 @@ target_compile_definitions(
-DPICO_WX_GIT_COMMITISH=${PICO_WX_GIT_COMMITISH}
)

target_compile_options(PicoTorrent PRIVATE /guard:cf /W4 /WX)

target_include_directories(
PicoTorrent
PRIVATE
Expand Down Expand Up @@ -295,7 +298,7 @@ add_library(
src/plugins/updater/updater
)

target_compile_definitions(Plugin_Updater PRIVATE -D_UNICODE -D_WIN32 -DWIN32_LEAN_AND_MEAN)
target_compile_definitions(Plugin_Updater PRIVATE -D_WIN32 -DUNICODE -DWIN32_LEAN_AND_MEAN)
target_include_directories(Plugin_Updater PRIVATE include)
target_link_libraries(Plugin_Updater PRIVATE PicoTorrent Comctl32)

Expand Down
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,12 @@ applications installed,
* [Boost 1.73.0](https://www.boost.org).
* [Chocolatey](https://chocolatey.org/install) (Optional) if you plan to build
or test the Chocolatey package.

Make sure all submodules are updated.
* [.NET Core](https://dotnet.microsoft.com/download). Used for the build scripts.

```
λ git submodule update --init --recursive
```

Build your desired configuration and architecture.

```
λ .\build.ps1 --platform [x86|x64] --configuration [Debug|Release]
λ dotnet tool restore
λ dotnet cake --platorm=[x86|x64] --configuration=[Debug|Release]
```


Expand Down
117 changes: 17 additions & 100 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#tool "nuget:?package=GitVersion.CommandLine&version=5.3.7"
#addin "nuget:?package=Cake.CMake&version=1.2.0"
#tool "nuget:?package=GitVersion.CommandLine&version=5.3.7"
#tool "nuget:?package=WiX&version=3.11.2"

//////////////////////////////////////////////////////////////////////
// ARGUMENTS
Expand All @@ -15,30 +17,12 @@ var PackagesDirectory = BuildDirectory + Directory("packages");
var PublishDirectory = BuildDirectory + Directory("publish");
var ResourceDirectory = Directory("./res");

var SigningCertificate = EnvironmentVariable("PICO_SIGNING_CERTIFICATE");
var SigningPassword = EnvironmentVariable("PICO_SIGNING_PASSWORD");
var SigningPublisher = EnvironmentVariable("PICO_SIGNING_PUBLISHER") ?? "CN=PicoTorrent TESTING";

var Version = GitVersion();
var Installer = string.Format("PicoTorrent-{0}-{1}.msi", Version.SemVer, platform);
var InstallerBundle = string.Format("PicoTorrent-{0}-{1}.exe", Version.SemVer, platform);
var PortablePackage = string.Format("PicoTorrent-{0}-{1}.zip", Version.SemVer, platform);
var SymbolsPackage = string.Format("PicoTorrent-{0}-{1}.symbols.zip", Version.SemVer, platform);

var LibrarySuffix = configuration == "Release" ? "" : "d";

public void SignFile(FilePath file, string description = "")
{
Sign(file,
new SignToolSignSettings
{
Description = description,
CertPath = SigningCertificate,
Password = SigningPassword,
TimeStampUri = new Uri("http://timestamp.digicert.com")
});
}

//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Expand All @@ -53,16 +37,13 @@ Task("Generate-Project")
.IsDependentOn("Clean")
.Does(() =>
{
var cmakePath = Context.Tools.Resolve("cmake.exe");
StartProcess(cmakePath, new ProcessSettings
CMake(new CMakeSettings
{
Arguments = new ProcessArgumentBuilder()
.Append("-S").AppendQuoted(".")
.Append("-B").AppendQuoted(OutputDirectory)
.Append("-G").AppendQuoted("Visual Studio 16 2019")
.Append("-A").AppendQuoted(platform == "x86" ? "Win32" : "x64")
.Append("-T").AppendQuoted("v142"),
SourcePath = ".",
OutputPath = OutputDirectory,
Generator = "Visual Studio 16 2019",
Platform = platform == "x86" ? "Win32" : "x64",
Toolset = "v142"
});
});

Expand All @@ -71,8 +52,9 @@ Task("Build")
.Does(() =>
{
var settings = new MSBuildSettings()
.SetConfiguration(configuration)
.UseToolVersion(MSBuildToolVersion.VS2019);
.SetConfiguration(configuration)
.SetMaxCpuCount(0)
.UseToolVersion(MSBuildToolVersion.VS2019);
if(platform == "x86")
{
Expand All @@ -85,7 +67,11 @@ Task("Build")
.SetPlatformTarget(PlatformTarget.x64);
}
MSBuild(OutputDirectory + File("PicoTorrent.sln"), settings);
MSBuild(OutputDirectory + File("PicoTorrent.vcxproj"), settings);
// Plugins
MSBuild(OutputDirectory + File("Plugin_Filters.vcxproj"), settings);
MSBuild(OutputDirectory + File("Plugin_Updater.vcxproj"), settings);
});

Task("Setup-Publish-Directory")
Expand Down Expand Up @@ -208,87 +194,18 @@ Task("Build-Symbols-Package")
Zip(BuildDirectory, PackagesDirectory + File(SymbolsPackage), files);
});

Task("Build-Chocolatey-Package")
.IsDependentOn("Build-Installer")
.Does(() =>
{
TransformTextFile("./packaging/Chocolatey/tools/chocolateyinstall.ps1.template", "%{", "}")
.WithToken("Installer", InstallerBundle)
.WithToken("Version", Version.MajorMinorPatch)
.Save("./packaging/Chocolatey/tools/chocolateyinstall.ps1");
var currentDirectory = MakeAbsolute(Directory("."));
var cd = MakeAbsolute(PackagesDirectory);
var nuspec = MakeAbsolute(File("./packaging/Chocolatey/picotorrent.nuspec"));
System.IO.Directory.SetCurrentDirectory(cd.ToString());
ChocolateyPack(nuspec, new ChocolateyPackSettings
{
Version = Version.MajorMinorPatch
});
System.IO.Directory.SetCurrentDirectory(currentDirectory.ToString());
});

Task("Sign")
.IsDependentOn("Build")
.WithCriteria(() => SigningCertificate != null && SigningPassword != null)
.Does(() =>
{
SignFile(BuildDirectory + File("PicoTorrent.exe"), "PicoTorrent");
});

Task("Sign-Installer")
.IsDependentOn("Build-Installer")
.WithCriteria(() => SigningCertificate != null && SigningPassword != null)
.Does(() =>
{
var file = PackagesDirectory + File(Installer);
SignFile(file);
});

Task("Sign-Installer-Bundle")
.IsDependentOn("Build-Installer-Bundle")
.WithCriteria(() => SigningCertificate != null && SigningPassword != null)
.Does(() =>
{
var bundle = PackagesDirectory + File(InstallerBundle);
var insignia = Directory("tools")
+ Directory("WiX")
+ Directory("tools")
+ File("insignia.exe");
// Detach Burn engine
StartProcess(insignia, "-ib \"" + bundle + "\" -o build/BurnEngine.exe");
SignFile("build/BurnEngine.exe");
StartProcess(insignia, "-ab build/BurnEngine.exe \"" + bundle + "\" -o \"" + bundle + "\"");
// Sign the bundle
SignFile(bundle);
});

//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////

Task("Default")
.IsDependentOn("Build")
.IsDependentOn("Build-Installer")
.IsDependentOn("Build-Installer-Bundle")
.IsDependentOn("Build-Chocolatey-Package")
.IsDependentOn("Build-Portable-Package")
.IsDependentOn("Build-Symbols-Package")
;

Task("Publish")
.IsDependentOn("Build")
.IsDependentOn("Sign")
.IsDependentOn("Build-Installer")
.IsDependentOn("Build-Installer-Bundle")
.IsDependentOn("Sign-Installer")
.IsDependentOn("Sign-Installer-Bundle")
.IsDependentOn("Build-Chocolatey-Package")
.IsDependentOn("Build-Portable-Package")
.IsDependentOn("Build-Symbols-Package");

Expand Down
57 changes: 0 additions & 57 deletions build.ps1

This file was deleted.

0 comments on commit 578ead0

Please sign in to comment.