Skip to content

Commit

Permalink
Merge pull request #118 from Laerdal/develop
Browse files Browse the repository at this point in the history
develop
  • Loading branch information
ksidirop-laerdal authored May 22, 2024
2 parents f9e7aea + 6c6ec45 commit a7ab2a9
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 46 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -394,3 +394,7 @@ version.txt

*.Tests.xml
*.Tests.htm*

# we dont want to allow any local nuget.configs to be checked in as they can cause issues with the build and/or contain hardcoded API keys with write access to the
# nuget feed and this is something we definitely want to avoid at all costs for obvious reasons such nuget.config files should be remain local to each dev machine
[Nn][Uu][Gg][Ee][Tt].[Cc][Oo][Nn][Ff][Ii][Gg]
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<Copy SourceFiles="$(McuMgrLaerdalWrapperAarFilePath)" DestinationFiles="$(CoreAarLibrary)"/>
</Target>

<!-- android download the jar and aar dependencies from maven -->
<!-- android download the jar and aar dependencies from maven -->
<Target Name="TackleJarDependencies" BeforeTargets="PrepareForBuild" Condition=" '$(DesignTimeBuild)' != 'true' AND '$(BuildingProject)' == 'true' ">

<!-- 1. jars go here - notice the :jar postfix to pick the right versions have a look at the folder Laerdal.McuMgr.Bindings.Android.Native/lib which contains all .jar files listed below -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,9 @@
<PropertyGroup>
<LangVersion>10.0</LangVersion>

<!-- net6 supports android12 and it corresponds to android-api levels 31.0 and 32.0 -->
<!-- <TargetPlatformVersion>21.0</TargetPlatformVersion> -->
<!-- <SupportedOSPlatformVersion Condition=" '$(TargetFramework.ToLower().StartsWith(net6.0))' == 'true' ">21</SupportedOSPlatformVersion> -->

<!-- net7 supports android13 and it corresponds to android-api level 33.0 -->
<TargetPlatformVersion Condition=" '$(TargetFramework.ToLower().StartsWith(net7.0))' == 'true' ">33.0</TargetPlatformVersion>
<SupportedOSPlatformVersion Condition=" '$(TargetFramework.ToLower().StartsWith(net7.0))' == 'true' ">33</SupportedOSPlatformVersion>

<!-- net8 supports android13 and it corresponds to android-api level 34.0 -->
<!-- <TargetPlatformVersion Condition=" '$(TargetFramework.ToLower().StartsWith(net8.0))' == 'true' ">34.0</TargetPlatformVersion> -->
<!-- <SupportedOSPlatformVersion Condition=" '$(TargetFramework.ToLower().StartsWith(net8.0))' == 'true' ">34</SupportedOSPlatformVersion> -->
<TargetPlatformVersion Condition=" '$(TargetFramework.ToLower().StartsWith(net8.0))' == 'true' ">34.0</TargetPlatformVersion>
<SupportedOSPlatformVersion Condition=" '$(TargetFramework.ToLower().StartsWith(net8.0))' == 'true' ">34</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup>
Expand All @@ -25,6 +17,7 @@
<TransformFile Remove="**"/>
<AndroidLibrary Remove="**"/>
<AndroidAarLibrary Remove="**"/>
<AndroidJavaLibrary Remove="**"/>

<!-- and now we set everything properly ourselves ala net6+ salient points: -->
<!-- -->
Expand All @@ -45,14 +38,16 @@

<AndroidLibrary Include="$(CoreAarLibrary)" Bind="true" />

<AndroidLibrary Include="$(AndroidLibsFolder)/Dependencies/slf4j-api.jar" Bind="false" />
<AndroidLibrary Include="$(AndroidLibsFolder)/Dependencies/jackson-core.jar" Bind="false" />
<AndroidLibrary Include="$(AndroidLibsFolder)/Dependencies/jackson-databind.jar" Bind="false" />
<AndroidLibrary Include="$(AndroidLibsFolder)/Dependencies/jackson-annotations.jar" Bind="false" />
<AndroidLibrary Include="$(AndroidLibsFolder)/Dependencies/jackson-dataformat-cbor.jar" Bind="false" />
<AndroidLibrary Include="$(AndroidLibsFolder)/Dependencies/nordicsemi-android-ble-2.7.3.jar" Bind="false" />
<AndroidLibrary Include="$(AndroidLibsFolder)/Dependencies/nordicsemi-android-mcumgr-ble-1.9.2.jar" Bind="false" />
<AndroidLibrary Include="$(AndroidLibsFolder)/Dependencies/nordicsemi-android-mcumgr-core-1.9.2.jar" Bind="false" />
<!-- note that we use <AndroidJavaLibrary> instead of <AndroidLibrary Bind=false> because net8 for some weird reason generates -->
<!-- poisoned nugets if we use the later approach this wasnt an issue in net7 https://github.com/dotnet/maui/issues/21102 -->
<AndroidJavaLibrary Include="$(AndroidLibsFolder)/Dependencies/slf4j-api.jar" />
<AndroidJavaLibrary Include="$(AndroidLibsFolder)/Dependencies/jackson-core.jar" />
<AndroidJavaLibrary Include="$(AndroidLibsFolder)/Dependencies/jackson-databind.jar" />
<AndroidJavaLibrary Include="$(AndroidLibsFolder)/Dependencies/jackson-annotations.jar" />
<AndroidJavaLibrary Include="$(AndroidLibsFolder)/Dependencies/jackson-dataformat-cbor.jar" />
<AndroidJavaLibrary Include="$(AndroidLibsFolder)/Dependencies/nordicsemi-android-ble-2.7.3.jar" />
<AndroidJavaLibrary Include="$(AndroidLibsFolder)/Dependencies/nordicsemi-android-mcumgr-ble-1.9.2.jar" />
<AndroidJavaLibrary Include="$(AndroidLibsFolder)/Dependencies/nordicsemi-android-mcumgr-core-1.9.2.jar" />
</ItemGroup>

<Target Name="PrintBindingConfiguration" AfterTargets="CoreCompile">
Expand All @@ -65,19 +60,23 @@
<Message Importance="high" Text="**** " />
<Message Importance="high" Text="**** '%(AndroidLibrary.Identity)' " />
<Message Importance="high" Text="**** " />

<Message Importance="High" Text="**** Android Java-libraries to embed for NetX-Android (@(AndroidJavaLibrary->Count()) in total): " />
<Message Importance="high" Text="**** " />
<Message Importance="high" Text="**** '%(AndroidJavaLibrary.Identity)' " />
<Message Importance="high" Text="**** " />

<Error Text="No transform files found on disk! This looks fishy ... erroring out ..."
Condition=" @(TransformFile->Count()) == 0 "/>
<Error Condition=" @(TransformFile->Count()) == 0 " Text="No transform files found on disk! This looks fishy ... erroring out ..."/>
<Error Condition=" !Exists($(CoreAarLibrary)) " Text="The core .aar library wasn't found on path '$(CoreAarLibrary)'! This looks fishy ... erroring out ..."/>

<ItemGroup>
<MissingTransformFiles Include="@(TransformFile)" Condition=" ! Exists(%(FullPath)) " />
<MissingAndroidLibraries Include="@(AndroidLibrary)" Condition=" ! Exists(%(FullPath)) " />
<MissingTransformFiles Include="@(TransformFile)" Condition=" ! Exists(%(FullPath)) " />
<MissingAndroidLibraries Include="@(AndroidLibrary)" Condition=" ! Exists(%(FullPath)) " />
<MissingAndroidJavaLibraries Include="@(AndroidJavaLibrary)" Condition=" ! Exists(%(FullPath)) " />
</ItemGroup>

<Error Text="@(MissingTransformFiles->Count()) file(s) specified by the property 'TransformFile' were not found on disk: $(MissingTransformFiles)"
Condition=" @(MissingTransformFiles->Count()) != 0 "/>

<Error Text="@(MissingAndroidLibraries->Count()) file(s) specified by the property 'AndroidLibrary' were not found on disk: $(MissingAndroidLibraries)"
Condition=" @(MissingAndroidLibraries->Count()) != 0 "/>
<Error Condition=" @(MissingTransformFiles->Count()) != 0 " Text="@(MissingTransformFiles->Count()) file(s) specified by the property 'TransformFile' were not found on disk: $(MissingTransformFiles)" />
<Error Condition=" @(MissingAndroidLibraries->Count()) != 0 " Text="@(MissingAndroidLibraries->Count()) file(s) specified by the property 'AndroidLibrary' were not found on disk: $(MissingAndroidLibraries)"/>
<Error Condition=" @(MissingAndroidJavaLibraries->Count()) != 0 " Text="@(MissingAndroidJavaLibraries->Count()) file(s) specified by the property 'AndroidJavaLibrary' were not found on disk: $(MissingAndroidJavaLibraries)"/>
</Target>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
<IsWindows Condition=" '$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' ">true</IsWindows>
<IsUnix Condition=" '$(IsOSX)' == 'true' OR '$(IsLinux)' == 'true' ">true</IsUnix>

<!-- to future maintainers we stick with net7 for now in android because as it turned out the net8 toolchain generates broken -->
<!-- to future maintainers we stick with net8 for now in android because as it turned out the net8 toolchain generates broken -->
<!-- to future maintainers android dlls that cause missing-symbols-errors in runtime what a freakshow net8 turned out to be man -->
<!-- -->
<!-- https://github.com/dotnet/maui/issues/21102 -->
<!-- -->
<TargetFramework>net7.0-android</TargetFramework>
<TargetFramework>net8.0-android</TargetFramework>

<IsNet7 Condition=" '$(TargetFramework.ToLower().StartsWith(net7))' == 'true' ">true</IsNet7>
<IsNetX Condition=" '$(IsNet7)' == 'true' ">true</IsNetX>
<IsNet8 Condition=" '$(TargetFramework.ToLower().StartsWith(net8))' == 'true' ">true</IsNet8>
<IsNetX Condition=" '$(IsNet8)' == 'true' ">true</IsNetX>

<!-- keep this sort of parameterization around because it will be very difficult to reintroduce it if we add more target-frameworks in the future -->
<ShouldBuildNativeLibraries Condition=" '$(IsNet7)' == 'true' ">true</ShouldBuildNativeLibraries>
<ShouldBuildNativeLibraries Condition=" '$(IsNet8)' == 'true' ">true</ShouldBuildNativeLibraries>

<DebugType>pdbonly</DebugType>
<DefineConstants>$(DefineConstants);TRACE</DefineConstants>
Expand All @@ -42,7 +42,7 @@

<PropertyGroup>
<PackageId>Laerdal.McuMgr.Bindings.Android</PackageId>
<PackageTags>Laerdal;Nordic;McuMgr;Bindings;Android;Net7;</PackageTags>
<PackageTags>Laerdal;Nordic;McuMgr;Bindings;Android;Net8;</PackageTags>
<PackageProjectUrl>https://github.com/Laerdal/Laerdal.McuMgr</PackageProjectUrl>
<PackageReadmeFile Condition=" '$(IsNetX)' == 'true' ">README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
Expand All @@ -55,15 +55,15 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>

<!-- these versions are getting replaced by the build script in one swift pass -->
<Version>1.0.1039.0</Version>
<FileVersion>1.0.1039.0</FileVersion>
<PackageVersion>1.0.1039.0</PackageVersion>
<AssemblyVersion>1.0.1039.0</AssemblyVersion>
<Version>1.0.1071.0</Version>
<FileVersion>1.0.1071.0</FileVersion>
<PackageVersion>1.0.1071.0</PackageVersion>
<AssemblyVersion>1.0.1071.0</AssemblyVersion>

<Title>$(PackageId)</Title>
<Owners>$(Authors)</Owners>
<Authors>Kyriakos Sidiropoulos, François Raminosona, Laerdal</Authors>
<Summary>.Net7+ McuMgr Bindings for Android</Summary>
<Summary>.Net8+ McuMgr Bindings for Android</Summary>
<Copyright>$(Authors)</Copyright>
<Description>$(PackageDescription)</Description>

Expand Down Expand Up @@ -100,15 +100,16 @@
<Message Importance="high" Text="BuildingProject: '$(BuildingProject)' "/>
<Message Importance="high" Text="MSBuildNodeCount: '$(MSBuildNodeCount)' "/>

<Message Importance="high" Text="IsNet7: '$(IsNet7)' "/>
<Message Importance="high" Text="IsNetX: '$(IsNetX)' "/>
<Message Importance="high" Text="IsNet8: '$(IsNet8)' "/>
<Message Importance="high" Text="IsNetX: '$(IsNetX)' "/>
<Message Importance="high" Text="AndroidApplication: '$(AndroidApplication)' "/>

<Message Importance="high" Text="ShouldBuildNativeLibraries: '$(ShouldBuildNativeLibraries)' "/>
</Target>

<!-- considering the highly customized nature of the build system we need to ensure that parallelization is turned off otherwise we will end up with -->
<!-- cryptic errors in azure due to target-frameworks trying to build themselves in parallel thus stepping onto eachothers toes thats because the -->
<!-- intended way of building stuff is to let net7.0-android build the android libs and once that is done then and only then proceed to any additional -->
<!-- intended way of building stuff is to let net8.0-android build the android libs and once that is done then and only then proceed to any additional -->
<!-- target-frameworks which will find the .aar and .jars already in place -->
<Target Name="EnsureThatParallelizedBuildingIsDisabled"
BeforeTargets="PrepareForBuild">
Expand Down
6 changes: 3 additions & 3 deletions Laerdal.Scripts/Laerdal.Builder.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- to test stuff out on your localdev try these -->
<!-- -->
<!-- - to simply calculate the proper version and build use: -->
<!-- - to build with an explicit version specified in the cli: -->
<!-- -->
<!-- # on macos -->
<!-- dotnet msbuild \ -->
Expand Down Expand Up @@ -205,8 +205,8 @@
<!-- BuildInParallel=false doesnt work for dotnet we have to use the /m:1 flag on the command line -->
<MSBuild Projects="$(Laerdal_McuMgrBindings_ProjectFile_Android)" Properties="$(_Laerdal_Build_Parameters)" Targets="Clean"/>
<MSBuild Projects="$(Laerdal_McuMgrBindings_ProjectFile_Android)" Properties="$(_Laerdal_Build_Parameters)" Targets="Restore"/>
<MSBuild Projects="$(Laerdal_McuMgrBindings_ProjectFile_Android)" Properties="$(_Laerdal_Build_Parameters);BuildingProject=true;" Targets="CompileMcuMgrLaerdalWrapper"/>
<MSBuild Projects="$(Laerdal_McuMgrBindings_ProjectFile_Android)" Properties="$(_Laerdal_Build_Parameters)" Targets="Build"/>
<MSBuild Projects="$(Laerdal_McuMgrBindings_ProjectFile_Android)" Properties="$(_Laerdal_Build_Parameters);BuildingProject=true;" Targets="TackleJarDependencies"/>
<MSBuild Projects="$(Laerdal_McuMgrBindings_ProjectFile_Android)" Properties="$(_Laerdal_Build_Parameters);BuildingProject=true;" Targets="Build"/>

<MSBuild Projects="$(Laerdal_McuMgrBindings_ProjectFile_iOS)" Properties="$(_Laerdal_Build_Parameters)" Targets="Restore;Rebuild"/>
<MSBuild Projects="$(Laerdal_McuMgrBindings_ProjectFile_NetStandard)" Properties="$(_Laerdal_Build_Parameters)" Targets="Restore;Rebuild"/>
Expand Down

0 comments on commit a7ab2a9

Please sign in to comment.