Makefile 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. #
  2. # Licensed to Cloudera, Inc. under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. Cloudera, Inc. licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. #
  18. # <<<< DEV ONLY
  19. #
  20. # Hue Build Process Overview
  21. # =======================================
  22. # This build process handles different types of builds:
  23. #
  24. # - The production release build, the main task of which is to install
  25. # Desktop in the local system. The main build products are:
  26. #
  27. # * build/env - The virtual environment, where Desktop core
  28. # and various apps install into.
  29. #
  30. # - The development build, which includes test and debugging tools. It
  31. # generates the production release, which boils down to a tarball that is
  32. # downloaded and installed. Additional build products include:
  33. #
  34. # * build/release/prod - The production tarball.
  35. # * build/docs - General Desktop and SDK docs.
  36. #
  37. # We achieve this by selecting the parts to be distributed, and by stripping
  38. # the Makefile's. Lines enclosed by the "DEV ONLY" marks are stripped for the
  39. # general release. Targets are split/expanded using multiple rules and
  40. # double-colon rules. The idea is to use almost identical build logic for the
  41. # different flavours.
  42. #
  43. # Logic Flow
  44. # ==========
  45. # Here we summarize the flow of the build logic. Lines represent dependency.
  46. #
  47. # virtual-bootstrap.py
  48. # | ext/thirdparty/js (crepo sync)
  49. # virtual-env (./env) |
  50. # | |
  51. # '--------+----------+---------------'
  52. # | |
  53. # | V
  54. # | desktop <--- recursive make in /desktop
  55. # | |
  56. # | V
  57. # | apps <--- recursive make in /apps
  58. # |
  59. # V
  60. # prod tarball <-- selective copying into /build/release/...
  61. #
  62. #
  63. # Application Build
  64. # =================
  65. # An app typically includes $(ROOT)/Makefile.sdk, which provides the standard
  66. # targets and facilities. ROOT, which points to the Hue installation root, is
  67. # always passed in.
  68. #
  69. # The application may also choose to not use the Hue build facilities. In that
  70. # case, its Makefile still receives $(ROOT), and needs to provide several
  71. # targets as specified in Makefile.sdk.
  72. #
  73. # END DEV ONLY >>>>
  74. ###################################
  75. # Global variables
  76. ###################################
  77. ROOT := $(realpath .)
  78. include $(ROOT)/Makefile.vars.priv
  79. ###################################
  80. # Error checking
  81. ###################################
  82. # <<<< DEV ONLY
  83. CREPO ?= $(shell which crepo 2> /dev/null)
  84. ifeq ($(CREPO),)
  85. $(error "Error: Need crepo. See <http://github.com/cloudera/crepo>.")
  86. endif
  87. ifneq ($(shell test -e $(HADOOP_HOME)/bin/hadoop && echo $$?),0)
  88. $(error "Error: No Hadoop installation at $(HADOOP_HOME). Please set $$HADOOP_HOME.")
  89. endif
  90. # END DEV ONLY >>>>
  91. .PHONY: default
  92. default:
  93. @echo 'The build targets for Hue $(DESKTOP_VERSION) are:'
  94. @echo ' install : Install at $$PREFIX ($(INSTALL_DIR)); need desktop'
  95. @echo ' apps : Build and register all desktop apps; need desktop'
  96. @echo ' desktop : Build desktop core only'
  97. @echo ' clean : Remove desktop build products'
  98. @echo ' distclean : Remove desktop and thirdparty build products'
  99. # <<<< DEV ONLY
  100. @echo ' docs : Build documentation'
  101. @echo ' crepo : Update crepo'
  102. @echo ' prod : Generate a tar file for production distribution'
  103. # END DEV ONLY >>>>
  104. .PHONY: all
  105. all: default
  106. # <<<< DEV ONLY
  107. include Makefile.tarball
  108. ###################################
  109. # Build docs
  110. ###################################
  111. .PHONY: docs
  112. docs:
  113. @$(MAKE) -C docs
  114. ###################################
  115. # Crepo
  116. ###################################
  117. # Development use crepo to fetch thirdparty dependencies.
  118. .PHONY: crepo
  119. crepo: $(THIRDPARTY_JS_DIR)/manifest.json $(THIRDPARTY_JS_DIR)/*.hash
  120. @echo "--- Synchronizing external dependencies with crepo"
  121. @# Do crepo sync iff not NOCREPO
  122. @if [ -n "$(NOCREPO)" ] ; then \
  123. echo ' ---- Skipping crepo sync (NOCREPO is set)' ; \
  124. else \
  125. mkdir -p $(BLD_DIR); \
  126. cd $(THIRDPARTY_JS_DIR) && $(CREPO) sync && \
  127. ($(CREPO) dump-refs > $(ROOT)/VERSION_DATA || true) ; \
  128. fi
  129. # END DEV ONLY >>>>
  130. ###################################
  131. # Install parent POM
  132. ###################################
  133. parent-pom:
  134. cd $(ROOT)/maven && mvn install $(MAVEN_OPTIONS)
  135. .PHONY: parent-pom
  136. ###################################
  137. # virtual-env
  138. ###################################
  139. virtual-env: $(BLD_DIR_ENV)/stamp
  140. $(BLD_DIR_ENV)/stamp:
  141. @echo "--- Creating virtual environment at $(BLD_DIR_ENV)"
  142. $(SYS_PYTHON) $(VIRTUAL_BOOTSTRAP) \
  143. $(VIRTUALENV_OPTS) --no-site-packages $(BLD_DIR_ENV)
  144. @touch $@
  145. @echo "--- $(BLD_DIR_ENV) ready"
  146. .PHONY: virtual-env
  147. ###################################
  148. # Build desktop
  149. ###################################
  150. .PHONY: desktop
  151. # <<<< DEV ONLY
  152. desktop: crepo parent-pom
  153. # END DEV ONLY >>>>
  154. desktop: virtual-env
  155. @$(MAKE) -C desktop
  156. ###################################
  157. # Build apps
  158. ###################################
  159. .PHONY: apps
  160. apps: desktop
  161. @$(MAKE) -C $(APPS_DIR) env-install
  162. ###################################
  163. # Install binary dist
  164. ###################################
  165. INSTALL_CORE_FILES = \
  166. Makefile* $(wildcard *.mk) \
  167. ext \
  168. tools/app_reg \
  169. tools/virtual-bootstrap \
  170. tools/relocatable.sh \
  171. VERS* LICENSE* README*
  172. .PHONY: install
  173. install: virtual-env install-check install-core-structure install-desktop install-apps install-env
  174. .PHONY: install-check
  175. install-check:
  176. @if [ -n '$(wildcard $(INSTALL_DIR)/*)' ] ; then \
  177. echo 'ERROR: $(INSTALL_DIR) not empty. Cowardly refusing to continue.' ; \
  178. false ; \
  179. fi
  180. .PHONY: install-core-structure
  181. install-core-structure:
  182. @echo --- Installing core source structure...
  183. @mkdir -p $(INSTALL_DIR)
  184. @tar cf - $(INSTALL_CORE_FILES) | tar -C $(INSTALL_DIR) -xf -
  185. @# Add some variables to Makefile to make sure that our virtualenv
  186. @# in the install root is the same one we built from - this also
  187. @# disables the check for python-devel packages which are no longer
  188. @# needed
  189. @echo "SYS_PYTHON=$(ENV_PYTHON_VERSION)" > $(INSTALL_DIR)/Makefile.buildvars
  190. @echo "SKIP_PYTHONDEV_CHECK=1" >> $(INSTALL_DIR)/Makefile.buildvars
  191. .PHONY: install-desktop
  192. install-desktop:
  193. @echo --- Installing Desktop core...
  194. INSTALL_DIR=$(realpath $(INSTALL_DIR)) $(MAKE) -C desktop install
  195. .PHONY: install-apps
  196. install-apps:
  197. @echo '--- Installing Applications...'
  198. INSTALL_DIR=$(realpath $(INSTALL_DIR)) $(MAKE) -C apps install
  199. .PHONY: install-env
  200. install-env:
  201. @echo --- Creating new virtual environment
  202. $(MAKE) -C $(INSTALL_DIR) virtual-env
  203. @echo --- Setting up Desktop core
  204. $(MAKE) -C $(INSTALL_DIR)/desktop env-install
  205. @echo --- Setting up Applications
  206. $(MAKE) -C $(INSTALL_DIR)/apps env-install
  207. @echo --- Setting up Desktop database
  208. $(MAKE) -C $(INSTALL_DIR)/desktop syncdb
  209. ###################################
  210. # Cleanup
  211. ###################################
  212. .PHONY: clean
  213. clean:
  214. @rm -rf $(BLD_DIR_ENV)
  215. @$(MAKE) -C desktop clean
  216. @$(MAKE) -C apps clean
  217. # <<<< DEV ONLY
  218. @$(MAKE) -C docs clean
  219. @echo "Removing dependencies managed by crepo"
  220. @cd $(THIRDPARTY_JS_DIR) && $(CREPO) do-all -x clean -f -x -d
  221. @rm -f VERSION_DATA
  222. # END DEV ONLY >>>>
  223. #
  224. # Note: It is important for clean targets to *ONLY* clean products of the
  225. # build, and not misc runtime generated files. Don't abuse Makefile.
  226. #
  227. .PHONY: distclean
  228. distclean: clean
  229. @# Remove the other directories in build/
  230. @rm -rf $(BLD_DIR)
  231. @$(MAKE) -C desktop distclean
  232. @$(MAKE) -C apps distclean
  233. .PHONY: ext-clean
  234. ext-clean:
  235. @$(MAKE) -C desktop ext-clean
  236. @$(MAKE) -C apps ext-clean
  237. # <<<< DEV ONLY
  238. ###############################################
  239. # Misc (some used by automated test scripts)
  240. ###############################################
  241. java-test:
  242. mvn -f desktop/libs/hadoop/java/pom.xml test $(MAVEN_OPTIONS)
  243. test: java-test
  244. DESKTOP_DEBUG=1 $(ENV_PYTHON) $(BLD_DIR_BIN)/hue test fast --with-xunit
  245. test-slow: java-test
  246. DESKTOP_DEBUG=1 $(ENV_PYTHON) $(BLD_DIR_BIN)/hue test all --with-xunit --with-cover
  247. $(BLD_DIR_BIN)/coverage xml
  248. start-dev:
  249. DESKTOP_DEBUG=1 $(ENV_PYTHON) $(BLD_DIR_BIN)/hue runserver_plus
  250. # END DEV ONLY >>>>