blob: 4e6831c13d64bc2038f26fdcd762bdbeb4b8f6f9 [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}")
Ed Tanous7b4e3da2017-06-26 11:08:40 -070082 if(UGLIFY_MINIFIER)
83 add_custom_command(OUTPUT ${MINIFIED_FILENAME}
84 COMMAND uglifyjs --compress --mangle
85 --output "${MINIFIED_FILENAME}"
86 "${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET}"
87 DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET}"
88 COMMENT "Minifying ${JAVASCRIPT_ASSET}"
89 )
90 list(APPEND MINIFIED_ASSETS_OUT ${MINIFIED_FILENAME})
91 endif(UGLIFY_MINIFIER)
92
Ed Tanous93f987d2017-04-17 17:52:36 -070093 # if it's a debug build, use the unminified version
Ed Tanous1e1e38c2017-06-19 16:01:33 -070094 if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT UGLIFY_MINIFIER)
Ed Tanous38bdb982017-03-03 14:19:33 -080095 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET})
96 else()
Ed Tanous93f987d2017-04-17 17:52:36 -070097 list(APPEND STATIC_ASSETS_OUT ${MINIFIED_FILENAME})
Ed Tanous1e1e38c2017-06-19 16:01:33 -070098 endif (CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT UGLIFY_MINIFIER)
Ed Tanous904063f2017-03-02 16:48:24 -080099endforeach(JAVASCRIPT_ASSET)
100
Ed Tanousc9b55212017-06-12 13:25:51 -0700101
102find_program(CSS_MINIFIER cssnano)
103if(NOT CSS_MINIFIER)
104 message("cssnano not found")
105endif()
Ed Tanous38bdb982017-03-03 14:19:33 -0800106# for now CSS is included as is
107foreach(CSS_ASSET ${CSS_ASSETS})
Ed Tanous93f987d2017-04-17 17:52:36 -0700108 set(MINIFIED_FILENAME ${CMAKE_CURRENT_BINARY_DIR}/${CSS_ASSET})
109 get_filename_component(FOLDERNAME ${MINIFIED_FILENAME} DIRECTORY)
110 file(MAKE_DIRECTORY "${FOLDERNAME}")
Ed Tanous1e1e38c2017-06-19 16:01:33 -0700111 if(CSS_MINIFIER)
Ed Tanousc9b55212017-06-12 13:25:51 -0700112 add_custom_command(OUTPUT ${MINIFIED_FILENAME}
113 COMMAND cssnano
114 "${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET}"
115 "${CMAKE_CURRENT_BINARY_DIR}/${CSS_ASSET}"
Ed Tanous93f987d2017-04-17 17:52:36 -0700116
Ed Tanousc9b55212017-06-12 13:25:51 -0700117 DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET}"
118 COMMENT "Minifying ${CSS_ASSET}"
119 )
120 list(APPEND MINIFIED_ASSETS_OUT ${MINIFIED_FILENAME})
121 endif()
Ed Tanous93f987d2017-04-17 17:52:36 -0700122 # if it's a debug build, use the unminified version
Ed Tanousc9b55212017-06-12 13:25:51 -0700123 if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT CSS_MINIFIER)
Ed Tanousc4771fb2017-03-13 13:39:49 -0700124 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET})
125 else()
Ed Tanous93f987d2017-04-17 17:52:36 -0700126 list(APPEND STATIC_ASSETS_OUT ${MINIFIED_FILENAME})
Ed Tanousc9b55212017-06-12 13:25:51 -0700127 endif (CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT CSS_MINIFIER)
Ed Tanousc4771fb2017-03-13 13:39:49 -0700128
Ed Tanous38bdb982017-03-03 14:19:33 -0800129endforeach(CSS_ASSET)
130
131# for now HTML is included as is
132foreach(HTML_ASSET ${HTML_ASSETS})
133 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${HTML_ASSET})
134endforeach(HTML_ASSET)
135
136# for now IMG is included as is
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700137foreach(OTHER_ASSET ${OTHER_ASSETS})
138 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${OTHER_ASSET})
139endforeach(OTHER_ASSET)
Ed Tanous38bdb982017-03-03 14:19:33 -0800140
Ed Tanous93f987d2017-04-17 17:52:36 -0700141# this taret is the dependency that the build script uses to make sure everything is available
142add_custom_target(buildstatic ALL DEPENDS ${STATIC_ASSETS_OUT})
143
144# this target makes sure that assets are minified in debug builds, even if they aren't used
145add_custom_target(minifyassets ALL DEPENDS ${MINIFIED_ASSETS_OUT})
146
Ed Tanous904063f2017-03-02 16:48:24 -0800147
Ed Tanous9b65f1f2017-03-07 15:17:13 -0800148file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/generated)
149
Ed Tanous904063f2017-03-02 16:48:24 -0800150set(CXX_STATIC_ASSETS_OUTPUT_FILE ${CMAKE_BINARY_DIR}/generated/webassets.cpp)
151set(WEBASSET_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/../scripts/build_web_assets.py")
152
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700153if (CMAKE_BUILD_TYPE STREQUAL "Debug")
154 set(DEBUG_MODE "-d")
155endif()
156
Ed Tanous904063f2017-03-02 16:48:24 -0800157add_custom_command(OUTPUT ${CXX_STATIC_ASSETS_OUTPUT_FILE}
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700158 COMMAND ${WEBASSET_SCRIPT} ${DEBUG_MODE}
Ed Tanous904063f2017-03-02 16:48:24 -0800159 -o ${CXX_STATIC_ASSETS_OUTPUT_FILE} -i ${STATIC_ASSETS_OUT}
160
161 DEPENDS ${STATIC_ASSETS_OUT} ${WEBASSET_SCRIPT}
162 COMMENT "Building CPP file ${CXX_STATIC_ASSETS_OUTPUT_FILE}"
163)
164
165add_custom_target(packagestaticcpp ALL DEPENDS ${CXX_STATIC_ASSETS_OUTPUT_FILE})