Skip to content
Open
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 docs/content/dependencies-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ The supported framework identifiers include:
* Mono for Android: `monoandroid{version}`
* Mono for Mac: `monomac`
* MonoTouch: `monotouch`
* Native: `native` or `native({buildmode},{platform})`
* Native: `native` or `native({buildmode},{platform})` or `native{version}`
* Xamarin for Mac: `xamarinmac`
* Xamarin for iOS: `xamarinios`
* Xamarin for watchOS: `xamarinwatchos`
Expand Down
8 changes: 6 additions & 2 deletions src/Paket.Core/PaketConfigFiles/InstallModel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,10 @@ module InstallModel =
// %s because 'native' uses subfolders...
(trySscanf "lib/%A{tfm}/%s" p : (Tfm * string) option)
|> Option.map (fun (l,path) ->
if l.Name = "native" && l.Platforms = [ FrameworkIdentifier.Native(NoBuildMode,NoPlatform) ] then
if l.Name = "native" && (match l.Platforms with
| [ FrameworkIdentifier.Native(NoBuildMode,NoPlatform,_) ] -> true
| _ -> false)
then
// We need some special logic to detect the platform
let path = path.ToLowerInvariant()
let newPlatform =
Expand All @@ -486,7 +489,8 @@ module InstallModel =
if path.Contains "/release/" then Release else
if path.Contains "/debug/" then Debug else
NoBuildMode
{ Path = { l with Platforms = [ FrameworkIdentifier.Native(newBuildMode,newPlatform) ]}; File = p; Runtime = None }
let newVersion = NoVersion
{ Path = { l with Platforms = [ FrameworkIdentifier.Native(newBuildMode,newPlatform,newVersion) ]}; File = p; Runtime = None }
else
{ Path = l; File = p; Runtime = None })
|> Option.orElseWith (fun _ ->
Expand Down
73 changes: 51 additions & 22 deletions src/Paket.Core/Versioning/FrameworkHandling.fs
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,11 @@ type DotNetCoreAppVersion =
| _ when s = "3.1" -> Some DotNetCoreAppVersion.V3_1
| _ -> None

type NativeVersion =
| NoVersion
| Major of major:int
| MajorMinor of major:int * minor:int

[<RequireQualifiedAccess>]
/// The Framework version.
// Each time a new version is added NuGetPackageCache.CurrentCacheVersion should be bumped.
Expand Down Expand Up @@ -861,7 +866,7 @@ type FrameworkIdentifier =
| MonoAndroid of MonoAndroidVersion
| MonoTouch
| MonoMac
| Native of BuildMode * Platform
| Native of BuildMode * Platform * NativeVersion
| XamarinTV
| XamarinWatch
| XamariniOS
Expand Down Expand Up @@ -895,8 +900,8 @@ type FrameworkIdentifier =
| MonoAndroid v -> "monoandroid" + v.ShortString()
| MonoTouch -> "monotouch"
| MonoMac -> "monomac"
| Native(BuildMode.NoBuildMode, Platform.NoPlatform) -> "native"
| Native(mode, platform) -> sprintf "native(%s,%s)" mode.AsString platform.AsString
| Native(BuildMode.NoBuildMode, Platform.NoPlatform, _) -> "native"
| Native(mode, platform, _) -> sprintf "native(%s,%s)" mode.AsString platform.AsString
| XamarinTV -> "xamarintvos"
| XamarinWatch -> "xamarinwatchos"
| XamariniOS -> "xamarinios"
Expand Down Expand Up @@ -1237,6 +1242,30 @@ module FrameworkDetection =
|> Option.bind FrameworkVersion.TryParse
else
None
let (|MatchNative|_|) (s:string) =
if not (s.StartsWith("native")) then
None
elif s.Length = 6 then
Some NativeVersion.NoVersion
else
let versions = s.Substring 6 // expected # or #.#
let parts = versions.Split('.')

match parts with
| [| majorPart |] ->
match Int32.TryParse majorPart with
| true, major -> Some (NativeVersion.Major major)
| false, _ -> None

| [| majorPart; minorPart |] ->
match Int32.TryParse majorPart, Int32.TryParse minorPart with
| (true, major), (true, minor) ->
Some (NativeVersion.MajorMinor (major, minor))
| _ ->
None

| _ ->
None
let Bind f = (fun _ -> f)
let parseWindows tfmStart v =
match tfmStart with
Expand Down Expand Up @@ -1287,15 +1316,15 @@ module FrameworkDetection =
| MatchTfm "xamarinwatchos" (allowVersions ["";"1"]) () -> Some XamarinWatch
| MatchTfm "xamarintvos" (allowVersions ["";"1"]) () -> Some XamarinTV
| MatchTfm "xamarinmac" (allowVersions ["";"1";"2"]) () -> Some XamarinMac
| "native/x86/debug" -> Some(Native(Debug,Win32))
| "native/x64/debug" -> Some(Native(Debug,X64))
| "native/arm/debug" -> Some(Native(Debug,Arm))
| "native/x86/release" -> Some(Native(Release,Win32))
| "native/x64/release" -> Some(Native(Release,X64))
| "native/arm/release" -> Some(Native(Release,Arm))
| "native/address-model-32" -> Some(Native(NoBuildMode,Win32))
| "native/address-model-64" -> Some(Native(NoBuildMode,X64))
| "native" -> Some(Native(NoBuildMode,NoPlatform))
| "native/x86/debug" -> Some(Native(Debug,Win32,NoVersion))
| "native/x64/debug" -> Some(Native(Debug,X64,NoVersion))
| "native/arm/debug" -> Some(Native(Debug,Arm,NoVersion))
| "native/x86/release" -> Some(Native(Release,Win32,NoVersion))
| "native/x64/release" -> Some(Native(Release,X64,NoVersion))
| "native/arm/release" -> Some(Native(Release,Arm,NoVersion))
| "native/address-model-32" -> Some(Native(NoBuildMode,Win32,NoVersion))
| "native/address-model-64" -> Some(Native(NoBuildMode,X64,NoVersion))
| MatchNative nv -> Some(Native(NoBuildMode,NoPlatform,nv))
| MatchTfm "sl" SilverlightVersion.TryParse fm -> Some (Silverlight fm)
| MatchTfms ["win"; "windows"; "netcore"; "winv"] parseWindows fm -> Some (Windows fm)
| "sl4-wp7" | "sl4-wp70" | "sl4-wp7.0" -> Some (WindowsPhone WindowsPhoneVersion.V7)
Expand Down Expand Up @@ -1989,16 +2018,16 @@ module KnownTargetProfiles =
//[SinglePlatform (DNXCore FrameworkVersion.V5_0)]

let AllNativeProfiles =
[ Native(NoBuildMode,NoPlatform)
Native(NoBuildMode,Win32)
Native(NoBuildMode,X64)
Native(NoBuildMode,Arm)
Native(Debug,Win32)
Native(Debug,Arm)
Native(Debug,X64)
Native(Release,Win32)
Native(Release,X64)
Native(Release,Arm)]
[ Native(NoBuildMode,NoPlatform,NoVersion)
Native(NoBuildMode,Win32,NoVersion)
Native(NoBuildMode,X64,NoVersion)
Native(NoBuildMode,Arm,NoVersion)
Native(Debug,Win32,NoVersion)
Native(Debug,Arm,NoVersion)
Native(Debug,X64,NoVersion)
Native(Release,Win32,NoVersion)
Native(Release,X64,NoVersion)
Native(Release,Arm,NoVersion)]

let isSupportedProfile profile =
match profile with
Expand Down
13 changes: 8 additions & 5 deletions src/Paket.Core/Versioning/PlatformMatching.fs
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ let getTargetCondition (target:TargetProfile) =
| XamarinWatch -> "$(TargetFrameworkIdentifier) == 'Xamarin.watchOS'", ""
| UAP(version) -> "$(TargetFrameworkIdentifier) == '.NETCore'", sprintf "$(TargetFrameworkVersion) == '%O'" version.NetCoreVersion
| XamarinMac -> "$(TargetFrameworkIdentifier) == 'Xamarin.Mac'", ""
| Native(NoBuildMode,NoPlatform) -> "true", ""
| Native(NoBuildMode,bits) -> (sprintf "'$(Platform)'=='%s'" bits.AsString), ""
| Native(profile,bits) -> (sprintf "'$(Configuration)|$(Platform)'=='%s|%s'" profile.AsString bits.AsString), ""
| Native(NoBuildMode,NoPlatform,_) -> "true", ""
| Native(NoBuildMode,bits,_) -> (sprintf "'$(Platform)'=='%s'" bits.AsString), ""
| Native(profile,bits,_) -> (sprintf "'$(Configuration)|$(Platform)'=='%s|%s'" profile.AsString bits.AsString), ""
| Tizen version ->"$(TargetFrameworkIdentifier) == 'Tizen'", sprintf "$(TargetFrameworkVersion) == '%O'" version
| XCode version ->"$(TargetFrameworkIdentifier) == 'XCode'", sprintf "$(TargetFrameworkVersion) == '%O'" version
| Unsupported s -> "", ""
Expand Down Expand Up @@ -288,12 +288,15 @@ let getCondition (referenceCondition:string option) (targets : TargetProfile Set
|> CheckIfFullyInGroupS "WindowsPhone" (function TargetProfile.SinglePlatform (WindowsPhone _) -> true | _ -> false)

let conditions =
if targets.Count = 1 && targets |> Set.minElement = TargetProfile.SinglePlatform(Native(NoBuildMode,NoPlatform)) then
if targets.Count = 1 && (match targets |> Set.minElement with
| TargetProfile.SinglePlatform(Native(NoBuildMode,NoPlatform,_)) -> true
| _ -> false)
then
targets
else
targets
|> Set.filter (function
| TargetProfile.SinglePlatform(Native(NoBuildMode,NoPlatform)) -> false
| TargetProfile.SinglePlatform(Native(NoBuildMode,NoPlatform,_)) -> false
| _ -> true)
|> Seq.map getTargetCondition
|> Seq.filter (fun (_, v) -> v <> "false")
Expand Down
6 changes: 3 additions & 3 deletions tests/Paket.Tests/Versioning/FrameworkRestrictionTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@ let ``Simplify <|| (&& (net452) (native)) (native)>`` () =
(FrameworkRestriction.Or[
FrameworkRestriction.And[
FrameworkRestriction.Exactly (DotNetFramework FrameworkVersion.V4_5_2)
FrameworkRestriction.Exactly (Native(NoBuildMode,NoPlatform))]
FrameworkRestriction.Exactly (Native(NoBuildMode,NoPlatform))])
FrameworkRestriction.Exactly (Native(NoBuildMode,NoPlatform,NoVersion))]
FrameworkRestriction.Exactly (Native(NoBuildMode,NoPlatform,NoVersion))])
toSimplify
|> shouldEqual (FrameworkRestriction.Exactly (Native(NoBuildMode,NoPlatform)))
|> shouldEqual (FrameworkRestriction.Exactly (Native(NoBuildMode,NoPlatform,NoVersion)))

[<Test>]
let ``Simplify (>=net20) && (>=net20)``() =
Expand Down
6 changes: 3 additions & 3 deletions tests/Paket.Tests/Versioning/RestrictionFilterSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ let ``should filter >= net20 < net40 and >= net40``() =

[<Test>]
let ``should not filter native, net452``() =
let l1 = ExplicitRestriction (FrameworkRestriction.Or [FrameworkRestriction.Exactly(DotNetFramework(FrameworkVersion.V4_5_2)); FrameworkRestriction.Exactly(Native(NoBuildMode,NoPlatform))])
let l2 = ExplicitRestriction (FrameworkRestriction.Exactly(Native(NoBuildMode,NoPlatform)))
let l1 = ExplicitRestriction (FrameworkRestriction.Or [FrameworkRestriction.Exactly(DotNetFramework(FrameworkVersion.V4_5_2)); FrameworkRestriction.Exactly(Native(NoBuildMode,NoPlatform,NoVersion))])
let l2 = ExplicitRestriction (FrameworkRestriction.Exactly(Native(NoBuildMode,NoPlatform,NoVersion)))

filterRestrictions l1 l2
|> shouldEqual (ExplicitRestriction (FrameworkRestriction.Exactly(Native(NoBuildMode,NoPlatform))))
|> shouldEqual (ExplicitRestriction (FrameworkRestriction.Exactly(Native(NoBuildMode,NoPlatform,NoVersion))))