Makefile 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. SHELL := /bin/bash
  2. .PHONY: help ios update tvos
  3. RUBY := $(shell command -v ruby 2>/dev/null)
  4. HOMEBREW := $(shell command -v brew 2>/dev/null)
  5. BUNDLER := $(shell command -v bundle 2>/dev/null)
  6. default: help
  7. # Add the following 'help' target to your Makefile
  8. # And add help text after each target name starting with '\#\#'
  9. # A category can be added with @category
  10. # COLORS
  11. GREEN := $(shell tput -Txterm setaf 2)
  12. YELLOW := $(shell tput -Txterm setaf 3)
  13. WHITE := $(shell tput -Txterm setaf 7)
  14. RESET := $(shell tput -Txterm sgr0)
  15. ## ----- Helper functions ------
  16. # Helper target for declaring an external executable as a recipe dependency.
  17. # For example,
  18. # `my_target: | _program_awk`
  19. # will fail before running the target named `my_target` if the command `awk` is
  20. # not found on the system path.
  21. _program_%: FORCE
  22. @_=$(or $(shell which $* 2> /dev/null),$(error `$*` command not found. Please install `$*` and try again))
  23. # Helper target for declaring required environment variables.
  24. #
  25. # For example,
  26. # `my_target`: | _var_PARAMETER`
  27. #
  28. # will fail before running `my_target` if the variable `PARAMETER` is not declared.
  29. _var_%: FORCE
  30. @_=$(or $($*),$(error `$*` is a required parameter))
  31. _tag: | _var_VERSION
  32. make --no-print-directory -B README.md
  33. git commit -am "Tagging release $(VERSION)"
  34. git tag -a $(VERSION) $(if $(NOTES),-m '$(NOTES)',-m $(VERSION))
  35. .PHONY: _tag
  36. _push: | _var_VERSION
  37. git push origin $(VERSION)
  38. git push origin master
  39. .PHONY: _push
  40. ## ------ Commmands -----------
  41. TARGET_MAX_CHAR_NUM=20
  42. ## Show help
  43. help:
  44. @echo ''
  45. @echo 'Usage:'
  46. @echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
  47. @echo ''
  48. @echo 'Targets:'
  49. @awk '/^[a-zA-Z\-\_0-9]+:/ { \
  50. helpMessage = match(lastLine, /^## (.*)/); \
  51. if (helpMessage) { \
  52. helpCommand = substr($$1, 0, index($$1, ":")-1); \
  53. helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
  54. printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
  55. } \
  56. } \
  57. { lastLine = $$0 }' \
  58. $(MAKEFILE_LIST)
  59. ## Install dependencies.
  60. setup: \
  61. pre_setup
  62. # check_for_homebrew \
  63. # update_homebrew \
  64. pull_request: \
  65. test \
  66. codecov_upload \
  67. danger
  68. pre_setup:
  69. $(info Project setup…)
  70. check_for_ruby:
  71. $(info Checking for Ruby…)
  72. ifeq ($(RUBY),)
  73. $(error Ruby is not installed.)
  74. endif
  75. check_for_homebrew:
  76. $(info Checking for Homebrew…)
  77. ifeq ($(HOMEBREW),)
  78. $(error Homebrew is not installed)
  79. endif
  80. update_homebrew:
  81. $(info Updating Homebrew…)
  82. brew update
  83. install_swift_lint:
  84. $(info Install swiftlint…)
  85. brew unlink swiftlint || true
  86. brew install swiftlint
  87. brew link --overwrite swiftlint
  88. install_bundler_gem:
  89. $(info Checking and installing bundler…)
  90. ifeq ($(BUNDLER),)
  91. gem install bundler -v '~> 1.17'
  92. else
  93. gem update bundler '~> 1.17'
  94. endif
  95. install_ruby_gems:
  96. $(info Installing Ruby gems…)
  97. bundle install
  98. pull:
  99. $(info Pulling new commits…)
  100. git stash push || true
  101. git pull
  102. git stash pop || true
  103. ## -- Source Code Tasks --
  104. ## Pull upstream and update 3rd party frameworks
  105. update: submodules
  106. submodules:
  107. $(info Updating submodules…)
  108. git submodule update --init --recursive --remote
  109. ## -- QA Task Runners --
  110. codecov_upload:
  111. curl -s https://codecov.io/bash | bash
  112. danger:
  113. bundle exec danger
  114. ## -- Testing --
  115. ## Run test on all targets
  116. test:
  117. bundle exec fastlane test
  118. ## -- Building --
  119. build:
  120. @xcodebuild -workspace Pomelo.xcodeproj/project.xcworkspace \
  121. -scheme Pomelo \
  122. -sdk iphoneos \
  123. -destination generic/platform=iOS
  124. archive -archivePath ./archive \
  125. CODE_SIGNING_REQUIRED=NO \
  126. AD_HOC_CODE_SIGNING_ALLOWED=YES \
  127. CODE_SIGNING_ALLOWED=NO \
  128. DWARF_DSYM_FOLDER_PATH="."
  129. ipa:
  130. mkdir Payload
  131. mkdir Payload/Pomelo.app
  132. cp -R archive.xcarchive/Products/Applications/Pomelo.app/ Payload/Pomelo.app/
  133. zip -r Pomelo.ipa Payload