blob: c34487f6281d53ed46b8fdf8e8f3cddf83988d45 [file] [log] [blame]
Ed Tanous904063f2017-03-02 16:48:24 -08001set(JAVASCRIPT_ASSETS
2 js/selController.js
3 js/lodash.core.js
Ed Tanous4758d5b2017-06-06 15:28:13 -07004 js/ui-bootstrap-tpls-2.5.0.js
Ed Tanous904063f2017-03-02 16:48:24 -08005 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 Tanous4758d5b2017-06-06 15:28:13 -070011 js/fwupdateController.js
12 js/mainController.js
Ed Tanouscc5a37f2017-05-11 10:27:23 -070013 js/versionController.js
14 js/sensorController.js
Ed Tanous904063f2017-03-02 16:48:24 -080015 js/angular-sanitize.js
16 js/bmcApp.js
Ed Tanous1ccd57c2017-03-21 13:15:58 -070017 js/base64.js
Ed Tanous904063f2017-03-02 16:48:24 -080018 js/angular-animate.js
19 js/run_prettify.js
20 js/angular.js
Ed Tanous4758d5b2017-06-06 15:28:13 -070021 js/angular-ui-router-uib-modal.js
Ed Tanouscc5a37f2017-05-11 10:27:23 -070022
Ed Tanousc81ca422017-03-21 16:18:49 -070023 noVNC/core/inflator.js
24 noVNC/core/input/xtscancodes.js
25 noVNC/core/input/util.js
26 noVNC/core/input/devices.js
27 noVNC/core/input/keysym.js
28 noVNC/core/input/keysymdef.js
29 noVNC/core/websock.js
30 noVNC/core/util.js
31 noVNC/core/base64.js
32 noVNC/core/rfb.js
33 noVNC/core/des.js
34 noVNC/core/display.js
35 noVNC/app/ui.js
36 noVNC/app/webutil.js
37
Ed Tanous904063f2017-03-02 16:48:24 -080038)
39
40set(CSS_ASSETS
41 css/intel.css
42 css/bootstrap.css
43 css/font-awesome.css
44 css/bootstrap-theme.css
45 css/prettify.css
Ed Tanousc81ca422017-03-21 16:18:49 -070046 noVNC/app/styles/base.css
47 noVNC/app/styles/auto.css
Ed Tanous904063f2017-03-02 16:48:24 -080048)
49
Ed Tanous38bdb982017-03-03 14:19:33 -080050set(HTML_ASSETS
51 index.html
Ed Tanous1ccd57c2017-03-21 13:15:58 -070052 partial-login.html
Ed Tanous38bdb982017-03-03 14:19:33 -080053 partial-eventlog.html
54 partial-fruinfo.html
55 partial-home-list.html
Ed Tanous1ccd57c2017-03-21 13:15:58 -070056 partial-ipmi.html
Ed Tanous38bdb982017-03-03 14:19:33 -080057 partial-kvm.html
Ed Tanouscc5a37f2017-05-11 10:27:23 -070058 partial-sensor.html
Ed Tanous38bdb982017-03-03 14:19:33 -080059 partial-systeminfo.html
Ed Tanous4758d5b2017-06-06 15:28:13 -070060 partial-fwupdate.html
61 partial-fwupdateconfirm.html
Ed Tanous38bdb982017-03-03 14:19:33 -080062)
63
Ed Tanous1ccd57c2017-03-21 13:15:58 -070064set(OTHER_ASSETS
Ed Tanous38bdb982017-03-03 14:19:33 -080065 img/logo.png
Ed Tanous4758d5b2017-06-06 15:28:13 -070066 img/blur-bg.jpg
Ed Tanous1ccd57c2017-03-21 13:15:58 -070067 fonts/fontawesome-webfont.woff
Ed Tanous38bdb982017-03-03 14:19:33 -080068)
69
Ed Tanous904063f2017-03-02 16:48:24 -080070set(STATIC_ASSETS_OUT "")
Ed Tanous93f987d2017-04-17 17:52:36 -070071set(MINIFIED_ASSETS_OUT "")
Ed Tanous904063f2017-03-02 16:48:24 -080072foreach(JAVASCRIPT_ASSET ${JAVASCRIPT_ASSETS})
Ed Tanous93f987d2017-04-17 17:52:36 -070073
74 set(MINIFIED_FILENAME ${CMAKE_CURRENT_BINARY_DIR}/${JAVASCRIPT_ASSET})
75 get_filename_component(FOLDERNAME ${MINIFIED_FILENAME} DIRECTORY)
76 # string(REGEX REPLACE "(\\.[^.]*$)" ".min\\1" OUTPUT_FILENAME ${OUTPUT_FILENAME})
77 file(MAKE_DIRECTORY "${FOLDERNAME}")
78 add_custom_command(OUTPUT ${MINIFIED_FILENAME}
Ed Tanousdde86302017-06-15 16:31:27 -070079 COMMAND uglifyjs --compress --mangle
80 --output "${MINIFIED_FILENAME}"
81 "${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET}"
Ed Tanous93f987d2017-04-17 17:52:36 -070082 DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET}"
83 COMMENT "Minifying ${JAVASCRIPT_ASSET}"
84 )
85
86
87 list(APPEND MINIFIED_ASSETS_OUT ${MINIFIED_FILENAME})
88 # if it's a debug build, use the unminified version
Ed Tanous1ccd57c2017-03-21 13:15:58 -070089 if (CMAKE_BUILD_TYPE STREQUAL "Debug")
Ed Tanous38bdb982017-03-03 14:19:33 -080090 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET})
91 else()
Ed Tanous93f987d2017-04-17 17:52:36 -070092 list(APPEND STATIC_ASSETS_OUT ${MINIFIED_FILENAME})
Ed Tanous1ccd57c2017-03-21 13:15:58 -070093 endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
Ed Tanous904063f2017-03-02 16:48:24 -080094endforeach(JAVASCRIPT_ASSET)
95
Ed Tanousc9b55212017-06-12 13:25:51 -070096
97find_program(CSS_MINIFIER cssnano)
98if(NOT CSS_MINIFIER)
99 message("cssnano not found")
100endif()
Ed Tanous38bdb982017-03-03 14:19:33 -0800101# for now CSS is included as is
102foreach(CSS_ASSET ${CSS_ASSETS})
Ed Tanous93f987d2017-04-17 17:52:36 -0700103 set(MINIFIED_FILENAME ${CMAKE_CURRENT_BINARY_DIR}/${CSS_ASSET})
104 get_filename_component(FOLDERNAME ${MINIFIED_FILENAME} DIRECTORY)
105 file(MAKE_DIRECTORY "${FOLDERNAME}")
Ed Tanousc9b55212017-06-12 13:25:51 -0700106 if(CSS_MINIFIER)
107 message(FATAL_ERROR "cssnano not found!")
108
109 add_custom_command(OUTPUT ${MINIFIED_FILENAME}
110 COMMAND cssnano
111 "${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET}"
112 "${CMAKE_CURRENT_BINARY_DIR}/${CSS_ASSET}"
Ed Tanous93f987d2017-04-17 17:52:36 -0700113
Ed Tanousc9b55212017-06-12 13:25:51 -0700114 DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET}"
115 COMMENT "Minifying ${CSS_ASSET}"
116 )
117 list(APPEND MINIFIED_ASSETS_OUT ${MINIFIED_FILENAME})
118 endif()
Ed Tanous93f987d2017-04-17 17:52:36 -0700119 # if it's a debug build, use the unminified version
Ed Tanousc9b55212017-06-12 13:25:51 -0700120 if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT CSS_MINIFIER)
Ed Tanousc4771fb2017-03-13 13:39:49 -0700121 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET})
122 else()
Ed Tanous93f987d2017-04-17 17:52:36 -0700123 list(APPEND STATIC_ASSETS_OUT ${MINIFIED_FILENAME})
Ed Tanousc9b55212017-06-12 13:25:51 -0700124 endif (CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT CSS_MINIFIER)
Ed Tanousc4771fb2017-03-13 13:39:49 -0700125
Ed Tanous38bdb982017-03-03 14:19:33 -0800126endforeach(CSS_ASSET)
127
128# for now HTML is included as is
129foreach(HTML_ASSET ${HTML_ASSETS})
130 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${HTML_ASSET})
131endforeach(HTML_ASSET)
132
133# for now IMG is included as is
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700134foreach(OTHER_ASSET ${OTHER_ASSETS})
135 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${OTHER_ASSET})
136endforeach(OTHER_ASSET)
Ed Tanous38bdb982017-03-03 14:19:33 -0800137
Ed Tanous93f987d2017-04-17 17:52:36 -0700138# this taret is the dependency that the build script uses to make sure everything is available
139add_custom_target(buildstatic ALL DEPENDS ${STATIC_ASSETS_OUT})
140
141# this target makes sure that assets are minified in debug builds, even if they aren't used
142add_custom_target(minifyassets ALL DEPENDS ${MINIFIED_ASSETS_OUT})
143
Ed Tanous904063f2017-03-02 16:48:24 -0800144
Ed Tanous9b65f1f2017-03-07 15:17:13 -0800145file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/generated)
146
Ed Tanous904063f2017-03-02 16:48:24 -0800147set(CXX_STATIC_ASSETS_OUTPUT_FILE ${CMAKE_BINARY_DIR}/generated/webassets.cpp)
148set(WEBASSET_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/../scripts/build_web_assets.py")
149
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700150if (CMAKE_BUILD_TYPE STREQUAL "Debug")
151 set(DEBUG_MODE "-d")
152endif()
153
Ed Tanous904063f2017-03-02 16:48:24 -0800154add_custom_command(OUTPUT ${CXX_STATIC_ASSETS_OUTPUT_FILE}
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700155 COMMAND ${WEBASSET_SCRIPT} ${DEBUG_MODE}
Ed Tanous904063f2017-03-02 16:48:24 -0800156 -o ${CXX_STATIC_ASSETS_OUTPUT_FILE} -i ${STATIC_ASSETS_OUT}
157
158 DEPENDS ${STATIC_ASSETS_OUT} ${WEBASSET_SCRIPT}
159 COMMENT "Building CPP file ${CXX_STATIC_ASSETS_OUTPUT_FILE}"
160)
161
162add_custom_target(packagestaticcpp ALL DEPENDS ${CXX_STATIC_ASSETS_OUTPUT_FILE})