Makefile 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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. # |
  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. .PHONY: default
  83. default:
  84. @echo 'The build targets for Hue $(DESKTOP_VERSION) are:'
  85. @echo ' install : Install at $$PREFIX ($(INSTALL_DIR)); need desktop'
  86. @echo ' apps : Build and register all desktop apps; need desktop'
  87. @echo ' desktop : Build desktop core only'
  88. @echo ' clean : Remove desktop build products'
  89. @echo ' distclean : Remove desktop and thirdparty build products'
  90. # <<<< DEV ONLY
  91. @echo ' docs : Build documentation'
  92. @echo ' prod : Generate a tar file for production distribution'
  93. @echo ' locales : Extract strings and update dictionary of each locale'
  94. @echo ' ace : Builds the Ace Editor tool'
  95. # END DEV ONLY >>>>
  96. .PHONY: all
  97. all: default
  98. # <<<< DEV ONLY
  99. include Makefile.tarball
  100. ###################################
  101. # Build docs
  102. ###################################
  103. .PHONY: docs
  104. docs:
  105. @$(MAKE) -C docs
  106. # END DEV ONLY >>>>
  107. ###################################
  108. # Install parent POM
  109. ###################################
  110. parent-pom:
  111. cd $(ROOT)/maven && mvn install $(MAVEN_OPTIONS)
  112. .PHONY: parent-pom
  113. ###################################
  114. # virtual-env
  115. ###################################
  116. virtual-env: $(BLD_DIR_ENV)/stamp
  117. $(BLD_DIR_ENV)/stamp:
  118. @echo "--- Creating virtual environment at $(BLD_DIR_ENV)"
  119. $(SYS_PYTHON) $(VIRTUAL_BOOTSTRAP) \
  120. $(VIRTUALENV_OPTS) --system-site-packages $(BLD_DIR_ENV)
  121. @touch $@
  122. @echo "--- $(BLD_DIR_ENV) ready"
  123. .PHONY: virtual-env
  124. ###################################
  125. # Build desktop
  126. ###################################
  127. .PHONY: desktop
  128. # <<<< DEV ONLY
  129. desktop: parent-pom
  130. # END DEV ONLY >>>>
  131. desktop: virtual-env
  132. @$(MAKE) -C desktop
  133. ###################################
  134. # Build apps
  135. ###################################
  136. .PHONY: apps
  137. apps: desktop
  138. @$(MAKE) -C $(APPS_DIR) env-install
  139. ###################################
  140. # Install binary dist
  141. ###################################
  142. INSTALL_CORE_FILES = \
  143. Makefile* $(wildcard *.mk) \
  144. ext \
  145. tools/app_reg \
  146. tools/virtual-bootstrap \
  147. tools/relocatable.sh \
  148. VERS* LICENSE* README*
  149. .PHONY: install
  150. install: virtual-env install-check install-core-structure install-desktop install-apps install-env
  151. .PHONY: install-check
  152. install-check:
  153. @if [ -n '$(wildcard $(INSTALL_DIR)/*)' ] ; then \
  154. echo 'ERROR: $(INSTALL_DIR) not empty. Cowardly refusing to continue.' ; \
  155. false ; \
  156. fi
  157. .PHONY: install-core-structure
  158. install-core-structure:
  159. @echo --- Installing core source structure...
  160. @mkdir -p $(INSTALL_DIR)
  161. @tar cf - $(INSTALL_CORE_FILES) | tar -C $(INSTALL_DIR) -xf -
  162. @# Add some variables to Makefile to make sure that our virtualenv
  163. @# in the install root is the same one we built from - this also
  164. @# disables the check for python-devel packages which are no longer
  165. @# needed
  166. @echo "SYS_PYTHON=$(ENV_PYTHON_VERSION)" > $(INSTALL_DIR)/Makefile.buildvars
  167. @echo "SKIP_PYTHONDEV_CHECK=1" >> $(INSTALL_DIR)/Makefile.buildvars
  168. .PHONY: install-desktop
  169. install-desktop:
  170. @echo --- Installing Desktop core...
  171. INSTALL_DIR=$(realpath $(INSTALL_DIR)) $(MAKE) -C desktop install
  172. .PHONY: install-apps
  173. install-apps:
  174. @echo '--- Installing Applications...'
  175. INSTALL_DIR=$(realpath $(INSTALL_DIR)) $(MAKE) -C apps install
  176. .PHONY: install-env
  177. install-env:
  178. @echo --- Creating new virtual environment
  179. $(MAKE) -C $(INSTALL_DIR) virtual-env
  180. @echo --- Setting up Desktop core
  181. $(MAKE) -C $(INSTALL_DIR)/desktop env-install
  182. @echo --- Setting up Applications
  183. $(MAKE) -C $(INSTALL_DIR)/apps env-install
  184. @echo --- Setting up Desktop database
  185. $(MAKE) -C $(INSTALL_DIR)/desktop syncdb
  186. ###################################
  187. # Internationalization
  188. ###################################
  189. # <<<< DEV ONLY
  190. .PHONY: locales
  191. locales:
  192. @$(MAKE) -C desktop compile-locales
  193. @$(MAKE) -C apps compile-locales
  194. # END DEV ONLY >>>>
  195. ###################################
  196. # Ace Editor
  197. ###################################
  198. # <<<< DEV ONLY
  199. .PHONY: ace
  200. ace:
  201. @cd tools/ace-editor && ./hue-ace.sh
  202. # END DEV ONLY >>>>
  203. ###################################
  204. # JISON Parser Generators
  205. ###################################
  206. # <<<< DEV ONLY
  207. .PHONY: global-search-parser
  208. global-search-parser:
  209. @cd tools/jison && ./hue-global-search.sh
  210. .PHONY: solr-all-parsers
  211. solr-all-parsers:
  212. @cd tools/jison && ./hue-solr-query.sh && ./hue-solr-formula.sh
  213. .PHONY: solr-query-parser
  214. solr-query-parser:
  215. @cd tools/jison && ./hue-solr-query.sh
  216. .PHONY: solr-formula-parser
  217. solr-formula-parser:
  218. @cd tools/jison && ./hue-solr-formula.sh
  219. .PHONY: sql-all-parsers
  220. sql-all-parsers:
  221. @cd tools/jison && ./hue-sql-autocomplete.sh && ./hue-sql-statement.sh && ./hue-sql-syntax.sh
  222. .PHONY: sql-autocomplete-parser
  223. sql-autocomplete-parser:
  224. @cd tools/jison && ./hue-sql-autocomplete.sh
  225. .PHONY: sql-statement-parser
  226. sql-statement-parser:
  227. @cd tools/jison && ./hue-sql-statement.sh
  228. .PHONY: sql-syntax-parser
  229. sql-syntax-parser:
  230. @cd tools/jison && ./hue-sql-syntax.sh
  231. # END DEV ONLY >>>>
  232. ###################################
  233. # Cleanup
  234. ###################################
  235. .PHONY: clean
  236. clean:
  237. @$(MAKE) -C desktop clean
  238. @$(MAKE) -C apps clean
  239. # <<<< DEV ONLY
  240. @$(MAKE) -C docs clean
  241. # END DEV ONLY >>>>
  242. @rm -rf $(BLD_DIR_ENV)
  243. @rm -rf $(STATIC_DIR)
  244. #
  245. # Note: It is important for clean targets to *ONLY* clean products of the
  246. # build, and not misc runtime generated files. Don't abuse Makefile.
  247. #
  248. .PHONY: distclean
  249. distclean: clean
  250. @# Remove the other directories in build/
  251. @$(MAKE) -C desktop distclean
  252. @$(MAKE) -C apps distclean
  253. @rm -rf $(BLD_DIR)
  254. .PHONY: ext-clean
  255. ext-clean:
  256. @$(MAKE) -C desktop ext-clean
  257. @$(MAKE) -C apps ext-clean
  258. # <<<< DEV ONLY
  259. ###############################################
  260. # Misc (some used by automated test scripts)
  261. ###############################################
  262. js-test:
  263. $(ROOT)/tools/jasmine/phantomjs.runner.sh $(ROOT)/desktop/core/src/desktop/templates/jasmineRunner.html
  264. java-test:
  265. mvn -f desktop/libs/hadoop/java/pom.xml test $(MAVEN_OPTIONS)
  266. test: java-test
  267. DESKTOP_DEBUG=1 $(ENV_PYTHON) $(BLD_DIR_BIN)/hue test fast --with-xunit
  268. test-slow: java-test
  269. DESKTOP_DEBUG=1 $(ENV_PYTHON) $(BLD_DIR_BIN)/hue test all --with-xunit --with-cover
  270. $(BLD_DIR_BIN)/coverage xml -i
  271. start-dev:
  272. DESKTOP_DEBUG=1 $(ENV_PYTHON) $(BLD_DIR_BIN)/hue runserver_plus
  273. devinstall:
  274. npm run devinstall
  275. css:
  276. npm run less
  277. # END DEV ONLY >>>>