Makefile 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. .PHONY: test coverage
  2. build: clean lint build_python build_electron
  3. publish: clean lint publish_electron publish_python publish_web publish_cask publish_winget
  4. install:
  5. @[ -d node_modules ] || npm install
  6. clean:
  7. rm -rf ./dist
  8. rm -rf ./node_modules
  9. rm -rf ./package-lock.json
  10. reset: clean
  11. rm -rf ./third_party/env
  12. rm -rf ./third_party/source
  13. update: install
  14. @./tools/armnn sync schema
  15. @./tools/bigdl sync schema
  16. @./tools/caffe sync schema
  17. @./tools/circle sync schema metadata
  18. @./tools/cntk sync schema
  19. @./tools/coreml sync schema
  20. @./tools/dnn schema
  21. @./tools/mnn sync schema
  22. @./tools/mslite sync schema metadata
  23. @./tools/nnabla sync schema metadata
  24. @./tools/onnx sync install schema metadata
  25. @./tools/om schema
  26. @./tools/paddle sync schema
  27. @./tools/pytorch sync install schema metadata
  28. @./tools/sklearn sync install metadata
  29. @./tools/tf sync install schema metadata
  30. @./tools/uff schema
  31. @./tools/xmodel sync schema
  32. build_python: install
  33. python -m pip install --user wheel
  34. python ./publish/setup.py build --version bdist_wheel
  35. install_python: build_python
  36. pip install --force-reinstall --quiet dist/dist/*.whl
  37. build_electron: install
  38. CSC_IDENTITY_AUTO_DISCOVERY=false npx electron-builder --mac --universal --publish never
  39. npx electron-builder --win --x64 --arm64 --publish never
  40. npx electron-builder --linux appimage --x64 --publish never
  41. npx electron-builder --linux snap --x64 --publish never
  42. start: install
  43. npx electron .
  44. lint: install
  45. npx eslint source/*.js test/*.js publish/*.js tools/*.js
  46. test: install
  47. node ./test/models.js
  48. coverage:
  49. rm -rf .nyc_output ./coverage ./dist/nyc
  50. mkdir -p ./dist/nyc
  51. cp ./package.json ./dist/nyc
  52. cp -R ./source ./dist/nyc
  53. nyc instrument --compact false ./source ./dist/nyc/source
  54. nyc --reporter=lcov --instrument npx electron ./dist/nyc
  55. publish_python: build_python
  56. python -m pip install --user twine
  57. python -m twine upload --non-interactive --skip-existing --verbose dist/dist/*
  58. publish_electron: install
  59. npx electron-builder --mac --universal --publish always
  60. npx electron-builder --win --x64 --arm64 --publish always
  61. npx electron-builder --linux appimage --x64 --publish always
  62. npx electron-builder --linux snap --x64 --publish always
  63. build_web:
  64. mkdir -p ./dist/web
  65. rm -rf ./dist/web/*
  66. cp -R ./source/*.html ./dist/web
  67. cp -R ./source/*.css ./dist/web
  68. cp -R ./source/*.js ./dist/web
  69. cp -R ./source/*.json ./dist/web
  70. cp -R ./source/*.ico ./dist/web
  71. cp -R ./source/*.png ./dist/web
  72. rm -rf ./dist/web/electron.* ./dist/web/app.js
  73. sed -i "s/0\.0\.0/$$(grep '"version":' package.json -m1 | cut -d\" -f4)/g" ./dist/web/index.html
  74. publish_web: build_web
  75. rm -rf ./dist/gh-pages
  76. git clone --depth=1 https://x-access-token:$(GITHUB_TOKEN)@github.com/$(GITHUB_USER)/netron.git --branch gh-pages ./dist/gh-pages 2>&1 > /dev/null
  77. cp -R ./dist/web/* ./dist/gh-pages
  78. git -C ./dist/gh-pages add --all
  79. git -C ./dist/gh-pages commit --amend --no-edit
  80. git -C ./dist/gh-pages push --force origin gh-pages
  81. publish_cask:
  82. curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X "DELETE" https://api.github.com/repos/${GITHUB_USER}/homebrew-cask 2>&1 > /dev/null
  83. sleep 4
  84. curl -s -H "Authorization: token $(GITHUB_TOKEN)" https://api.github.com/repos/Homebrew/homebrew-cask/forks -d '' 2>&1 > /dev/null
  85. rm -rf ./dist/homebrew-cask
  86. sleep 4
  87. git clone --depth=2 https://x-access-token:$(GITHUB_TOKEN)@github.com/$(GITHUB_USER)/homebrew-cask.git ./dist/homebrew-cask
  88. node ./publish/cask.js ./dist/homebrew-cask/Casks/netron.rb
  89. git -C ./dist/homebrew-cask add --all
  90. git -C ./dist/homebrew-cask commit -m "Update $$(node -pe "require('./package.json').productName") to $$(node -pe "require('./package.json').version")"
  91. git -C ./dist/homebrew-cask push
  92. curl -H "Authorization: token $(GITHUB_TOKEN)" https://api.github.com/repos/Homebrew/homebrew-cask/pulls -d "{\"title\":\"Update $$(node -pe "require('./package.json').name") to $$(node -pe "require('./package.json').version")\",\"base\":\"master\",\"head\":\"$(GITHUB_USER):master\",\"body\":\"\"}" 2>&1 > /dev/null
  93. rm -rf ./dist/homebrew-cask
  94. publish_winget:
  95. curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X "DELETE" https://api.github.com/repos/${GITHUB_USER}/winget-pkgs 2>&1 > /dev/null
  96. sleep 4
  97. curl -s -H "Authorization: token $(GITHUB_TOKEN)" https://api.github.com/repos/microsoft/winget-pkgs/forks -d '' 2>&1 > /dev/null
  98. rm -rf ./dist/winget-pkgs
  99. sleep 4
  100. git clone --depth=2 https://x-access-token:$(GITHUB_TOKEN)@github.com/$(GITHUB_USER)/winget-pkgs.git ./dist/winget-pkgs
  101. node ./publish/winget.js ./dist/winget-pkgs/manifests
  102. git -C ./dist/winget-pkgs add --all
  103. git -C ./dist/winget-pkgs commit -m "Update $$(node -pe "require('./package.json').name") to $$(node -pe "require('./package.json').version")"
  104. git -C ./dist/winget-pkgs push
  105. curl -H "Authorization: token $(GITHUB_TOKEN)" https://api.github.com/repos/microsoft/winget-pkgs/pulls -d "{\"title\":\"Update $$(node -pe "require('./package.json').productName") to $$(node -pe "require('./package.json').version")\",\"base\":\"master\",\"head\":\"$(GITHUB_USER):master\",\"body\":\"\"}" 2>&1 > /dev/null
  106. rm -rf ./dist/winget-pkgs
  107. version:
  108. node ./publish/version.js ./package.json
  109. git add ./package.json
  110. git commit -m "Update to $$(node -pe "require('./package.json').version")"
  111. git tag v$$(node -pe "require('./package.json').version")
  112. git push
  113. git push --tags
  114. pull:
  115. git fetch --prune origin "refs/tags/*:refs/tags/*"
  116. git pull --prune --rebase