Skip to content

Commit

Permalink
[builds] Remove all legacy logic. (#21307)
Browse files Browse the repository at this point in the history
We still need some of the source files from the legacy Mono library, but it's
only a few files, so just add them to the git repo.

Also implement caching of the .NET download, which speeds up clean rebuilds
significantly.

Note: all the files in the `builds/mono-ios-sdk-destdir` are a straight import
from the Mono archive, so those shouldn't need much reviewing (nor will I
change them unless absolutely necessary).
  • Loading branch information
rolfbjarne authored and haritha-mohan committed Oct 19, 2024
1 parent 86db6e3 commit ae2322f
Show file tree
Hide file tree
Showing 75 changed files with 11,603 additions and 346 deletions.
17 changes: 1 addition & 16 deletions Make.config
Original file line number Diff line number Diff line change
Expand Up @@ -637,22 +637,7 @@ JENKINS_RESULTS_DIRECTORY ?= $(abspath $(TOP)/jenkins-results)
# Clone files instead of copying them on APFS file systems. Much faster.
CP:=$(shell df -t apfs / >/dev/null 2>&1 && echo "cp -c" || echo "cp")

# WORKAROUND, Ideally it should be xcode-$(XCODE_PRODUCT_BUILD_VERSION) but mono does not build binaries for each xcode release
# Xcode 12.4 Build 12D4e
XCODE_IOS_ARCHIVE_VERSION=xcode-12D4e
# Xcode 12.4 Build 12D4e
XCODE_MACOS_ARCHIVE_VERSION=xcode-12D4e
MONO_IOS_FILENAME:=ios-release-Darwin-$(MONO_HASH).7z
MONO_IOS_URL:=https://download.mono-project.com/mono-sdks/$(XCODE_IOS_ARCHIVE_VERSION)/$(MONO_IOS_FILENAME)

# Setup various variables depending on whether mono is downloaded or built from source
ifeq ($(MONO_BUILD_FROM_SOURCE),)
MONO_IOS_SDK_DESTDIR:=$(abspath $(TOP)/builds/downloads/$(basename $(MONO_IOS_FILENAME)))
MONO_BUILD_MODE=download-mono
else
MONO_IOS_SDK_DESTDIR:=$(abspath $(MONO_PATH)/sdks/out)
MONO_BUILD_MODE=compile-mono
endif
MONO_IOS_SDK_DESTDIR:=$(abspath $(TOP)/builds/downloads/mono-ios-sdk-destdir)

# This variable includes all the platforms we support, even those that might be disabled in this build.
ALL_PLATFORMS=iOS tvOS watchOS macOS
Expand Down
28 changes: 0 additions & 28 deletions builds/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,3 @@ dotnet-install.sh
BundledNETCorePlatformsPackageVersion.txt
downloads
.stamp*
.deps.*.mk
*.config.cache
install
mac32
mac64
llvm
llvm64
simulator86
simulator64
watchsimulator
tvsimulator
tools64
cross
cross64
crosstv
cross-watch
target7
target7s
target64
targettv
targetwatch
watchbcl
mono-ios-sdk-destdir
*.dylib
*.o
x86-64-slice*
*.pkg

85 changes: 12 additions & 73 deletions builds/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,68 +12,22 @@ else
DOTNET_ARCH=x64
endif

##
## Mono download vs. build
##

download: download-mono
download-mono: \
downloads/$(basename $(MONO_IOS_FILENAME)) \

downloads/$(basename $(MONO_IOS_FILENAME)): MONO_URL=$(MONO_IOS_URL)

include $(TOP)/mk/colors.mk

DOWNLOADS = \
downloads/$(MONO_IOS_FILENAME) \

# This target downloads the mono archives, there's one for Xamarin.iOS and one for Xamarin.Mac.
# If doing many clean builds, it's possible to copy the downloaded zip file to ~/Library/Caches/xamarin-macios
# to avoid having to download it every time. The zip files have to be copied manually, otherwise
# we'd end up filling up a lot of hard drives around the world.
$(DOWNLOADS):
$(Q) mkdir -p downloads
$(Q) echo "Downloading $(MONO_URL)..."
$(Q) if test -f ~/Library/Caches/xamarin-macios/$(notdir $@); then \
echo "Found a cached version of $(MONO_URL) in ~/Library/Caches/xamarin-macios/$(notdir $@)."; \
$(CP) ~/Library/Caches/xamarin-macios/$(notdir $@) $@.tmp; \
else \
EC=0; \
$(CURL_RETRY) $(MONO_URL) --output $@.tmp || EC=$$?; \
if [[ x$$EC == x22 ]]; then \
MSG="Could not download the archive %s because the URL doesn't exist. This can happen if bumping mono very soon after the corresponding commit was pushed to mono (i.e. the archive hasn't been built yet). If so, please wait a bit and try again."; \
printf "$(COLOR_RED)*** $$MSG$(COLOR_CLEAR)\n" "$(notdir $@)"; \
if test -n "$$FAILURE_REASON_PATH"; then printf "$$MSG\n" "[$(notdir $@)]($(MONO_URL))" >> "$$FAILURE_REASON_PATH"; fi; \
fi; \
if [[ x$$EC != x0 ]]; then exit $$EC; fi; \
if [[ "x$$MACIOS_CACHE_DOWNLOADS" != "x" ]]; then \
mkdir -p ~/Library/Caches/xamarin-macios/; \
$(CP) $@.tmp ~/Library/Caches/xamarin-macios/"$(notdir $@)"; \
echo "Cached the download of $(notdir $@) in ~/Library/Caches/xamarin-macios"; \
fi; \
fi
$(Q) mv $@.tmp $@
$(Q) echo "Downloaded $(MONO_URL)"

downloads/%: downloads/%.7z
$(Q) echo "Unzipping $*..."
$(Q) rm -Rf $@.tmp
$(Q) 7z x $< -o$@.tmp
$(Q) find $@.tmp -exec touch {} +
$(Q) mv $@.tmp $@
$(Q) echo "Unzipped $*."

downloads/%: downloads/%.nupkg
$(Q) echo "Unzipping $*..."
$(Q) rm -Rf $@.tmp
$(Q) unzip -d $@.tmp $<
$(Q) find $@.tmp -exec touch {} +
$(Q) mv $@.tmp $@
$(Q) echo "Unzipped $*."
DOTNET_FILENAME=$(DOTNET_VERSION).tar.gz
DOTNET_CACHE_FILENAME=$(HOME)/Library/Caches/xamarin-macios/$(DOTNET_FILENAME)

downloads/$(DOTNET_INSTALL_NAME): dotnet-install.sh
$(Q) echo "Downloading and installing .NET $(DOTNET_VERSION) ($(DOTNET_ARCH)) into $@..."
$(Q) ./dotnet-install.sh --install-dir "$@.tmp" --version "$(DOTNET_VERSION)" --architecture $(DOTNET_ARCH) --no-path $$DOTNET_INSTALL_EXTRA_ARGS
$(Q) if test -f $(DOTNET_CACHE_FILENAME); then \
echo "Found a cached version of .NET $(DOTNET_VERSION) in $(DOTNET_CACHE_FILENAME)."; \
mkdir -p "$@.tmp"; \
tar -xzf $(DOTNET_CACHE_FILENAME) -C "$@.tmp"; \
else \
./dotnet-install.sh --install-dir "$@.tmp" --version "$(DOTNET_VERSION)" --architecture $(DOTNET_ARCH) --no-path --keep-zip --zip-path "downloads/$(DOTNET_FILENAME)" $$DOTNET_INSTALL_EXTRA_ARGS; \
cp -c downloads/$(DOTNET_FILENAME) $(DOTNET_CACHE_FILENAME); \
echo "Cached the download of $(DOTNET_FILENAME) in ~/Library/Caches/xamarin-macios"; \
fi
$(Q) rm -Rf "$@"
$(Q) mv "$@.tmp" "$@"
$(Q) echo "Downloaded and installed .NET $(DOTNET_VERSION) into $@."
Expand Down Expand Up @@ -108,10 +62,6 @@ dotnet-install.sh: Makefile
$(Q) chmod +x $@.tmp
$(Q) mv $@.tmp $@

.stamp-download-mono: $(TOP)/Make.config $(TOP)/mk/mono.mk
$(MAKE) download-mono
$(Q) touch $@

ifdef CUSTOM_DOTNET
DOWNLOAD_DOTNET_VERSION=$(CUSTOM_DOTNET_VERSION)
else
Expand Down Expand Up @@ -170,17 +120,7 @@ dotnet:: $(DOTNET_DOWNLOADS)
all-local:: $(DOTNET_DOWNLOADS)

clean-local::
$(Q) rm -Rf downloads .stamp-download-mono

all-local:: .stamp-mono-ios-sdk-destdir

.stamp-mono-ios-sdk-destdir: .stamp-$(MONO_BUILD_MODE)
ln -sf $(MONO_IOS_SDK_DESTDIR) mono-ios-sdk-destdir
$(Q) touch $@

#
# .NET
#
$(Q) rm -Rf downloads

DOTNET_COMMON_DIRECTORIES += \
$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),$(DOTNET_DESTDIR)/$($(platform)_NUGET_SDK_NAME)) \
Expand Down Expand Up @@ -214,4 +154,3 @@ $(DOTNET_COMMON_DIRECTORIES):
install-dotnet: $(DOTNET_COMMON_TARGETS)
install-local:: install-dotnet
all-local:: install-dotnet

58 changes: 0 additions & 58 deletions builds/Mono.framework-Info.plist

This file was deleted.

56 changes: 0 additions & 56 deletions builds/Mono.framework-tvos.Info.plist

This file was deleted.

56 changes: 0 additions & 56 deletions builds/Mono.framework-watchos.Info.plist

This file was deleted.

3 changes: 0 additions & 3 deletions builds/mac-System.config

This file was deleted.

Loading

0 comments on commit ae2322f

Please sign in to comment.