blob: 7353ccc3a46fd035f8bac3775962a1f8bf06eef8 [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 Tanous1ccd57c2017-03-21 13:15:58 -07008 js/kvmController.js
9 js/loginController.js
10 js/ipmiController.js
Ed Tanous904063f2017-03-02 16:48:24 -080011 js/angular-resource.js
12 js/angular-sanitize.js
13 js/bmcApp.js
Ed Tanous1ccd57c2017-03-21 13:15:58 -070014 js/base64.js
Ed Tanous904063f2017-03-02 16:48:24 -080015 js/angular-animate.js
16 js/run_prettify.js
17 js/angular.js
18 js/versionController.js
Ed Tanousc81ca422017-03-21 16:18:49 -070019 noVNC/core/inflator.js
20 noVNC/core/input/xtscancodes.js
21 noVNC/core/input/util.js
22 noVNC/core/input/devices.js
23 noVNC/core/input/keysym.js
24 noVNC/core/input/keysymdef.js
25 noVNC/core/websock.js
26 noVNC/core/util.js
27 noVNC/core/base64.js
28 noVNC/core/rfb.js
29 noVNC/core/des.js
30 noVNC/core/display.js
31 noVNC/app/ui.js
32 noVNC/app/webutil.js
33
Ed Tanous904063f2017-03-02 16:48:24 -080034)
35
36set(CSS_ASSETS
37 css/intel.css
38 css/bootstrap.css
39 css/font-awesome.css
40 css/bootstrap-theme.css
41 css/prettify.css
Ed Tanousc81ca422017-03-21 16:18:49 -070042 noVNC/app/styles/base.css
43 noVNC/app/styles/auto.css
Ed Tanous904063f2017-03-02 16:48:24 -080044)
45
Ed Tanous38bdb982017-03-03 14:19:33 -080046set(HTML_ASSETS
47 index.html
Ed Tanous1ccd57c2017-03-21 13:15:58 -070048 partial-login.html
Ed Tanous38bdb982017-03-03 14:19:33 -080049 partial-eventlog.html
50 partial-fruinfo.html
51 partial-home-list.html
Ed Tanous1ccd57c2017-03-21 13:15:58 -070052 partial-ipmi.html
Ed Tanous38bdb982017-03-03 14:19:33 -080053 partial-kvm.html
54 partial-systeminfo.html
Ed Tanous38bdb982017-03-03 14:19:33 -080055)
56
Ed Tanous1ccd57c2017-03-21 13:15:58 -070057set(OTHER_ASSETS
Ed Tanous38bdb982017-03-03 14:19:33 -080058 img/logo.png
Ed Tanous1ccd57c2017-03-21 13:15:58 -070059 fonts/fontawesome-webfont.woff
Ed Tanous38bdb982017-03-03 14:19:33 -080060)
61
Ed Tanous904063f2017-03-02 16:48:24 -080062set(STATIC_ASSETS_OUT "")
63foreach(JAVASCRIPT_ASSET ${JAVASCRIPT_ASSETS})
Ed Tanous38bdb982017-03-03 14:19:33 -080064 # if it's a debug build, don't minify
Ed Tanous1ccd57c2017-03-21 13:15:58 -070065 if (CMAKE_BUILD_TYPE STREQUAL "Debug")
Ed Tanous38bdb982017-03-03 14:19:33 -080066 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET})
67 else()
68 set(OUTPUT_FILENAME ${CMAKE_CURRENT_BINARY_DIR}/${JAVASCRIPT_ASSET})
69 get_filename_component(FOLDERNAME ${OUTPUT_FILENAME} DIRECTORY)
Ed Tanous1ccd57c2017-03-21 13:15:58 -070070 # string(REGEX REPLACE "(\\.[^.]*$)" ".min\\1" OUTPUT_FILENAME ${OUTPUT_FILENAME})
Ed Tanous38bdb982017-03-03 14:19:33 -080071 file(MAKE_DIRECTORY "${FOLDERNAME}")
72 # TODO only minify if not a debug build
73 add_custom_command(OUTPUT ${OUTPUT_FILENAME}
74 COMMAND closure-compiler --language_in=ECMASCRIPT5
75 --js "${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET}"
Ed Tanous1ccd57c2017-03-21 13:15:58 -070076 --js_output_file "${OUTPUT_FILENAME}"
Ed Tanousc4771fb2017-03-13 13:39:49 -070077 --compilation_level SIMPLE_OPTIMIZATIONS
78 --angular_pass
Ed Tanous38bdb982017-03-03 14:19:33 -080079 DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET}"
80 COMMENT "Minifying ${JAVASCRIPT_ASSET}"
81 )
Ed Tanous1ccd57c2017-03-21 13:15:58 -070082 list(APPEND STATIC_ASSETS_OUT ${OUTPUT_FILENAME})
83 endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
Ed Tanous904063f2017-03-02 16:48:24 -080084endforeach(JAVASCRIPT_ASSET)
85
Ed Tanous38bdb982017-03-03 14:19:33 -080086# for now CSS is included as is
87foreach(CSS_ASSET ${CSS_ASSETS})
Ed Tanousc4771fb2017-03-13 13:39:49 -070088 # if it's a debug build, don't minify
Ed Tanous1ccd57c2017-03-21 13:15:58 -070089 if (CMAKE_BUILD_TYPE STREQUAL "Debug")
Ed Tanousc4771fb2017-03-13 13:39:49 -070090 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET})
91 else()
92 set(OUTPUT_FILENAME ${CMAKE_CURRENT_BINARY_DIR}/${CSS_ASSET})
93 get_filename_component(FOLDERNAME ${OUTPUT_FILENAME} DIRECTORY)
94 file(MAKE_DIRECTORY "${FOLDERNAME}")
95 # TODO only minify if not a debug build
96 add_custom_command(OUTPUT ${OUTPUT_FILENAME}
97 COMMAND cssnano
98 "${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET}"
99 "${CMAKE_CURRENT_BINARY_DIR}/${CSS_ASSET}"
100
101 DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET}"
102 COMMENT "Minifying ${CSS_ASSET}"
103 )
104 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_BINARY_DIR}/${CSS_ASSET})
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700105 endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
Ed Tanousc4771fb2017-03-13 13:39:49 -0700106
Ed Tanous38bdb982017-03-03 14:19:33 -0800107endforeach(CSS_ASSET)
108
109# for now HTML is included as is
110foreach(HTML_ASSET ${HTML_ASSETS})
111 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${HTML_ASSET})
112endforeach(HTML_ASSET)
113
114# for now IMG is included as is
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700115foreach(OTHER_ASSET ${OTHER_ASSETS})
116 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${OTHER_ASSET})
117endforeach(OTHER_ASSET)
Ed Tanous38bdb982017-03-03 14:19:33 -0800118
Ed Tanous904063f2017-03-02 16:48:24 -0800119add_custom_target(minifyjs ALL DEPENDS ${STATIC_ASSETS_OUT})
120
Ed Tanous9b65f1f2017-03-07 15:17:13 -0800121file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/generated)
122
Ed Tanous904063f2017-03-02 16:48:24 -0800123set(CXX_STATIC_ASSETS_OUTPUT_FILE ${CMAKE_BINARY_DIR}/generated/webassets.cpp)
124set(WEBASSET_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/../scripts/build_web_assets.py")
125
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700126if (CMAKE_BUILD_TYPE STREQUAL "Debug")
127 set(DEBUG_MODE "-d")
128endif()
129
Ed Tanous904063f2017-03-02 16:48:24 -0800130add_custom_command(OUTPUT ${CXX_STATIC_ASSETS_OUTPUT_FILE}
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700131 COMMAND ${WEBASSET_SCRIPT} ${DEBUG_MODE}
Ed Tanous904063f2017-03-02 16:48:24 -0800132 -o ${CXX_STATIC_ASSETS_OUTPUT_FILE} -i ${STATIC_ASSETS_OUT}
133
134 DEPENDS ${STATIC_ASSETS_OUT} ${WEBASSET_SCRIPT}
135 COMMENT "Building CPP file ${CXX_STATIC_ASSETS_OUTPUT_FILE}"
136)
137
138add_custom_target(packagestaticcpp ALL DEPENDS ${CXX_STATIC_ASSETS_OUTPUT_FILE})