Skip to content

Commit

Permalink
Support building the workspaces layer in source-build. Also added a v…
Browse files Browse the repository at this point in the history
…erification step to CI to ensure we don't break the build.
  • Loading branch information
333fred committed Aug 30, 2019
1 parent e512863 commit 4f6fe5d
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 1 deletion.
17 changes: 17 additions & 0 deletions azure-pipelines.yml
Expand Up @@ -210,6 +210,23 @@ jobs:
continueOnError: true
condition: not(succeeded())

- job: SourceBuild_Test
pool:
name: NetCorePublic-Pool
queue: BuildPool.Ubuntu.1604.amd64.Open
timeoutInMinutes: 90
steps:
- script: ./eng/cibuild.sh --configuration Debug --prepareMachine --docker --sourceBuild
displayName: Build
- task: PublishBuildArtifacts@1
displayName: Publish Logs
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/artifacts/log/Debug'
ArtifactName: 'SourceBuild_Test'
publishLocation: Container
continueOnError: true
condition: not(succeeded())

- job: macOS_Test
pool:
vmImage: 'macOS-10.13'
Expand Down
6 changes: 6 additions & 0 deletions eng/build.ps1
Expand Up @@ -42,6 +42,7 @@ param (
[switch]$prepareMachine,
[switch]$useGlobalNuGetCache = $true,
[switch]$warnAsError = $false,
[switch]$sourceBuild = $false,

# official build settings
[string]$officialBuildId = "",
Expand Down Expand Up @@ -102,6 +103,7 @@ function Print-Usage() {
Write-Host " -prepareMachine Prepare machine for CI run, clean up processes after build"
Write-Host " -useGlobalNuGetCache Use global NuGet cache."
Write-Host " -warnAsError Treat all warnings as errors"
Write-Host " -sourceBuild Simulate building source-build"
Write-Host ""
Write-Host "Official build settings:"
Write-Host " -officialBuildId An official build id, e.g. 20190102.3"
Expand Down Expand Up @@ -233,6 +235,9 @@ function BuildSolution() {
# Workaround for some machines in the AzDO pool not allowing long paths (%5c is msbuild escaped backslash)
$ibcDir = Join-Path $RepoRoot ".o%5c"

# Set DotNetBuildFromSource to 'true' if we're simulating building for source-build.
$buildFromSource = if ($sourceBuild) { "/p:DotNetBuildFromSource=true" } else { "" }

try {
MSBuild $toolsetBuildProj `
$bl `
Expand All @@ -258,6 +263,7 @@ function BuildSolution() {
/p:IbcOptimizationDataDir=$ibcDir `
$suppressExtensionDeployment `
$msbuildWarnAsError `
$buildFromSource `
@properties
}
finally {
Expand Down
6 changes: 6 additions & 0 deletions eng/build.sh
Expand Up @@ -34,6 +34,7 @@ usage()
echo " --skipAnalyzers Do not run analyzers during build operations"
echo " --prepareMachine Prepare machine for CI run, clean up processes after build"
echo " --warnAsError Treat all warnings as errors"
echo " --sourceBuild Simulate building for source-build"
echo ""
echo "Command line arguments starting with '/p:' are passed through to MSBuild."
}
Expand Down Expand Up @@ -68,6 +69,7 @@ prepare_machine=false
warn_as_error=false
properties=""
disable_parallel_restore=false
source_build=false

docker=false
args=""
Expand Down Expand Up @@ -141,6 +143,9 @@ while [[ $# > 0 ]]; do
shift
continue
;;
--sourcebuild)
source_build=true
;;
/p:*)
properties="$properties $1"
;;
Expand Down Expand Up @@ -274,6 +279,7 @@ function BuildSolution {
/p:TreatWarningsAsErrors=true \
/p:RestoreDisableParallel=$disable_parallel_restore \
/p:TestRuntimeAdditionalArguments=$test_runtime_args \
/p:DotNetBuildFromSource=$source_build \
$test_runtime \
$mono_tool \
$properties
Expand Down
4 changes: 4 additions & 0 deletions eng/targets/Settings.props
Expand Up @@ -194,4 +194,8 @@
</PropertyGroup>
</When>
</Choose>

<PropertyGroup Condition="'$(DotNetBuildFromSource)' == 'true'">
<DefineConstants>DotNetBuildFromSource</DefineConstants>
</PropertyGroup>
</Project>
Expand Up @@ -24,10 +24,11 @@
<ProjectReference Include="..\..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="$(SQLitePCLRawbundle_greenVersion)" PrivateAssets="all" />
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="$(SQLitePCLRawbundle_greenVersion)" PrivateAssets="all" Condition="'$(DotNetBuildFromSource)' != 'true'" />
<PackageReference Include="System.Composition" Version="$(SystemCompositionVersion)" />
</ItemGroup>
<ItemGroup Label="Linked Files">
<Compile Remove="Storage\Sqlite\**\*.cs" Condition="'$(DotNetBuildFromSource)' == 'true'" />
<Compile Include="..\..\..\CodeStyle\Core\CodeFixes\FixAllContextHelper.cs" Link="CodeFixes\FixAllOccurrences\FixAllContextHelper.cs" />
<Compile Include="..\..\..\Compilers\Shared\DesktopAnalyzerAssemblyLoader.cs">
<Link>Execution\Desktop\DesktopAnalyzerAssemblyLoader.cs</Link>
Expand Down
Expand Up @@ -5,7 +5,10 @@
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.SolutionSize;
// When building for source-build, there is no sqlite dependency
#if !DotNetBuildFromSource
using Microsoft.CodeAnalysis.SQLite;
#endif

namespace Microsoft.CodeAnalysis.Storage
{
Expand All @@ -22,6 +25,7 @@ public PersistenceStorageServiceFactory(ISolutionSizeTracker solutionSizeTracker

public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices)
{
#if !DotNetBuildFromSource
var optionService = workspaceServices.GetRequiredService<IOptionService>();
var database = optionService.GetOption(StorageOptions.Database);
switch (database)
Expand All @@ -35,6 +39,7 @@ public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices)

break;
}
#endif

return NoOpPersistentStorageService.Instance;
}
Expand Down

0 comments on commit 4f6fe5d

Please sign in to comment.