CodeLinker.ps1 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. $packages = ("Packages", "Library\PackageCache")
  2. $dirs = ("Model~", "Hotfix~", "ModelView~", "HotfixView~")
  3. $client_server_dir = ("Client", "Server", "Share")
  4. function Link($targetPath, $linker, $subPath, $moudle)
  5. {
  6. $path = $linker + $subPath
  7. foreach($c in Get-ChildItem $path)
  8. {
  9. if ($c -is [System.IO.FileInfo])
  10. {
  11. $to = $targetPath + "/" + $moudle + $subPath + $c.Name
  12. Write-Host "link:", $to, $c.FullName
  13. New-Item -ItemType HardLink -Path $to -Value $c.FullName -Force
  14. continue
  15. }
  16. elseif ($c -is [System.IO.DirectoryInfo])
  17. {
  18. $newSubPath = $subPath + $c.Name + "/"
  19. Link $targetPath $linker $newSubPath $moudle
  20. }
  21. }
  22. }
  23. foreach($package in $packages)
  24. {
  25. foreach($a in Get-ChildItem $package)
  26. {
  27. # name = core
  28. $name = $a.Name
  29. if (!$name.StartsWith("com.et."))
  30. {
  31. continue
  32. }
  33. $name = $name.Substring(7, $name.Length - 7);
  34. $newDir = $a.FullName + "/Scripts"
  35. # $b model~ dir
  36. foreach($b in Get-ChildItem $newDir)
  37. {
  38. $name2 = $b.Name
  39. if (!$dirs.Contains($name2))
  40. {
  41. continue
  42. }
  43. $path = $b.FullName
  44. # name3 Hotfix name2 Hotfix~
  45. $name3 = $name2.Substring(0, $name2.Length - 1)
  46. foreach($c in Get-ChildItem $path)
  47. {
  48. $name4 = $c.Name
  49. if (!$client_server_dir.Contains($name4))
  50. {
  51. continue
  52. }
  53. # Assets/Scripts/Hotfix/Client/
  54. $targetPath = "Assets/Scripts/$name3/$name4"
  55. Link $targetPath $c.FullName "/" $name
  56. }
  57. }
  58. }
  59. }