源战役
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.4 KiB

1 개월 전
  1. #encoding:utf8
  2. $cur_dir = Split-Path $MyInvocation.MyCommand.Path
  3. $dir_main = "$cur_dir/../"
  4. $dir_erl = $dir_main
  5. $dir_log = "$dir_erl/logs"
  6. $werl = "werl"
  7. $erl = "erl"
  8. $param_pa = "-pa " + $($dir_erl -replace "\\", "/") + "/ebin"
  9. function fun_make(){
  10. $src = $dir_main + "/src"
  11. $inc = $dir_main + "/include"
  12. $timefile = $cur_dir + "/timefile"
  13. #$beamfile = $dir_main + "/ebin"
  14. $lastTime = $(Get-Item $timefile).LastWriteTime
  15. #$beamTime = $(Get-Item $beamfile).LastWriteTime
  16. #$measureObject = $lastTime, $beamTime | Measure-Object -Maximum
  17. #$latestTime = $measureObject.Maximum
  18. $latestTime = $lastTime
  19. function get_hrl_str(){
  20. begin{ $list = @() }
  21. process{ $list += $_.Name }
  22. end{
  23. $str = $list -join "|"
  24. if($str -ne ""){
  25. $str = "($str)"
  26. }
  27. $str
  28. }
  29. }
  30. $chhrl_str = Get-ChildItem $inc -Include *.hrl -Recurse | Where-Object {$_.LastWriteTime -gt $latestTime} | get_hrl_str
  31. ## 使用管道获取变化的文件
  32. ## 1. 获取所有文件
  33. ## 2. 检测变化文件
  34. ## 3. 生成文件全名列表
  35. function get_erl_str(){
  36. begin{ $list = @() }
  37. process{
  38. $f = $_.FullName -replace "\\", "/"
  39. $list += "`\`"$f`\`""
  40. }
  41. end{ $list -join "," }
  42. }
  43. $erl_str = Get-ChildItem $src -Include *.erl -Exclude .svn,.git -Recurse | Where-Object {
  44. if ( $(Get-Item $_.FullName).LastWriteTime -gt $latestTime ){
  45. return $_
  46. }
  47. if($chhrl_str -eq ""){
  48. return $false
  49. }
  50. if (Select-String -Path $_.FullName -Pattern $chhrl_str -Quiet) {
  51. return $_
  52. }else{
  53. return $false
  54. }
  55. } | get_erl_str
  56. Set-Location $dir_erl
  57. ## 在windows下
  58. ## 直接mmake:files(5, [])无效
  59. ## 必须mmake:files(5, [], Opts)
  60. ## why? {{ok,[{{_, Opts}}|_]}}
  61. $cmd_str = '{0} {1} -noshell -eval "{{ok,FileInfo}}=file:consult(\"./Emakefile\"),{{_, Opts}}=lists:last(FileInfo),case mmake:files(5,[{2}], Opts) of up_to_date -> init:stop(); _ -> init:stop(1) end"'
  62. $cmd = $cmd_str -f $erl, $param_pa, $erl_str
  63. ## echo $cmd
  64. cmd /C $cmd
  65. if ($?) {
  66. Write-Output "=============> success"
  67. (Get-Date).ToString() | Out-File $timefile -Append
  68. }else{
  69. Write-Error "==============> fail"
  70. }
  71. Set-Location $cur_dir
  72. }
  73. fun_make