blob: 645db9a8990d62d25940ee79c4484387eb6b5cc3 [file] [log] [blame]
Ed Tanous904063f2017-03-02 16:48:24 -08001set(JAVASCRIPT_ASSETS
2 js/selController.js
3 js/lodash.core.js
4 js/ui-bootstrap-tpls-2.1.3.js
5 js/angular-cookies.js
6 js/angular-websocket.js
7 js/angular-ui-router.js
Ed Tanous904063f2017-03-02 16:48:24 -08008 js/kvm-controller.js
Ed Tanous38bdb982017-03-03 14:19:33 -08009 js/logincontroller.js
Ed Tanous904063f2017-03-02 16:48:24 -080010 js/angular-resource.js
11 js/angular-sanitize.js
12 js/bmcApp.js
13 js/angular-animate.js
14 js/run_prettify.js
15 js/angular.js
16 js/versionController.js
17 noVNC/utils/parse.js
18 noVNC/utils/inflator.partial.js
19 noVNC/karma.conf.js
20 noVNC/include/inflator.js
21 noVNC/include/keysym.js
22 noVNC/include/chrome-app/tcp-client.js
23 noVNC/include/ui.js
24 noVNC/include/keysymdef.js
25 noVNC/include/websock.js
26 noVNC/include/util.js
27 noVNC/include/base64.js
28 noVNC/include/logo.js
29 noVNC/include/input.js
30 noVNC/include/rfb.js
31 noVNC/include/des.js
32 noVNC/include/playback.js
33 noVNC/include/xtscancodes.js
34 noVNC/include/keyboard.js
35 noVNC/include/webutil.js
36 noVNC/include/display.js
37)
38
39set(CSS_ASSETS
40 css/intel.css
41 css/bootstrap.css
42 css/font-awesome.css
43 css/bootstrap-theme.css
44 css/prettify.css
Ed Tanous904063f2017-03-02 16:48:24 -080045 noVNC/include/base.css
46 noVNC/include/blue.css
47 noVNC/include/black.css
48)
49
Ed Tanous38bdb982017-03-03 14:19:33 -080050set(HTML_ASSETS
51 index.html
52 login.html
53 partial-eventlog.html
54 partial-fruinfo.html
55 partial-home-list.html
56 partial-kvm.html
57 partial-systeminfo.html
58 websocket.html
59)
60
61set(IMG_ASSETS
62 img/logo.png
63)
64
Ed Tanous904063f2017-03-02 16:48:24 -080065set(STATIC_ASSETS_OUT "")
66foreach(JAVASCRIPT_ASSET ${JAVASCRIPT_ASSETS})
Ed Tanous38bdb982017-03-03 14:19:33 -080067 # if it's a debug build, don't minify
Ed Tanousc4771fb2017-03-13 13:39:49 -070068 if (CMAKE_BUILD_TYPE STREQUAL "DEBUG")
Ed Tanous38bdb982017-03-03 14:19:33 -080069 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET})
70 else()
71 set(OUTPUT_FILENAME ${CMAKE_CURRENT_BINARY_DIR}/${JAVASCRIPT_ASSET})
72 get_filename_component(FOLDERNAME ${OUTPUT_FILENAME} DIRECTORY)
73 file(MAKE_DIRECTORY "${FOLDERNAME}")
74 # TODO only minify if not a debug build
75 add_custom_command(OUTPUT ${OUTPUT_FILENAME}
76 COMMAND closure-compiler --language_in=ECMASCRIPT5
77 --js "${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET}"
78 --js_output_file "${CMAKE_CURRENT_BINARY_DIR}/${JAVASCRIPT_ASSET}"
Ed Tanousc4771fb2017-03-13 13:39:49 -070079 --compilation_level SIMPLE_OPTIMIZATIONS
80 --angular_pass
Ed Tanous38bdb982017-03-03 14:19:33 -080081 DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET}"
82 COMMENT "Minifying ${JAVASCRIPT_ASSET}"
83 )
84 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_BINARY_DIR}/${JAVASCRIPT_ASSET})
Ed Tanousc4771fb2017-03-13 13:39:49 -070085 endif (CMAKE_BUILD_TYPE STREQUAL "DEBUG")
Ed Tanous904063f2017-03-02 16:48:24 -080086endforeach(JAVASCRIPT_ASSET)
87
Ed Tanous38bdb982017-03-03 14:19:33 -080088# for now CSS is included as is
89foreach(CSS_ASSET ${CSS_ASSETS})
Ed Tanousc4771fb2017-03-13 13:39:49 -070090 # if it's a debug build, don't minify
91 if (CMAKE_BUILD_TYPE STREQUAL "DEBUG")
92 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET})
93 else()
94 set(OUTPUT_FILENAME ${CMAKE_CURRENT_BINARY_DIR}/${CSS_ASSET})
95 get_filename_component(FOLDERNAME ${OUTPUT_FILENAME} DIRECTORY)
96 file(MAKE_DIRECTORY "${FOLDERNAME}")
97 # TODO only minify if not a debug build
98 add_custom_command(OUTPUT ${OUTPUT_FILENAME}
99 COMMAND cssnano
100 "${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET}"
101 "${CMAKE_CURRENT_BINARY_DIR}/${CSS_ASSET}"
102
103 DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET}"
104 COMMENT "Minifying ${CSS_ASSET}"
105 )
106 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_BINARY_DIR}/${CSS_ASSET})
107 endif (CMAKE_BUILD_TYPE STREQUAL "DEBUG")
108
Ed Tanous38bdb982017-03-03 14:19:33 -0800109endforeach(CSS_ASSET)
110
111# for now HTML is included as is
112foreach(HTML_ASSET ${HTML_ASSETS})
113 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${HTML_ASSET})
114endforeach(HTML_ASSET)
115
116# for now IMG is included as is
117foreach(IMG_ASSET ${IMG_ASSETS})
118 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${IMG_ASSET})
119endforeach(IMG_ASSET)
120
Ed Tanous904063f2017-03-02 16:48:24 -0800121add_custom_target(minifyjs ALL DEPENDS ${STATIC_ASSETS_OUT})
122
Ed Tanous9b65f1f2017-03-07 15:17:13 -0800123file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/generated)
124
Ed Tanous904063f2017-03-02 16:48:24 -0800125set(CXX_STATIC_ASSETS_OUTPUT_FILE ${CMAKE_BINARY_DIR}/generated/webassets.cpp)
126set(WEBASSET_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/../scripts/build_web_assets.py")
127
128add_custom_command(OUTPUT ${CXX_STATIC_ASSETS_OUTPUT_FILE}
129 COMMAND ${WEBASSET_SCRIPT}
130 -o ${CXX_STATIC_ASSETS_OUTPUT_FILE} -i ${STATIC_ASSETS_OUT}
131
132 DEPENDS ${STATIC_ASSETS_OUT} ${WEBASSET_SCRIPT}
133 COMMENT "Building CPP file ${CXX_STATIC_ASSETS_OUTPUT_FILE}"
134)
135
136add_custom_target(packagestaticcpp ALL DEPENDS ${CXX_STATIC_ASSETS_OUTPUT_FILE})