diff --git a/src/Makefile b/src/Makefile index 1063650ce25a..81b73d55c5b1 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1213,6 +1213,12 @@ dotnet-gen:: dotnet-gen-$(3) $($(2)_DOTNET_BUILD_DIR)/ILLink.LinkAttributes.xml: $(TOP)/src/ILLink.LinkAttributes.xml.in | $($(2)_DOTNET_BUILD_DIR) $$(call Q_PROF_GEN,$(3)) sed < $$< > $$@ 's|@PRODUCT_NAME@|Microsoft.$(1)|g;' +$($(2)_DOTNET_BUILD_DIR)/SourceLink.json: $($(2)_DOTNET_BUILD_DIR) + $$(Q) $(TOP)/src/generate-sourcelink-json.csharp "$(PACKAGE_HEAD_REV)" "$(abspath $(TOP)/src)" "$$@" >/dev/null 2>&1 + +$($(2)_DOTNET_BUILD_DIR)/embed-files.rsp: $($(2)_DOTNET_BUILD_DIR)/$(3)-generated-sources + $$(Q) $(TOP)/src/generate-embed-files.sh $($(2)_DOTNET_BUILD_DIR) $(3) > $$@ + $($(2)_DOTNET_BUILD_DIR)/ILLink.Substitutions.xml: $(TOP)/src/ILLink.Substitutions.$(1).xml | $($(2)_DOTNET_BUILD_DIR) $(Q) $(CP) $$< $$@ @@ -1259,6 +1265,8 @@ endif $(2)_DOTNET_PLATFORM_ASSEMBLY_DEPENDENCIES = \ $($(2)_DOTNET_SOURCES) \ $($(2)_DOTNET_BUILD_DIR)/$(3)-generated-sources \ + $($(2)_DOTNET_BUILD_DIR)/SourceLink.json \ + $($(2)_DOTNET_BUILD_DIR)/embed-files.rsp \ $($(2)_DOTNET_BUILD_DIR)/ILLink.LinkAttributes.xml \ $($(2)_DOTNET_BUILD_DIR)/ILLink.Substitutions.xml \ $(PRODUCT_KEY_PATH) \ @@ -1277,6 +1285,8 @@ $($(2)_DOTNET_BUILD_DIR)/$(4)/Microsoft.$(1)%dll $($(2)_DOTNET_BUILD_DIR)/$(4)/M -publicsign -keyfile:$(PRODUCT_KEY_PATH) \ $$($(2)_$(4)_REFOUT_ARG) \ $$($(2)_$(4)_DOC_ARG) \ + -sourcelink:$($(2)_DOTNET_BUILD_DIR)/SourceLink.json \ + @$($(2)_DOTNET_BUILD_DIR)/embed-files.rsp \ $$($(2)_DEFINES) \ $(ARGS_$(4)) \ $$(DOTNET_WARNINGS_TO_FIX) \ diff --git a/src/generate-embed-files.sh b/src/generate-embed-files.sh new file mode 100755 index 000000000000..45397ce51a66 --- /dev/null +++ b/src/generate-embed-files.sh @@ -0,0 +1,28 @@ +#!/bin/bash -e + +find_files() { + find "$(realpath "$1")" -type f -name "$2" -exec printf "%s," {} + +} + +build_dir="$1" +platform="$2" + +if [ "$platform" = "macos" ]; then + modified_platform="mac" +else + modified_platform="$platform" +fi + +root="$(realpath "$build_dir/../../../..")" + +# find generated/untracked files +# impt to include, otherwise sourcelink test will fail (don't have a valid source file to link to) +files=$(find_files "$build_dir" "*.g.cs") +files+=$(find_files "$root/src/build/common" "*.cs") +files+=$(find_files "$root/src/build/$modified_platform" "AssemblyInfo.cs") +files+=$(find_files "$root/src/build/$modified_platform" "Constants.cs") +files+=$(find_files "$root/src/build/dotnet" "Constants.$platform.generated.cs") +files+=$(find_files "$root/runtime" "*generated.cs") +files+=$(find_files "$root/src" "MinimumVersions.cs") +files="-embed:${files%,}" +echo $files diff --git a/src/generate-sourcelink-json.csharp b/src/generate-sourcelink-json.csharp new file mode 100755 index 000000000000..5581cb6fe353 --- /dev/null +++ b/src/generate-sourcelink-json.csharp @@ -0,0 +1,25 @@ +#!/usr/bin/env /Library/Frameworks/Mono.framework/Commands/csharp + +using System.IO; +using System.Text; + +var args = Environment.GetCommandLineArgs (); + +var latestCommit = args [2]; +var src = args [3]; +var outputPath = args [4]; + +var json = new StringBuilder (); +json.AppendLine ("{"); +json.AppendLine (" \"documents\": {"); + +json.AppendLine ($" \"{src}*\": \"https://raw.githubusercontent.com/xamarin/xamarin-macios/{latestCommit}/src/*\""); +json.AppendLine (" }"); +json.AppendLine ("}"); + +string outputData = json.ToString (); +using (StreamWriter writer = new StreamWriter(outputPath)) +{ + writer.Write(outputData); +} +