Skip to content

Commit

Permalink
Ship a .framework version of Mono (#53370)
Browse files Browse the repository at this point in the history
Additionally ship Mono on iOS/tvOS/MacCatalyst as a .framework bundle

Fixes #42846
  • Loading branch information
directhex authored Jul 8, 2021
1 parent ab64ce5 commit d841f5e
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 3 deletions.
2 changes: 2 additions & 0 deletions eng/liveBuilds.targets
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@
<IsNative>true</IsNative>
</RuntimeFiles>

<FrameworkReleaseFiles Condition="'$(TargetsMacCatalyst)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'" Include="$(MonoArtifactsPath)\Mono.release.framework\*.*" />
<FrameworkDebugFiles Condition="'$(TargetsMacCatalyst)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'" Include="$(MonoArtifactsPath)\Mono.debug.framework\*.*" />
<MonoIncludeFiles Condition="'$(TargetsMobile)' == 'true'"
Include="$(MonoArtifactsPath)\include\**\*.*" />
</ItemGroup>
Expand Down
8 changes: 7 additions & 1 deletion eng/pipelines/common/global-build-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ jobs:
${{ if ne(parameters.isOfficialBuild, true) }}:
value: ''

- name: _buildDarwinFrameworksParameter
${{ if in(parameters.osGroup, 'iOS', 'tvOS', 'MacCatalyst')}}:
value: /p:BuildDarwinFrameworks=true
${{ if notin(parameters.osGroup, 'iOS', 'tvOS', 'MacCatalyst')}}:
value: ''

- name: _richCodeNavigationParam
${{ if eq(parameters.enableRichCodeNavigation, true) }}:
value: /p:EnableRichCodeNavigation=true
Expand Down Expand Up @@ -134,7 +140,7 @@ jobs:
displayName: Install native dependencies

# Build
- script: $(_sclEnableCommand) $(Build.SourcesDirectory)$(dir)build$(scriptExt) -ci -arch ${{ parameters.archType }} $(_osParameter) ${{ parameters.buildArgs }} $(_officialBuildParameter) $(_crossBuildPropertyArg) $(_cxx11Parameter) $(_richCodeNavigationParam)
- script: $(_sclEnableCommand) $(Build.SourcesDirectory)$(dir)build$(scriptExt) -ci -arch ${{ parameters.archType }} $(_osParameter) ${{ parameters.buildArgs }} $(_officialBuildParameter) $(_crossBuildPropertyArg) $(_cxx11Parameter) $(_richCodeNavigationParam) $(_buildDarwinFrameworksParameter)
displayName: Build product
${{ if eq(parameters.useContinueOnErrorDuringBuild, true) }}:
continueOnError: ${{ parameters.shouldContinueOnError }}
Expand Down
12 changes: 11 additions & 1 deletion eng/pipelines/mono/templates/build-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ jobs:
value: ''
- name: msCorDbi
value: '+mono.mscordbi'
- name: darwinFrameworks
value: ''
- ${{ if and(eq(variables['System.TeamProject'], 'internal'), ne(variables['Build.Reason'], 'PullRequest')) }}:
- name: officialBuildIdArg
value: '/p:officialBuildId=$(Build.BuildNumber)'
Expand All @@ -76,15 +78,23 @@ jobs:
- ${{ if eq(parameters.osGroup, 'tvOS') }}:
- name: osOverride
value: -os tvOS
- name: darwinFrameworks
value: /p:BuildDarwinFrameworks=true
- ${{ if eq(parameters.osGroup, 'tvOSSimulator') }}:
- name: osOverride
value: -os tvOSSimulator
- name: darwinFrameworks
value: /p:BuildDarwinFrameworks=true
- ${{ if eq(parameters.osGroup, 'iOS') }}:
- name: osOverride
value: -os iOS
- name: darwinFrameworks
value: /p:BuildDarwinFrameworks=true
- ${{ if eq(parameters.osGroup, 'iOSSimulator') }}:
- name: osOverride
value: -os iOSSimulator
- name: darwinFrameworks
value: /p:BuildDarwinFrameworks=true
- ${{ if eq(parameters.osGroup, 'Android') }}:
- name: osOverride
value: -os Android
Expand Down Expand Up @@ -136,7 +146,7 @@ jobs:
# Build
- ${{ if ne(parameters.osGroup, 'windows') }}:
- script: ./build$(scriptExt) -subset mono$(msCorDbi) -c $(buildConfig) -arch $(archType) $(osOverride) -ci $(officialBuildIdArg) $(aotCrossParameter) $(llvmParameter)
- script: ./build$(scriptExt) -subset mono$(msCorDbi) -c $(buildConfig) -arch $(archType) $(osOverride) -ci $(officialBuildIdArg) $(aotCrossParameter) $(llvmParameter) $(darwinFrameworks)
displayName: Build product
- ${{ if eq(parameters.osGroup, 'windows') }}:
- script: build$(scriptExt) -subset mono$(msCorDbi) -c $(buildConfig) -arch $(archType) $(osOverride) -ci $(officialBuildIdArg) $(aotCrossParameter) $(llvmParameter)
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/runtime-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
jobParameters:
testGroup: innerloop
nameSuffix: AllSubsets_Mono
buildArgs: -s mono+libs+host+packs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true /p:RunAOTCompilation=true /p:MonoForceInterpreter=true
buildArgs: -s mono+libs+host+packs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true /p:RunAOTCompilation=true /p:MonoForceInterpreter=true /p:BuildDarwinFrameworks=true
timeoutInMinutes: 180
condition: >-
or(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@
<TargetPath>runtimes/$(RuntimeIdentifier)/native/include/%(RecursiveDir)</TargetPath>
</RuntimeFiles>

<RuntimeFiles Condition="'$(TargetsMacCatalyst)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'"
Include="@(FrameworkReleaseFiles)"
ExcludeFromDataFiles="true">
<TargetPath>runtimes/$(RuntimeIdentifier)/native/Mono.release.framework/%(RecursiveDir)</TargetPath>
</RuntimeFiles>

<RuntimeFiles Condition="'$(TargetsMacCatalyst)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'"
Include="@(FrameworkDebugFiles)"
ExcludeFromDataFiles="true">
<TargetPath>runtimes/$(RuntimeIdentifier)/native/Mono.debug.framework/%(RecursiveDir)</TargetPath>
</RuntimeFiles>

<RuntimeFiles Condition="'$(RuntimeFlavor)' == 'mono'"
Include="$(MonoArtifactsPath)\build\**\*.*"
ExcludeFromDataFiles="true">
Expand Down
38 changes: 38 additions & 0 deletions src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
<_MonoCMakeArgs Include="-DCMAKE_BUILD_TYPE=$(Configuration)"/>
<_MonoCMakeArgs Condition="'$(CMakeArgs)' != ''" Include="$(CMakeArgs)"/>
<_MonoCMakeArgs Condition="'$(MonoEnableLLVM)' == 'true'" Include="-DLLVM_PREFIX=$(MonoLLVMDir.TrimEnd('\/'))" />
<_MonoCMakeArgs Condition="'$(BuildDarwinFrameworks)' == 'true'" Include="-DBUILD_DARWIN_FRAMEWORKS=1" />
<_MonoCMakeArgs Include="-DGC_SUSPEND=$(MonoThreadSuspend)" />
<_MonoCMakeArgs Include="-DMONO_LIB_NAME=$(MonoLibName)" />
<_MonoCMakeArgs Include="-DMONO_SHARED_LIB_NAME=$(MonoSharedLibName)" />
Expand Down Expand Up @@ -508,6 +509,7 @@
<ItemGroup>
<FilesToStrip Include="$(_MonoRuntimeFilePath)" />
<FilesToStrip Include="$([System.IO.Directory]::GetParent($(_MonoRuntimeFilePath)))\libmono-component-*$(SharedLibExt)" />
<FilesToStrip Include="$([System.IO.Directory]::GetParent($(_MonoRuntimeFilePath)))\Mono*framework\**\Mono*" Exclude="$([System.IO.Directory]::GetParent($(_MonoRuntimeFilePath)))\Mono*framework\**\*.dwarf" />
</ItemGroup>
<Message Condition="'$(BuildMonoAOTCrossCompilerOnly)' != 'true' and ($([MSBuild]::IsOSPlatform('OSX')) or $([MSBuild]::IsOSPlatform('Linux')))" Text="Stripping debug symbols from %(FilesToStrip.Identity)" Importance="High"/>
<Exec Condition="!$([System.String]::Copy(%(FilesToStrip.Identity)).EndsWith('.a')) and '$(BuildMonoAOTCrossCompilerOnly)' != 'true' and ('$(TargetsOSX)' == 'true' or '$(TargetsMacCatalyst)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true')" Command="dsymutil --flat --minimize %(FilesToStrip.Identity)" IgnoreStandardErrorWarningFormat="true" WorkingDirectory="$(MonoObjDir)"/>
Expand Down Expand Up @@ -773,6 +775,42 @@
<Destination>$(RuntimeBinDir)cross\$(PackageRID)\opt$(ExeExt)</Destination>
</_MonoRuntimeArtifacts>
<_MonoIncludeArtifacts Include="$(MonoObjDir)out\include\**" />
<_MonoRuntimeArtifacts Condition="'$(MonoComponentsStatic)' != 'true' and Exists('$(MonoObjDir)out\lib\Mono.release.framework')" Include="@(_MonoRuntimeComponentsSharedFilePath)">
<Destination>$(RuntimeBinDir)\Mono.release.framework\%(_MonoRuntimeComponentsSharedFilePath.Filename)%(_MonoRuntimeComponentsSharedFilePath.Extension)</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Condition="Exists('$(MonoObjDir)out\lib\Mono.release.framework') and !Exists('$(MonoObjDir)out\lib\Mono.release.framework\Versions')" Include="$(MonoObjDir)out\lib\Mono.release.framework\Mono.release">
<Destination>$(RuntimeBinDir)\Mono.release.framework\Mono</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Condition="Exists('$(MonoObjDir)out\lib\Mono.release.framework') and Exists('$(MonoObjDir)out\lib\Mono.release.framework\Versions')" Include="$(MonoObjDir)out\lib\Mono.release.framework\Versions\Current\Mono.release">
<Destination>$(RuntimeBinDir)\Mono.release.framework\Mono</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Condition="Exists('$(MonoObjDir)out\lib\Mono.release.framework')" Include="$(MonoObjDir)out\lib\Mono.release.framework\Mono.release.dwarf">
<Destination>$(RuntimeBinDir)\Mono.release.framework\Mono.dwarf</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Condition="'$(MonoComponentsStatic)' != 'true' and Exists('$(MonoObjDir)out\lib\Mono.debug.framework')" Include="@(_MonoRuntimeComponentsSharedFilePath)">
<Destination>$(RuntimeBinDir)\Mono.debug.framework\%(_MonoRuntimeComponentsSharedFilePath.Filename)%(_MonoRuntimeComponentsSharedFilePath.Extension)</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Condition="Exists('$(MonoObjDir)out\lib\Mono.debug.framework') and !Exists('$(MonoObjDir)out\lib\Mono.debug.framework\Versions')" Include="$(MonoObjDir)out\lib\Mono.debug.framework\Mono.debug">
<Destination>$(RuntimeBinDir)\Mono.debug.framework\Mono</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Condition="Exists('$(MonoObjDir)out\lib\Mono.debug.framework') and Exists('$(MonoObjDir)out\lib\Mono.debug.framework\Versions')" Include="$(MonoObjDir)out\lib\Mono.debug.framework\Versions\Current\Mono.debug">
<Destination>$(RuntimeBinDir)\Mono.debug.framework\Mono</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Condition="Exists('$(MonoObjDir)out\lib\Mono.debug.framework')" Include="$(MonoObjDir)out\lib\Mono.debug.framework\Mono.debug.dwarf">
<Destination>$(RuntimeBinDir)\Mono.debug.framework\Mono.dwarf</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Condition="Exists('$(MonoObjDir)out\lib\Mono.release.framework') and !Exists('$(MonoObjDir)out\lib\Mono.release.framework\Versions')" Include="$(MonoObjDir)out\lib\Mono.release.framework\Info.plist">
<Destination>$(RuntimeBinDir)\Mono.release.framework\Info.plist</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Condition="Exists('$(MonoObjDir)out\lib\Mono.release.framework') and Exists('$(MonoObjDir)out\lib\Mono.release.framework\Versions')" Include="$(MonoObjDir)out\lib\Mono.release.framework\Versions\Current\Resources\Info.plist">
<Destination>$(RuntimeBinDir)\Mono.release.framework\Info.plist</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Condition="Exists('$(MonoObjDir)out\lib\Mono.debug.framework') and !Exists('$(MonoObjDir)out\lib\Mono.debug.framework\Versions')" Include="$(MonoObjDir)out\lib\Mono.debug.framework\Info.plist">
<Destination>$(RuntimeBinDir)\Mono.debug.framework\Info.plist</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Condition="Exists('$(MonoObjDir)out\lib\Mono.debug.framework') and Exists('$(MonoObjDir)out\lib\Mono.debug.framework\Versions')" Include="$(MonoObjDir)out\lib\Mono.debug.framework\Versions\Current\Resources\Info.plist">
<Destination>$(RuntimeBinDir)\Mono.debug.framework\Info.plist</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeBuildArtifacts Include="$(MonoObjDir)\build\**" />
<_MonoRuntimeArtifacts Condition="'$(_MonoIncludeInterpStaticFiles)' == 'true'" Include="$(MonoObjDir)out\lib\libmono-ee-interp.a">
<Destination>$(RuntimeBinDir)libmono-ee-interp.a</Destination>
Expand Down
41 changes: 41 additions & 0 deletions src/mono/mono/mini/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,47 @@ if(NOT DISABLE_SHARED_LIBS)
add_library(monosgen-shared-dac SHARED "mini-windows-dlldac.c")
set_target_properties(monosgen-shared-dac PROPERTIES OUTPUT_NAME ${MONO_SHARED_LIB_NAME}-dac)
endif()

if(BUILD_DARWIN_FRAMEWORKS)
if(TARGET_DARWIN)
# In cmake, you cannot have list entries which contain a space or semicolon - those are considered
# record separators (i.e. a list of list(APPEND foo "a" "b;c" "d e") is a five entry list of values
# a, b, c, d and e.
# So, in order to treat the components lists as single list entries, swap out the ; character
# for a temporary replacement character, allowing the full lists to be treated as single entries
string(REPLACE ";" "*" mono-components-objects-nowhitespace "${mono-components-objects}")
string(REPLACE ";" "*" mono-components-stub-objects-nowhitespace "${mono-components-stub-objects}")
list(APPEND FrameworkConfig Mono.debug Mono.release)
list(APPEND ComponentsObjects "${mono-components-objects-nowhitespace}" "${mono-components-stub-objects-nowhitespace}")
foreach(frameworkconfig componentsobjects IN ZIP_LISTS FrameworkConfig ComponentsObjects)
if("${componentsobjects}" STREQUAL "")
#components list is empty, use stubs instead
set(componentsobjects "${mono-components-stub-objects-nowhitespace}")
endif()
add_library(${frameworkconfig} SHARED $<TARGET_OBJECTS:monosgen-objects>)
target_compile_definitions(${frameworkconfig} PRIVATE -DMONO_DLL_EXPORT)
target_sources(${frameworkconfig} PRIVATE $<TARGET_OBJECTS:eglib_objects>)
target_link_libraries(${frameworkconfig} PRIVATE ${OS_LIBS} ${ICONV_LIB} ${LLVM_LIBS} ${ICU_LIBS})
if(ICU_LDFLAGS)
set_property(TARGET ${frameworkconfig} APPEND_STRING PROPERTY LINK_FLAGS " ${ICU_LDFLAGS}")
endif()
if(STATIC_ICU)
set_property(TARGET ${frameworkconfig} APPEND_STRING PROPERTY LINKER_LANGUAGE CXX)
endif ()
set_property(TARGET ${frameworkconfig} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-compatibility_version -Wl,2.0 -Wl,-current_version -Wl,2.0")
string(REPLACE "*" ";" componentsobjects-whitespace "${componentsobjects}")
target_sources(${frameworkconfig} PRIVATE "${componentsobjects-whitespace}")
set_target_properties(${frameworkconfig} PROPERTIES
FRAMEWORK TRUE
FRAMEWORK_VERSION C
MACOSX_FRAMEWORK_IDENTIFIER net.dot.mono-framework
)
install(TARGETS ${frameworkconfig}
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endforeach()
endif()
endif()
endif()

find_package(Python3 COMPONENTS Interpreter)
Expand Down

0 comments on commit d841f5e

Please sign in to comment.