Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tools/apidiff/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ tvos-*.md
watchos-*.md
macos-*.md
xamarin-*.md
.unzip.stamp
*.stamp
bundle-*.zip
47 changes: 26 additions & 21 deletions tools/apidiff/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,32 @@ MAC_ARCH_ASSEMBLIES = native-32/Xamarin.Mac native-64/Xamarin.Mac

APIDIFF_IGNORE = -i 'INSObjectProtocol'

.download-$(MONO_HASH).stamp:
$(MAKE) -C $(TOP)/builds download
$(Q) touch $@

$(MONO_API_INFO) $(MONO_API_HTML): .download-$(MONO_HASH).stamp

# create api info. Directory hierarchy is based on installed hierarchy
# (XM goes into temp/xm, and XI goes into temp/xi)

$(APIDIFF_DIR)/temp/xi/%.xml: $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/%.dll
$(APIDIFF_DIR)/temp/xi/%.xml: $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/%.dll $(MONO_API_INFO)
$(Q) mkdir -p $(dir $@)
$(QF_GEN) $(MONO_BUILD) --debug $(MONO_API_INFO) $< -o $@

$(APIDIFF_DIR)/temp/xm/%.xml: $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/%.dll
$(APIDIFF_DIR)/temp/xm/%.xml: $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/%.dll $(MONO_API_INFO)
$(Q) mkdir -p $(dir $@)
$(QF_GEN) $(MONO_BUILD) --debug $(MONO_API_INFO) -d $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/Xamarin.Mac $< -o $@

$(APIDIFF_DIR)/temp/xm/4.5/Xamarin.Mac.xml: $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/Xamarin.Mac.dll
$(APIDIFF_DIR)/temp/xm/4.5/Xamarin.Mac.xml: $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/Xamarin.Mac.dll $(MONO_API_INFO)
$(Q) mkdir -p $(dir $@)
$(QF_GEN) $(MONO_BUILD) --debug $(MONO_API_INFO) -d $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5 $< -o $@

$(APIDIFF_DIR)/temp/native-%/Xamarin.Mac.xml: $(TOP)/src/build/mac/mobile-%/Xamarin.Mac.dll
$(APIDIFF_DIR)/temp/native-%/Xamarin.Mac.xml: $(TOP)/src/build/mac/mobile-%/Xamarin.Mac.dll $(MONO_API_INFO)
$(Q) mkdir -p $(dir $@)
$(QF_GEN) $(MONO_BUILD) --debug $(MONO_API_INFO) -d $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/Xamarin.Mac $< -o $@

$(APIDIFF_DIR)/temp/native-%/Xamarin.iOS.xml: $(TOP)/src/build/ios/native-%/Xamarin.iOS.dll
$(APIDIFF_DIR)/temp/native-%/Xamarin.iOS.xml: $(TOP)/src/build/ios/native-%/Xamarin.iOS.dll $(MONO_API_INFO)
$(Q) mkdir -p $(dir $@)
$(QF_GEN) $(MONO_BUILD) --debug $(MONO_API_INFO) $< -o $@

Expand All @@ -76,13 +82,13 @@ $(APIDIFF_DIR)/temp/native-%/Xamarin.iOS.xml: $(TOP)/src/build/ios/native-%/Xama
# to run mono-api-html every time even if none of the
# dependencies changed)

$(APIDIFF_DIR)/diff/%.html: $(APIDIFF_DIR)/temp/%.xml $(APIDIFF_DIR)/references/%.xml
$(APIDIFF_DIR)/diff/%.html: $(APIDIFF_DIR)/temp/%.xml $(APIDIFF_DIR)/references/%.xml $(MONO_API_HTML)
$(Q) mkdir -p $(dir $@)
$(QF_GEN) $(MONO_BUILD) --debug $(MONO_API_HTML) $(NEW_REGEX) $(ADD_REGEX) $(APIDIFF_DIR)/references/$*.xml $(APIDIFF_DIR)/temp/$*.xml $(APIDIFF_IGNORE) $@
$(Q) touch $@

# this is a hack to show the difference between iOS and tvOS
$(APIDIFF_DIR)/diff/ios-to-tvos.html: $(APIDIFF_DIR)/temp/xi/Xamarin.iOS/Xamarin.iOS.xml $(APIDIFF_DIR)/temp/xi/Xamarin.TVOS/Xamarin.TVOS.xml
$(APIDIFF_DIR)/diff/ios-to-tvos.html: $(APIDIFF_DIR)/temp/xi/Xamarin.iOS/Xamarin.iOS.xml $(APIDIFF_DIR)/temp/xi/Xamarin.TVOS/Xamarin.TVOS.xml $(MONO_API_HTML)
$(Q) mkdir -p $(dir $@)
$(Q) sed -e 's_<assembly name="Xamarin.TVOS" version="0.0.0.0">_<assembly name="Xamarin.iOS" version="0.0.0.0">_' $(APIDIFF_DIR)/temp/xi/Xamarin.TVOS/Xamarin.TVOS.xml > $(APIDIFF_DIR)/temp/Xamarin.TVOS-as-iOS.xml
$(QF_GEN) $(MONO_BUILD) --debug $(MONO_API_HTML) $< $(APIDIFF_DIR)/temp/Xamarin.TVOS-as-iOS.xml $@
Expand Down Expand Up @@ -162,12 +168,13 @@ endif
# easy-to-type helper targets.
# one rule to create all the api diffs

all-local:: $(BUNDLE_ZIP) $(APIDIFF_DIR)/api-diff.html
all-local:: $(APIDIFF_DIR)/api-diff.html

# Rules to re-create the reference infos from the curretn stable 'bundle.zip. assemblies

# split the URL in words based on the path separator, and then chose the 6th word (the hash) in the bundle zip filename
BUNDLE_ZIP ?= $(APIDIFF_DIR)/bundle-$(word 6,$(subst /, ,$(APIDIFF_REFERENCES))).zip
APIDIFF_HASH ?= $(word 6,$(subst /, ,$(APIDIFF_REFERENCES)))
BUNDLE_ZIP ?= $(APIDIFF_DIR)/bundle-$(APIDIFF_HASH).zip
$(BUNDLE_ZIP):
# download to a temporary filename so interrupted downloads won't prevent re-downloads.
$(Q) if test -f ~/Library/Caches/xamarin-macios/$(notdir $@); then \
Expand All @@ -178,30 +185,31 @@ $(BUNDLE_ZIP):
fi
$(Q) mv $@.tmp $@

UNZIP_STAMP=$(APIDIFF_DIR)/.unzip.stamp
UNZIP_STAMP=$(APIDIFF_DIR)/.unzip.$(APIDIFF_HASH).stamp
UNZIP_DIR=temp/downloads/$(APIDIFF_HASH)
$(UNZIP_STAMP): $(BUNDLE_ZIP)
$(Q) rm -Rf temp/downloads
$(Q) mkdir -p temp
$(Q_GEN) unzip -q -d temp/downloads $(BUNDLE_ZIP)
$(Q) rm -Rf $(UNZIP_DIR)
$(Q) mkdir -p $(dir $(UNZIP_DIR))
$(Q_GEN) unzip -q -d $(UNZIP_DIR) $(BUNDLE_ZIP)
$(Q) touch $@

# the semi-colon at the end means an empty recipe, and is required for make to consider pattern rules
temp/downloads/%.dll: $(UNZIP_STAMP) ;
$(UNZIP_DIR)/%.dll: $(UNZIP_STAMP) ;

IOS_REFS = $(foreach file,$(IOS_ASSEMBLIES),$(APIDIFF_DIR)/updated-references/xi/$(file).xml)
MAC_REFS = $(foreach file,$(MAC_ASSEMBLIES),$(APIDIFF_DIR)/updated-references/xm/$(file).xml)
WATCHOS_REFS = $(foreach file,$(WATCHOS_ASSEMBLIES),$(APIDIFF_DIR)/updated-references/xi/$(file).xml)
TVOS_REFS = $(foreach file,$(TVOS_ASSEMBLIES),$(APIDIFF_DIR)/updated-references/xi/$(file).xml)

$(APIDIFF_DIR)/references/xi/%.xml: temp/downloads/%.dll $(MONO_API_INFO)
$(APIDIFF_DIR)/references/xi/%.xml: $(UNZIP_DIR)/%.dll $(MONO_API_INFO)
$(Q) mkdir -p $(dir $@) $(dir $(APIDIFF_DIR)/references/xi/$*)
$(QF_GEN) mono --debug $(MONO_API_INFO) $< -o $(APIDIFF_DIR)/references/xi/$*.xml

$(APIDIFF_DIR)/updated-references/xi/%.xml: $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/%.dll $(MONO_API_INFO)
$(Q) mkdir -p $(dir $@) $(dir $(APIDIFF_DIR)/references/xi/$*)
$(QF_GEN) mono --debug $(MONO_API_INFO) $< -o $(APIDIFF_DIR)/references/xi/$*.xml

$(APIDIFF_DIR)/references/xm/%.xml: temp/downloads/%.dll $(MONO_API_INFO)
$(APIDIFF_DIR)/references/xm/%.xml: $(UNZIP_DIR)/%.dll $(MONO_API_INFO)
$(Q) mkdir -p $(dir $@) $(dir $(APIDIFF_DIR)/references/xm/$*)
$(QF_GEN) mono --debug $(MONO_API_INFO) $< -o $(APIDIFF_DIR)/references/xm/$*.xml

Expand Down Expand Up @@ -238,11 +246,8 @@ $(DIRS):
$(Q) mkdir -p $@

# make will automatically consider files created in chained implicit rules as temporary files, and delete them afterwards
# marking those files as .SECONDARY will prevent that deletion.
.SECONDARY: $(foreach file,$(IOS_ASSEMBLIES),$(APIDIFF_DIR)/temp/xi/$(file).xml)
.SECONDARY: $(foreach file,$(MAC_ASSEMBLIES),$(APIDIFF_DIR)/temp/xm/$(file).xml)
.SECONDARY: $(foreach file,$(WATCHOS_ASSEMBLIES),$(APIDIFF_DIR)/temp/xi/$(file).xml)
.SECONDARY: $(foreach file,$(TVOS_ASSEMBLIES),$(APIDIFF_DIR)/temp/xi/$(file).xml)
# defining a .SECONDARY rule will prevent that deletion.
.SECONDARY:

merger.exe: merger.cs
$(Q) $(SYSTEM_CSC) -debug $< -out:$@
Expand Down
36 changes: 25 additions & 11 deletions tools/compare-commits.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,12 @@ CURRENT_HASH=$(git log -1 --pretty=%H)
GENERATOR_DIFF_FILE=
APIDIFF_FILE=

function upon_exit ()
HASH_RESTORED=
function restore_hash ()
{
if test -z "$CURRENT_BRANCH"; then
if test -n "$HASH_RESTORED"; then
echo "Previous hash/branch already restored."
elif test -z "$CURRENT_BRANCH"; then
echo "Restoring the previous hash ${BLUE}${CURRENT_HASH}${CLEAR} (there was no previous branch; probably because HEAD was detached)"
git checkout --force "$CURRENT_HASH"
echo "Previous hash restored successfully."
Expand All @@ -143,6 +146,12 @@ function upon_exit ()
git reset --hard "$CURRENT_HASH"
echo "Previous branch restored successfully."
fi
HASH_RESTORED=1
}

function upon_exit ()
{
restore_hash

if ! test -z "$GENERATOR_DIFF_FILE"; then
echo "Generator diff: $GENERATOR_DIFF_FILE"
Expand Down Expand Up @@ -202,6 +211,9 @@ fi
#
# API diff
#
# First we calculate the apidiff references for the hash we're comparing against
# Then we restore the original hash, and finally we calculate the api diff.
#

# Calculate apidiff references according to the temporary build
echo "${BLUE}Updating apidiff references...${CLEAR}"
Expand All @@ -211,15 +223,6 @@ if ! make update-refs -C "$ROOT_DIR/tools/apidiff" -j8 APIDIFF_DIR="$OUTPUT_DIR/
exit "$EC"
fi

# Now compare the current build against those references
echo "${BLUE}Running apidiff...${CLEAR}"
APIDIFF_FILE=$OUTPUT_DIR/apidiff/api-diff.html
if ! make all-local -C "$ROOT_DIR/tools/apidiff" -j8 APIDIFF_DIR="$OUTPUT_DIR/apidiff"; then
EC=$?
report_error_line "${RED}Failed to run apidiff${CLEAR}"
exit "$EC"
fi

#
# Generator diff
#
Expand Down Expand Up @@ -251,3 +254,14 @@ if test -n "$MODIFIED_FILES"; then
echo "$MODIFIED_FILES" | sed 's/^/ /' | while read line; do report_error_line "$line"; done
exit 1
fi

restore_hash

# Now compare the current build against those references
echo "${BLUE}Running apidiff...${CLEAR}"
APIDIFF_FILE=$OUTPUT_DIR/apidiff/api-diff.html
if ! make all-local -C "$ROOT_DIR/tools/apidiff" -j8 APIDIFF_DIR="$OUTPUT_DIR/apidiff"; then
EC=$?
report_error_line "${RED}Failed to run apidiff${CLEAR}"
exit "$EC"
fi