Makefile 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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/dlc schema
  21. @./tools/dnn schema
  22. @./tools/mnn sync schema
  23. @./tools/mslite sync schema metadata
  24. @./tools/megengine sync schema metadata
  25. @./tools/nnabla sync schema metadata
  26. @./tools/onnx sync install schema metadata
  27. @./tools/om schema
  28. @./tools/paddle sync schema
  29. @./tools/pytorch sync schema metadata
  30. @./tools/rknn schema
  31. @./tools/sklearn sync install metadata
  32. @./tools/tf sync install schema metadata
  33. @./tools/uff schema
  34. @./tools/xmodel sync schema
  35. build_python: install
  36. python publish/python.py build version
  37. python -m pip install --user build wheel --quiet
  38. python -m build --no-isolation --wheel --outdir ./dist/pypi dist/pypi
  39. install_python: build_python
  40. pip install --force-reinstall dist/pypi/*.whl
  41. build_electron: install
  42. npx electron-builder install-app-deps
  43. npx electron-builder --mac --universal --publish never -c.mac.identity=null
  44. npx electron-builder --win --x64 --arm64 --publish never
  45. npx electron-builder --linux appimage --x64 --publish never
  46. npx electron-builder --linux snap --x64 --publish never
  47. start: install
  48. npx electron .
  49. lint: install
  50. npx eslint source/*.js test/*.js publish/*.js tools/*.js
  51. python -m pip install --upgrade --quiet pylint
  52. python -m pylint -sn source/*.py publish/*.py test/*.py tools/*.py
  53. codeql:
  54. @[ -d third_party/tools/codeql ] || git clone --depth=1 https://github.com/github/codeql.git ./third_party/tools/codeql
  55. rm -rf dist/codeql
  56. mkdir -p dist/codeql/netron
  57. cp -r publish source test tools dist/codeql/netron/
  58. codeql database create dist/codeql/database --source-root dist/codeql/netron --language=javascript --threads=3
  59. codeql database analyze dist/codeql/database ./third_party/tools/codeql/javascript/ql/src/codeql-suites/javascript-security-and-quality.qls --format=csv --output=dist/codeql/results.csv --threads=3
  60. cat dist/codeql/results.csv
  61. test: install
  62. node ./test/models.js
  63. coverage:
  64. rm -rf .nyc_output ./coverage ./dist/nyc
  65. mkdir -p ./dist/nyc
  66. cp ./package.json ./dist/nyc
  67. cp -R ./source ./dist/nyc
  68. nyc instrument --compact false ./source ./dist/nyc/source
  69. nyc --reporter=lcov --instrument npx electron ./dist/nyc
  70. publish_python: build_python
  71. python -m pip install --user twine
  72. python -m twine upload --non-interactive --skip-existing --verbose dist/pypi/*.whl
  73. publish_electron: install
  74. npx electron-builder install-app-deps
  75. npx electron-builder --mac --universal --publish always
  76. npx electron-builder --win --x64 --arm64 --publish always
  77. npx electron-builder --linux appimage --x64 --publish always
  78. npx electron-builder --linux snap --x64 --publish always
  79. build_web:
  80. mkdir -p ./dist/web
  81. rm -rf ./dist/web/*
  82. cp -R ./source/*.html ./dist/web
  83. cp -R ./source/*.css ./dist/web
  84. cp -R ./source/*.js ./dist/web
  85. cp -R ./source/*.json ./dist/web
  86. cp -R ./source/*.ico ./dist/web
  87. cp -R ./source/*.png ./dist/web
  88. rm -rf ./dist/web/electron.* ./dist/web/app.js
  89. node ./publish/web.js ./package.json ./dist/web/index.html
  90. publish_web: build_web
  91. rm -rf ./dist/gh-pages
  92. 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
  93. cp -R ./dist/web/* ./dist/gh-pages
  94. git -C ./dist/gh-pages add --all
  95. git -C ./dist/gh-pages commit --amend --no-edit
  96. git -C ./dist/gh-pages push --force origin gh-pages
  97. publish_cask:
  98. curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X "DELETE" https://api.github.com/repos/${GITHUB_USER}/homebrew-cask 2>&1 > /dev/null
  99. sleep 4
  100. curl -s -H "Authorization: token $(GITHUB_TOKEN)" https://api.github.com/repos/Homebrew/homebrew-cask/forks -d '' 2>&1 > /dev/null
  101. rm -rf ./dist/homebrew-cask
  102. sleep 4
  103. git clone --depth=2 https://x-access-token:$(GITHUB_TOKEN)@github.com/$(GITHUB_USER)/homebrew-cask.git ./dist/homebrew-cask
  104. node ./publish/cask.js ./dist/homebrew-cask/Casks/netron.rb
  105. git -C ./dist/homebrew-cask add --all
  106. git -C ./dist/homebrew-cask commit -m "Update $$(node -pe "require('./package.json').productName") to $$(node -pe "require('./package.json').version")"
  107. git -C ./dist/homebrew-cask push
  108. 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\":\"Update version and sha256.\"}" 2>&1 > /dev/null
  109. rm -rf ./dist/homebrew-cask
  110. publish_winget:
  111. curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X "DELETE" https://api.github.com/repos/${GITHUB_USER}/winget-pkgs 2>&1 > /dev/null
  112. sleep 4
  113. curl -s -H "Authorization: token $(GITHUB_TOKEN)" https://api.github.com/repos/microsoft/winget-pkgs/forks -d '' 2>&1 > /dev/null
  114. rm -rf ./dist/winget-pkgs
  115. sleep 4
  116. git clone --depth=2 https://x-access-token:$(GITHUB_TOKEN)@github.com/$(GITHUB_USER)/winget-pkgs.git ./dist/winget-pkgs
  117. node ./publish/winget.js ./dist/winget-pkgs/manifests
  118. git -C ./dist/winget-pkgs add --all
  119. git -C ./dist/winget-pkgs commit -m "Update $$(node -pe "require('./package.json').name") to $$(node -pe "require('./package.json').version")"
  120. git -C ./dist/winget-pkgs push
  121. 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
  122. rm -rf ./dist/winget-pkgs
  123. version:
  124. node ./publish/version.js ./package.json
  125. git add ./package.json
  126. git commit -m "Update to $$(node -pe "require('./package.json').version")"
  127. git tag v$$(node -pe "require('./package.json').version")
  128. git push
  129. git push --tags
  130. pull:
  131. git fetch --prune origin "refs/tags/*:refs/tags/*"
  132. git pull --prune --rebase