@@ -91,123 +91,6 @@ fn check_global_json_policy() -> Result<()> {
9191 Ok ( ( ) )
9292}
9393
94- fn overlay_unity_meta_skeleton ( pkg_id : & str ) -> Result < ( ) > {
95- let skeleton_base = Path :: new ( "sdks/csharp/unity-meta-skeleton~" ) ;
96- let skeleton_root = skeleton_base. join ( pkg_id) ;
97- if !skeleton_root. exists ( ) {
98- return Ok ( ( ) ) ;
99- }
100-
101- let pkg_root = Path :: new ( "sdks/csharp/packages" ) . join ( pkg_id) ;
102- if !pkg_root. exists ( ) {
103- return Ok ( ( ) ) ;
104- }
105-
106- // Copy spacetimedb.<pkg>.meta
107- let pkg_root_meta = skeleton_base. join ( format ! ( "{pkg_id}.meta" ) ) ;
108- if pkg_root_meta. exists ( )
109- && let Some ( parent) = pkg_root. parent ( )
110- {
111- let pkg_meta_dst = parent. join ( format ! ( "{pkg_id}.meta" ) ) ;
112- fs:: copy ( & pkg_root_meta, & pkg_meta_dst) ?;
113- }
114-
115- let versioned_dir = match find_only_subdir ( & pkg_root) {
116- Ok ( dir) => dir,
117- Err ( err) => {
118- log:: info!( "Skipping Unity meta overlay for {pkg_id}: could not locate restored version dir: {err}" ) ;
119- return Ok ( ( ) ) ;
120- }
121- } ;
122-
123- // If version.meta exists under the skeleton package, rename it to match the restored version dir.
124- let version_meta_template = skeleton_root. join ( "version.meta" ) ;
125- if version_meta_template. exists ( )
126- && let Some ( parent) = versioned_dir. parent ( )
127- {
128- let version_name = versioned_dir
129- . file_name ( )
130- . expect ( "versioned directory should have a file name" ) ;
131- let version_meta_dst = parent. join ( format ! ( "{}.meta" , version_name. to_string_lossy( ) ) ) ;
132- fs:: copy ( & version_meta_template, & version_meta_dst) ?;
133- }
134-
135- copy_overlay_dir ( & skeleton_root, & versioned_dir)
136- }
137-
138- fn clear_restored_package_dirs ( pkg_id : & str ) -> Result < ( ) > {
139- let pkg_root = Path :: new ( "sdks/csharp/packages" ) . join ( pkg_id) ;
140- if !pkg_root. exists ( ) {
141- return Ok ( ( ) ) ;
142- }
143-
144- fs:: remove_dir_all ( & pkg_root) ?;
145-
146- Ok ( ( ) )
147- }
148-
149- fn find_only_subdir ( dir : & Path ) -> Result < PathBuf > {
150- let mut subdirs: Vec < PathBuf > = vec ! [ ] ;
151-
152- for entry in fs:: read_dir ( dir) ? {
153- let entry = entry?;
154- if entry. file_type ( ) ?. is_dir ( ) {
155- subdirs. push ( entry. path ( ) ) ;
156- }
157- }
158-
159- match subdirs. as_slice ( ) {
160- [ ] => Err ( anyhow:: anyhow!(
161- "Could not find a restored versioned directory under {}" ,
162- dir. display( )
163- ) ) ,
164- [ only] => Ok ( only. clone ( ) ) ,
165- _ => Err ( anyhow:: anyhow!(
166- "Expected exactly one restored versioned directory under {}, found {}" ,
167- dir. display( ) ,
168- subdirs. len( )
169- ) ) ,
170- }
171- }
172-
173- fn copy_overlay_dir ( src : & Path , dst : & Path ) -> Result < ( ) > {
174- if !src. exists ( ) {
175- bail ! ( "Skeleton directory does not exist: {}" , src. display( ) ) ;
176- }
177- if !dst. exists ( ) {
178- bail ! ( "Destination directory does not exist: {}" , dst. display( ) ) ;
179- }
180-
181- for entry in fs:: read_dir ( src) ? {
182- let entry = entry?;
183- let src_path = entry. path ( ) ;
184- let dst_path = dst. join ( entry. file_name ( ) ) ;
185- if entry. file_type ( ) ?. is_dir ( ) {
186- if dst_path. exists ( ) {
187- copy_overlay_dir ( & src_path, & dst_path) ?;
188- }
189- } else {
190- if src_path. extension ( ) == Some ( OsStr :: new ( "meta" ) ) {
191- let asset_path = dst_path
192- . parent ( )
193- . expect ( "dst_path should have a parent" )
194- . join ( dst_path. file_stem ( ) . expect ( ".meta file should have a file stem" ) ) ;
195-
196- if asset_path. exists ( ) {
197- fs:: copy ( & src_path, & dst_path) ?;
198- } else if dst_path. exists ( ) {
199- fs:: remove_file ( & dst_path) ?;
200- }
201- continue ;
202- }
203-
204- fs:: copy ( & src_path, & dst_path) ?;
205- }
206- }
207-
208- Ok ( ( ) )
209- }
210-
21194#[ derive( Subcommand ) ]
21295enum CiCmd {
21396 /// Runs tests
@@ -225,11 +108,9 @@ enum CiCmd {
225108 ///
226109 /// Runs tests for the codegen crate and builds a test module with the wasm bindings.
227110 WasmBindings ,
228- /// Builds and packs C# DLLs and NuGet packages for local Unity workflows
111+ /// Deprecated; use `cargo regen csharp dlls`.
229112 ///
230- /// Packs the in-repo C# NuGet packages and restores the C# SDK to populate `sdks/csharp/packages/**`.
231- /// Then overlays Unity `.meta` skeleton files from `sdks/csharp/unity-meta-skeleton~/**` onto the restored
232- /// versioned package directory, so Unity can associate stable meta files with the most recently built package.
113+ /// Builds and packs C# DLLs and NuGet packages for local Unity workflows.
233114 Dlls ,
234115 /// Runs smoketests
235116 ///
@@ -308,84 +189,6 @@ fn tracked_rs_files_under(path: &str) -> Result<Vec<PathBuf>> {
308189 . collect ( ) )
309190}
310191
311- fn run_dlls ( ) -> Result < ( ) > {
312- ensure_repo_root ( ) ?;
313-
314- cmd ! (
315- "dotnet" ,
316- "pack" ,
317- "crates/bindings-csharp/BSATN.Runtime" ,
318- "-c" ,
319- "Release"
320- )
321- . run ( ) ?;
322- cmd ! ( "dotnet" , "pack" , "crates/bindings-csharp/Runtime" , "-c" , "Release" ) . run ( ) ?;
323-
324- let repo_root = env:: current_dir ( ) ?;
325- let bsatn_source = repo_root. join ( "crates/bindings-csharp/BSATN.Runtime/bin/Release" ) ;
326- let runtime_source = repo_root. join ( "crates/bindings-csharp/Runtime/bin/Release" ) ;
327-
328- let nuget_config_dir = tempfile:: tempdir ( ) ?;
329- let nuget_config_path = nuget_config_dir. path ( ) . join ( "nuget.config" ) ;
330- let nuget_config_contents = format ! (
331- r#"<?xml version="1.0" encoding="utf-8"?>
332- <configuration>
333- <packageSources>
334- <clear />
335- <add key="Local SpacetimeDB.BSATN.Runtime" value="{}" />
336- <add key="Local SpacetimeDB.Runtime" value="{}" />
337- <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
338- </packageSources>
339- <packageSourceMapping>
340- <packageSource key="Local SpacetimeDB.BSATN.Runtime">
341- <package pattern="SpacetimeDB.BSATN.Runtime" />
342- </packageSource>
343- <packageSource key="Local SpacetimeDB.Runtime">
344- <package pattern="SpacetimeDB.Runtime" />
345- </packageSource>
346- <packageSource key="nuget.org">
347- <package pattern="*" />
348- </packageSource>
349- </packageSourceMapping>
350- </configuration>
351- "# ,
352- bsatn_source. display( ) ,
353- runtime_source. display( ) ,
354- ) ;
355- fs:: write ( & nuget_config_path, nuget_config_contents) ?;
356-
357- let nuget_config_path_str = nuget_config_path. to_string_lossy ( ) . to_string ( ) ;
358-
359- clear_restored_package_dirs ( "spacetimedb.bsatn.runtime" ) ?;
360- clear_restored_package_dirs ( "spacetimedb.runtime" ) ?;
361-
362- cmd ! (
363- "dotnet" ,
364- "restore" ,
365- "SpacetimeDB.ClientSDK.csproj" ,
366- "--configfile" ,
367- & nuget_config_path_str,
368- )
369- . dir ( "sdks/csharp" )
370- . run ( ) ?;
371-
372- overlay_unity_meta_skeleton ( "spacetimedb.bsatn.runtime" ) ?;
373- overlay_unity_meta_skeleton ( "spacetimedb.runtime" ) ?;
374-
375- cmd ! (
376- "dotnet" ,
377- "pack" ,
378- "SpacetimeDB.ClientSDK.csproj" ,
379- "-c" ,
380- "Release" ,
381- "--no-restore"
382- )
383- . dir ( "sdks/csharp" )
384- . run ( ) ?;
385-
386- Ok ( ( ) )
387- }
388-
389192fn run_publish_checks ( ) -> Result < ( ) > {
390193 cmd ! ( "bash" , "-lc" , "test -d venv || python3 -m venv venv" ) . run ( ) ?;
391194 cmd ! ( "venv/bin/pip3" , "install" , "argparse" , "toml" ) . run ( ) ?;
@@ -623,7 +426,8 @@ fn main() -> Result<()> {
623426 }
624427
625428 Some ( CiCmd :: Dlls ) => {
626- run_dlls ( ) ?;
429+ eprintln ! ( "warning: `cargo ci dlls` is deprecated; use `cargo regen csharp dlls` instead" ) ;
430+ cmd ! ( "cargo" , "regen" , "csharp" , "dlls" ) . run ( ) ?;
627431 }
628432
629433 Some ( CiCmd :: Smoketests ( args) ) => {
0 commit comments