DMusic.nimble 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. version = "0.4.1"
  2. author = "DTeam"
  3. description = "Music player"
  4. license = "GPL"
  5. srcDir = "src"
  6. bin = @["dmusic"]
  7. backend = "cpp"
  8. requires "nim >= 2.0.0"
  9. requires "fusion"
  10. requires "cligen"
  11. requires "https://github.com/levovix0/impl"
  12. requires "filetype"
  13. requires "localize == 0.3.2"
  14. requires "pixie"
  15. requires "checksums"
  16. mkdir "build"
  17. task translate, "generate translations":
  18. exec "lrelease translations/russian.ts -qm translations/russian.qm"
  19. task installFlatpak, "build and install flatpak package":
  20. exec "flatpak-builder --user --install --force-clean build-flatpak org.DTeam.DMusic.yml"
  21. task buildWindows, "cross-compile from Linux to Windows":
  22. template cmake(args, body) =
  23. if not dirExists("build"):
  24. mkdir "build"
  25. withDir "build":
  26. exec "cmake -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -DCMAKE_FIND_ROOT_PATH=/usr/x86_64-w64-mingw32 -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY " & args & " .."
  27. exec "make"
  28. body
  29. if not dirExists("build-windows"):
  30. mkdir "build-windows"
  31. withDir "build-windows":
  32. if not dirExists("taglib-1.12"):
  33. exec "wget https://taglib.org/releases/taglib-1.12.tar.gz"
  34. exec "tar -xf taglib-1.12.tar.gz"
  35. rmFile "taglib-1.12.tar.gz"
  36. withDir "taglib-1.12":
  37. cmake "":
  38. discard
  39. if not dirExists("zlib-1.3"):
  40. exec "wget https://zlib.net/zlib-1.3.tar.gz"
  41. exec "tar -xf zlib-1.3.tar.gz"
  42. rmFile "zlib-1.3.tar.gz"
  43. withDir "zlib-1.3":
  44. cmake "":
  45. cpFile "libzlibstatic.a", "libz.a"
  46. # if not dirExists("Qt5.15.9-Windows-x86_64-MinGW8.1.0"):
  47. # # exec "wget https://sourceforge.net/projects/fsu0413-qtbuilds/files/Qt5.15/Windows-x86_64/Qt5.15.9-Windows-x86_64-MinGW8.1.0-staticFull-20230602.7z/download"
  48. # exec "wget https://sourceforge.net/projects/fsu0413-qtbuilds/files/Qt5.15/Windows-x86_64/Qt5.15.9-Windows-x86_64-MinGW8.1.0-20230530.7z/download"
  49. # exec "7z x download"
  50. # rmFile "download"
  51. # if not dirExists("cqtdeployer"):
  52. # exec "wget https://github.com/QuasarApp/CQtDeployer/releases/download/v1.6.2285/CQtDeployer_1.6.2285.1507045_Linux_x86_64.zip"
  53. # mkdir "cqtdeployer"
  54. # exec "unzip CQtDeployer_1.6.2285.1507045_Linux_x86_64.zip -d cqtdeployer"
  55. # rmFile "CQtDeployer_1.6.2285.1507045_Linux_x86_64.zip"
  56. # exec "chmod +x cqtdeployer/bin/CQtDeployer"
  57. if not dirExists("dmusic-0.4"):
  58. exec "wget https://github.com/levovix0/DMusic/releases/download/0.4/DMusic-windows-updated.zip"
  59. mkdir "dmusic-0.4"
  60. exec "unzip DMusic-windows-updated.zip -d dmusic-0.4"
  61. rmFile "DMusic-windows-updated.zip"
  62. if not dirExists("nim-2.0.0"):
  63. exec "wget https://nim-lang.org/download/nim-2.0.0_x64.zip"
  64. exec "unzip nim-2.0.0_x64.zip"
  65. rmFile "nim-2.0.0_x64.zip"
  66. if not dirExists("mingw64"):
  67. exec "wget https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-win32/seh/x86_64-8.1.0-release-win32-seh-rt_v6-rev0.7z"
  68. exec "7z x x86_64-8.1.0-release-win32-seh-rt_v6-rev0.7z"
  69. rmFile "x86_64-8.1.0-release-win32-seh-rt_v6-rev0.7z"
  70. exec "nimble cpp --warnings:off -d:mingw -d:compiletimeOs:linux --os:windows --cc:gcc --gcc.exe:/usr/bin/x86_64-w64-mingw32-gcc --gcc.linkerexe:/usr/bin/x86_64-w64-mingw32-gcc --gcc.cpp.exe:/usr/bin/x86_64-w64-mingw32-g++ --gcc.cpp.linkerexe:/usr/bin/x86_64-w64-mingw32-g++ -d:taglibLib:build-windows/taglib-1.12/build/taglib -d:qtLib:build-windows/dmusic-0.4/DMusic --passl:-Lbuild-windows/zlib-1.3/build -o:build-windows/dmusic.exe -d:danger --app:gui src/dmusic.nim"
  71. # exec "nimble cpp -d:mingw --d:compiletimeOs:linux --os:windows --cc:gcc --gcc.exe:/usr/bin/x86_64-w64-mingw32-gcc --gcc.linkerexe:/usr/bin/x86_64-w64-mingw32-gcc --gcc.cpp.exe:/usr/bin/x86_64-w64-mingw32-g++ --gcc.cpp.linkerexe:/usr/bin/x86_64-w64-mingw32-g++ -o:build-windows/dmusic.exe src/dmusic.nim"
  72. withDir "build-windows":
  73. # exec "sh cqtdeployer/CQtDeployer.sh force-clear -qmlDir ../qml -bin dmusic.exe -platform win_x86_64 -qmake Qt5.15.9-Windows-x86_64-MinGW8.1.0/bin/qmake.exe"
  74. if dirExists("DMusic"):
  75. rmdir "DMusic"
  76. mkdir "DMusic"
  77. # proc splitPath(path: string): tuple[head, tail: string] =
  78. # var sepPos = -1
  79. # for i in countdown(len(path)-1, 0):
  80. # if path[i] in {'/', '\\'}:
  81. # sepPos = i
  82. # break
  83. # if sepPos >= 0:
  84. # result.head = path[0 .. sepPos-1]
  85. # result.tail = path[sepPos+1 .. ^1]
  86. # else:
  87. # result.head = ""
  88. # result.tail = path
  89. # cpFile "DistributionKit/bin/dmusic.exe", "build/dmusic.exe"
  90. # for x in "DistributionKit/lib".listFiles:
  91. # cpFile x, "build/" & x.splitPath.tail
  92. # for x in "DistributionKit/plugins".listDirs:
  93. # cpDir x, "build/" & x.splitPath.tail
  94. # for x in "DistributionKit/qml".listDirs:
  95. # cpDir x, "build/" & x.splitPath.tail
  96. cpFile "dmusic.exe", "DMusic/dmusic.exe"
  97. for d in ["audio", "mediaservice", "Qt", "styles", "bearer", "QtGraphicalEffects", "platforms", "QtQml", "iconengines", "platformthemes", "QtQuick", "imageformats", "playlistformats", "QtQuick.2"]:
  98. cpDir "dmusic-0.4/DMusic/" & d, "DMusic/" & d
  99. for f in ["Qt5Core.dll", "Qt5Gui.dll", "Qt5Multimedia.dll", "Qt5Network.dll", "Qt5Qml.dll", "Qt5QmlModels.dll", "Qt5QmlWorkerScript.dll", "Qt5QuickControls2.dll", "Qt5Quick.dll", "Qt5QuickShapes.dll", "Qt5QuickTemplates2.dll", "Qt5RemoteObjects.dll", "Qt5Svg.dll", "Qt5Widgets.dll"]:
  100. cpFile "dmusic-0.4/DMusic/" & f, "DMusic/" & f
  101. cpFile "mingw64/bin/libgcc_s_seh-1.dll", "DMusic/libgcc_s_seh-1.dll"
  102. cpFile "mingw64/bin/libstdc++-6.dll", "DMusic/libstdc++-6.dll"
  103. cpFile "mingw64/bin/libwinpthread-1.dll", "DMusic/libwinpthread-1.dll"
  104. cpFile "nim-2.0.0/bin/libcrypto-1_1-x64.dll", "DMusic/libcrypto-1_1-x64.dll"
  105. cpFile "nim-2.0.0/bin/libssl-1_1-x64.dll", "DMusic/libssl-1_1-x64.dll"
  106. cpFile "nim-2.0.0/bin/pcre64.dll", "DMusic/pcre64.dll"
  107. cpFile "nim-2.0.0/bin/cacert.pem", "DMusic/cacert.pem"
  108. exec "zip -r DMusic.zip DMusic"