@@ -93,25 +93,49 @@ public override void Run(BuildContext context)
9393
9494 foreach ( var projectItem in WellKnownProjects . NativeAssetsProjects )
9595 {
96- var unityRid = projectItem . DotNetRid switch
96+ if ( projectItem . CmakeRid == "osx" )
9797 {
98- "win-x64" => "x86_64" ,
99- "linux-x64" => "x86_64" ,
100- "osx" => "macOS" ,
101- _ => throw new NotSupportedException ( $ "RID '{ projectItem . DotNetRid } ' is not supported.")
102- } ;
98+ // natives-osx-auto\Assets\core\upm\Plugins\macOS\*.dylib
99+ var nativeAssetsPathmacOS = nativeAssetsDirectory . Path
100+ . Combine ( "natives-osx-auto" )
101+ . Combine ( "Assets" )
102+ . Combine ( "core" )
103+ . Combine ( "upm" )
104+ . Combine ( "Plugins" )
105+ . Combine ( "macOS" ) ;
106+
107+ var targetDirectorymacOS = context . ProjectsRoot . Path
108+ . Combine ( projectItem . Name )
109+ . Combine ( "lib" )
110+ . Combine ( projectItem . DotNetRid ) . Combine ( "native" ) ;
111+
112+ Directory . CreateDirectory ( targetDirectorymacOS . FullPath ) ;
113+
114+ var filesmacOS = context . GetFiles ( new GlobPattern ( $ "{ nativeAssetsPathmacOS . FullPath } /*{ projectItem . DotNetNativeName } *dylib") , new GlobberSettings ( ) { IsCaseSensitive = false } ) ;
115+ if ( filesmacOS . Count == 0 )
116+ {
117+ throw new CakeException ( $ "No native assets found in '{ nativeAssetsPathmacOS . FullPath } ' for project '{ projectItem . Name } '.") ;
118+ }
119+ if ( filesmacOS . Count > 1 )
120+ {
121+ throw new CakeException ( $ "Multiple native assets found in '{ nativeAssetsPathmacOS . FullPath } ' for project '{ projectItem . Name } '. Expected only one. Found: { filesmacOS . Count } , files: { string . Join ( ", " , filesmacOS . Select ( f => f . FullPath ) ) } ") ;
122+ }
123+ context . CopyFiles ( filesmacOS , targetDirectorymacOS . FullPath ) ;
103124
104- var suffix = projectItem . DotNetRid switch
105- {
106- "win-x64" => ".dll" ,
107- "linux-x64" => ".so" ,
108- "osx" => ".dylib" ,
109- _ => throw new NotSupportedException ( $ "RID '{ projectItem . DotNetRid } ' is not supported.")
110- } ;
125+ // Copy libnode dependencies for NodeJS
126+ if ( projectItem . DotNetNativeName == "NodeJS" )
127+ {
128+ var libnodeFilesmacOS = context . GetFiles ( new GlobPattern ( $ "{ nativeAssetsPathmacOS . FullPath } /libnode*") , new GlobberSettings ( ) { IsCaseSensitive = false } ) ;
129+ context . CopyFiles ( libnodeFilesmacOS , targetDirectorymacOS . FullPath ) ;
130+ }
131+
132+ continue ;
133+ }
111134
112135 var nativeAssetsPath = nativeAssetsDirectory . Path
113136 . Combine ( "natives-" + projectItem . CmakeRid )
114- . Combine ( unityRid ) ;
137+ . Combine ( "native" )
138+ . Combine ( projectItem . CmakeNativeName ) ;
115139
116140 if ( ! Directory . Exists ( nativeAssetsPath . FullPath ) )
117141 {
@@ -125,7 +149,7 @@ public override void Run(BuildContext context)
125149
126150 Directory . CreateDirectory ( targetDirectory . FullPath ) ;
127151
128- var files = context . GetFiles ( new GlobPattern ( $ "{ nativeAssetsPath . FullPath } /**/*{ suffix } ") ) ;
152+ var files = context . GetFiles ( new GlobPattern ( $ "{ nativeAssetsPath . FullPath } /**/*") ) ;
129153 context . CopyFiles ( files , targetDirectory . FullPath ) ;
130154 }
131155 }
@@ -286,7 +310,7 @@ public string CmakeRid
286310 {
287311 "win-x64" => "win-x64" ,
288312 "linux-x64" => "linux-x64" ,
289- "osx" => "osx-auto " ,
313+ "osx" => "osx" ,
290314 _ => throw new NotSupportedException ( $ "RID '{ DotNetRid } ' is not supported.")
291315 } ;
292316 }
0 commit comments