Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ship a .framework version of Mono #53370

Merged
merged 24 commits into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3d876f7
WIP
akoeplinger May 17, 2021
ada980d
Merge remote-tracking branch 'origin/main' into ios-xcframework
directhex May 27, 2021
82555d5
Copy mono-framework.framework to same build dir as monosgen
directhex May 27, 2021
4879ec7
Copy .frameworks to bin/
directhex May 27, 2021
9e3bc17
Ship .framework in nupkg
directhex May 27, 2021
ff168f9
Merge remote-tracking branch 'origin/main' into ios-xcframework
directhex Jun 3, 2021
f97e186
Rename mono-framework to Mono
directhex Jun 3, 2021
0ee1330
Merge remote-tracking branch 'origin/main' into ios-xcframework
directhex Jun 29, 2021
7d8d578
Fix framework build on non-catalyst
directhex Jun 29, 2021
e97ec4c
Build stubby (release) and static-component (release) .frameworks
directhex Jun 30, 2021
f16eabb
Merge remote-tracking branch 'origin/main' into ios-xcframework
directhex Jun 30, 2021
75ea8d1
Strip frameworks
directhex Jun 30, 2021
9bd0b0e
What if we flatten to iOS-style unversioned frameworks on non-iOS?
directhex Jul 1, 2021
4ee0938
Fix stripping-dwarf-files bug
directhex Jul 2, 2021
45f4e2b
Merge remote-tracking branch 'origin/main' into ios-xcframework
directhex Jul 2, 2021
3315ef6
Merge branch 'ios-xcframework' of github.com:directhex/runtime into i…
directhex Jul 2, 2021
8f544ab
Bundle dylibs for components on dynamic component platforms
directhex Jul 2, 2021
db386ee
Only build .frameworks if explicitly turned on; turn on in relevant C…
directhex Jul 6, 2021
aa31a96
Merge remote-tracking branch 'origin/main' into ios-xcframework
directhex Jul 6, 2021
62ab8ae
Typo
directhex Jul 6, 2021
2837fcb
Fix casing (from Mitch)
directhex Jul 7, 2021
65e00a7
Add explanation of whitespace fiddling to bypass cmake list limitations
directhex Jul 7, 2021
29e9413
Release and debug were reversed (debug should get full objects, not s…
directhex Jul 7, 2021
bd8272e
Merge remote-tracking branch 'origin/main' into ios-xcframework
directhex Jul 8, 2021
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: 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>

<CoreCLRCrossTargetFiles PackOnly="true" />
<CoreCLRCrossTargetFiles Condition="'%(FileName)' == 'clrjit' or '%(FileName)' == 'libclrjit'">
<TargetPath>runtimes/$(CoreCLRCrossTargetComponentDirName)_$(TargetArchitecture)/native</TargetPath>
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 @@ -505,6 +506,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" />
directhex marked this conversation as resolved.
Show resolved Hide resolved
</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 @@ -770,6 +772,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>
<_MonoRuntimeArtifacts Condition="'$(_MonoIncludeInterpStaticFiles)' == 'true'" Include="$(MonoObjDir)out\lib\libmono-ee-interp.a">
<Destination>$(RuntimeBinDir)libmono-ee-interp.a</Destination>
</_MonoRuntimeArtifacts>
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be TARGET_DARWIN AND STATIC_COMPONENTS.
I think this version of the code is only right if the components are static archives, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we should never build a .framework in the case of .dylib components? Didn't you say iOS Simulator should ship dylibs & build against stubs in #53370 (comment) ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I meant to me this looks like the code only supports the static components case. I assumed a dynamic components version will be added in a follow-up PR. Maybe I misunderstood what's happening here.

# 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}")
directhex marked this conversation as resolved.
Show resolved Hide resolved
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