[mtouch] Fix cache invalidation with app extensions.

Change cache invalidation so that if any app extension's cache is invalid,
then invalidate the cache for the container app and all other app extensions.

This is the safest option when we're sharing code.
This commit is contained in:
Rolf Bjarne Kvinge 2017-01-31 10:23:08 +01:00
Родитель 95dfdd3a00
Коммит b547454e98
2 изменённых файлов: 30 добавлений и 7 удалений

Просмотреть файл

@ -197,7 +197,7 @@ public class Cache {
return sb.ToString ();
}
bool IsCacheValid ()
public bool IsCacheValid ()
{
var name = "arguments";
var pcache = Path.Combine (Location, name);

Просмотреть файл

@ -703,6 +703,7 @@ namespace Xamarin.Bundler {
allapps.Add (this); // We need to build the main app first, so that any extensions sharing code can reference frameworks built in the main app.
allapps.AddRange (AppExtensions);
VerifyCache ();
allapps.ForEach ((v) => v.BuildInitialize ());
DetectCodeSharing ();
allapps.ForEach ((v) => v.BuildManaged ());
@ -711,17 +712,39 @@ namespace Xamarin.Bundler {
allapps.ForEach ((v) => v.BuildEnd ());
}
void BuildInitialize ()
void VerifyCache ()
{
var valid = true;
// First make sure that all the caches (both for the container app and any app extensions) are valid.
// Due to code sharing it's safest to rebuild everything if any cache ends up out-of-date.
if (Driver.Force) {
Driver.Log (3, "A full rebuild has been forced by the command line argument -f.");
Cache.Clean ();
Driver.Log (3, $"A full rebuild has been forced by the command line argument -f.");
valid = false;
} else if (!Cache.IsCacheValid ()) {
Driver.Log (3, $"A full rebuild has been forced because the cache for {Name} is not valid.");
valid = false;
} else {
// this will destroy the cache if invalid, which makes setting Driver.Force to true mostly unneeded
// in fact setting it means some actions (like extract native resource) gets duplicate for fat builds
Cache.VerifyCache ();
foreach (var appex in AppExtensions) {
if (appex.Cache.IsCacheValid ())
continue;
Driver.Log (3, $"A full rebuild has been forced because the cache for {appex.Name} is not valid.");
valid = false;
break;
}
}
if (valid)
return;
// Something's not valid anymore, so clean everything.
Cache.Clean ();
AppExtensions.ForEach ((v) => v.Cache.Clean ());
}
void BuildInitialize ()
{
Initialize ();
ValidateAbi ();
SelectRegistrar ();