blob: b5a53ecbe9c26245baba557828be244256d172fa [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 Tanousd4649872017-06-20 10:24:35 -070072find_program(UGLIFY_MINIFIER uglifyjs)
Ed Tanous1e1e38c2017-06-19 16:01:33 -070073if(NOT UGLIFY_MINIFIER)
74 message("uglifyjs not found")
75endif()
Ed Tanous904063f2017-03-02 16:48:24 -080076foreach(JAVASCRIPT_ASSET ${JAVASCRIPT_ASSETS})
Ed Tanous93f987d2017-04-17 17:52:36 -070077
78 set(MINIFIED_FILENAME ${CMAKE_CURRENT_BINARY_DIR}/${JAVASCRIPT_ASSET})
79 get_filename_component(FOLDERNAME ${MINIFIED_FILENAME} DIRECTORY)
80 # string(REGEX REPLACE "(\\.[^.]*$)" ".min\\1" OUTPUT_FILENAME ${OUTPUT_FILENAME})
81 file(MAKE_DIRECTORY "${FOLDERNAME}")
82 add_custom_command(OUTPUT ${MINIFIED_FILENAME}
Ed Tanousdde86302017-06-15 16:31:27 -070083 COMMAND uglifyjs --compress --mangle
84 --output "${MINIFIED_FILENAME}"
85 "${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET}"
Ed Tanous93f987d2017-04-17 17:52:36 -070086 DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET}"
87 COMMENT "Minifying ${JAVASCRIPT_ASSET}"
88 )
89
Ed Tanous93f987d2017-04-17 17:52:36 -070090 list(APPEND MINIFIED_ASSETS_OUT ${MINIFIED_FILENAME})
91 # if it's a debug build, use the unminified version
Ed Tanous1e1e38c2017-06-19 16:01:33 -070092 if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT UGLIFY_MINIFIER)
Ed Tanous38bdb982017-03-03 14:19:33 -080093 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET})
94 else()
Ed Tanous93f987d2017-04-17 17:52:36 -070095 list(APPEND STATIC_ASSETS_OUT ${MINIFIED_FILENAME})
Ed Tanous1e1e38c2017-06-19 16:01:33 -070096 endif (CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT UGLIFY_MINIFIER)
Ed Tanous904063f2017-03-02 16:48:24 -080097endforeach(JAVASCRIPT_ASSET)
98
Ed Tanousc9b55212017-06-12 13:25:51 -070099
100find_program(CSS_MINIFIER cssnano)
101if(NOT CSS_MINIFIER)
102 message("cssnano not found")
103endif()
Ed Tanous38bdb982017-03-03 14:19:33 -0800104# for now CSS is included as is
105foreach(CSS_ASSET ${CSS_ASSETS})
Ed Tanous93f987d2017-04-17 17:52:36 -0700106 set(MINIFIED_FILENAME ${CMAKE_CURRENT_BINARY_DIR}/${CSS_ASSET})
107 get_filename_component(FOLDERNAME ${MINIFIED_FILENAME} DIRECTORY)
108 file(MAKE_DIRECTORY "${FOLDERNAME}")
Ed Tanous1e1e38c2017-06-19 16:01:33 -0700109 if(CSS_MINIFIER)
Ed Tanousc9b55212017-06-12 13:25:51 -0700110 add_custom_command(OUTPUT ${MINIFIED_FILENAME}
111 COMMAND cssnano
112 "${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET}"
113 "${CMAKE_CURRENT_BINARY_DIR}/${CSS_ASSET}"
Ed Tanous93f987d2017-04-17 17:52:36 -0700114
Ed Tanousc9b55212017-06-12 13:25:51 -0700115 DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET}"
116 COMMENT "Minifying ${CSS_ASSET}"
117 )
118 list(APPEND MINIFIED_ASSETS_OUT ${MINIFIED_FILENAME})
119 endif()
Ed Tanous93f987d2017-04-17 17:52:36 -0700120 # if it's a debug build, use the unminified version
Ed Tanousc9b55212017-06-12 13:25:51 -0700121 if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT CSS_MINIFIER)
Ed Tanousc4771fb2017-03-13 13:39:49 -0700122 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET})
123 else()
Ed Tanous93f987d2017-04-17 17:52:36 -0700124 list(APPEND STATIC_ASSETS_OUT ${MINIFIED_FILENAME})
Ed Tanousc9b55212017-06-12 13:25:51 -0700125 endif (CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT CSS_MINIFIER)
Ed Tanousc4771fb2017-03-13 13:39:49 -0700126
Ed Tanous38bdb982017-03-03 14:19:33 -0800127endforeach(CSS_ASSET)
128
129# for now HTML is included as is
130foreach(HTML_ASSET ${HTML_ASSETS})
131 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${HTML_ASSET})
132endforeach(HTML_ASSET)
133
134# for now IMG is included as is
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700135foreach(OTHER_ASSET ${OTHER_ASSETS})
136 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${OTHER_ASSET})
137endforeach(OTHER_ASSET)
Ed Tanous38bdb982017-03-03 14:19:33 -0800138
Ed Tanous93f987d2017-04-17 17:52:36 -0700139# this taret is the dependency that the build script uses to make sure everything is available
140add_custom_target(buildstatic ALL DEPENDS ${STATIC_ASSETS_OUT})
141
142# this target makes sure that assets are minified in debug builds, even if they aren't used
143add_custom_target(minifyassets ALL DEPENDS ${MINIFIED_ASSETS_OUT})
144
Ed Tanous904063f2017-03-02 16:48:24 -0800145
Ed Tanous9b65f1f2017-03-07 15:17:13 -0800146file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/generated)
147
Ed Tanous904063f2017-03-02 16:48:24 -0800148set(CXX_STATIC_ASSETS_OUTPUT_FILE ${CMAKE_BINARY_DIR}/generated/webassets.cpp)
149set(WEBASSET_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/../scripts/build_web_assets.py")
150
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700151if (CMAKE_BUILD_TYPE STREQUAL "Debug")
152 set(DEBUG_MODE "-d")
153endif()
154
Ed Tanous904063f2017-03-02 16:48:24 -0800155add_custom_command(OUTPUT ${CXX_STATIC_ASSETS_OUTPUT_FILE}
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700156 COMMAND ${WEBASSET_SCRIPT} ${DEBUG_MODE}
Ed Tanous904063f2017-03-02 16:48:24 -0800157 -o ${CXX_STATIC_ASSETS_OUTPUT_FILE} -i ${STATIC_ASSETS_OUT}
158
159 DEPENDS ${STATIC_ASSETS_OUT} ${WEBASSET_SCRIPT}
160 COMMENT "Building CPP file ${CXX_STATIC_ASSETS_OUTPUT_FILE}"
161)
162
163add_custom_target(packagestaticcpp ALL DEPENDS ${CXX_STATIC_ASSETS_OUTPUT_FILE})