blob: a99abc7568f8e5d0af131dc7cf764a563dd37f5d [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 Tanous5fceeb42017-06-28 09:43:09 -070022 js/smart-table.js
Ed Tanouscc5a37f2017-05-11 10:27:23 -070023
Ed Tanousc81ca422017-03-21 16:18:49 -070024 noVNC/core/inflator.js
25 noVNC/core/input/xtscancodes.js
26 noVNC/core/input/util.js
27 noVNC/core/input/devices.js
28 noVNC/core/input/keysym.js
29 noVNC/core/input/keysymdef.js
30 noVNC/core/websock.js
31 noVNC/core/util.js
32 noVNC/core/base64.js
33 noVNC/core/rfb.js
34 noVNC/core/des.js
35 noVNC/core/display.js
36 noVNC/app/ui.js
37 noVNC/app/webutil.js
38
Ed Tanous904063f2017-03-02 16:48:24 -080039)
40
41set(CSS_ASSETS
42 css/intel.css
43 css/bootstrap.css
44 css/font-awesome.css
45 css/bootstrap-theme.css
46 css/prettify.css
Ed Tanousc81ca422017-03-21 16:18:49 -070047 noVNC/app/styles/base.css
48 noVNC/app/styles/auto.css
Ed Tanous904063f2017-03-02 16:48:24 -080049)
50
Ed Tanous38bdb982017-03-03 14:19:33 -080051set(HTML_ASSETS
52 index.html
Ed Tanous1ccd57c2017-03-21 13:15:58 -070053 partial-login.html
Ed Tanous38bdb982017-03-03 14:19:33 -080054 partial-eventlog.html
55 partial-fruinfo.html
56 partial-home-list.html
Ed Tanous1ccd57c2017-03-21 13:15:58 -070057 partial-ipmi.html
Ed Tanous38bdb982017-03-03 14:19:33 -080058 partial-kvm.html
Ed Tanouscc5a37f2017-05-11 10:27:23 -070059 partial-sensor.html
Ed Tanous38bdb982017-03-03 14:19:33 -080060 partial-systeminfo.html
Ed Tanous4758d5b2017-06-06 15:28:13 -070061 partial-fwupdate.html
62 partial-fwupdateconfirm.html
Ed Tanous38bdb982017-03-03 14:19:33 -080063)
64
Ed Tanous1ccd57c2017-03-21 13:15:58 -070065set(OTHER_ASSETS
Ed Tanous38bdb982017-03-03 14:19:33 -080066 img/logo.png
Ed Tanous4758d5b2017-06-06 15:28:13 -070067 img/blur-bg.jpg
Ed Tanous1ccd57c2017-03-21 13:15:58 -070068 fonts/fontawesome-webfont.woff
Ed Tanous38bdb982017-03-03 14:19:33 -080069)
70
Ed Tanous904063f2017-03-02 16:48:24 -080071set(STATIC_ASSETS_OUT "")
Ed Tanous93f987d2017-04-17 17:52:36 -070072set(MINIFIED_ASSETS_OUT "")
Ed Tanous3dac7492017-08-02 13:46:20 -070073
Ed Tanousd4649872017-06-20 10:24:35 -070074find_program(UGLIFY_MINIFIER uglifyjs)
Ed Tanous1e1e38c2017-06-19 16:01:33 -070075if(NOT UGLIFY_MINIFIER)
76 message("uglifyjs not found")
Ed Tanous5fceeb42017-06-28 09:43:09 -070077else()
78 message("Found ${UGLIFY_MINIFIER}")
Ed Tanous1e1e38c2017-06-19 16:01:33 -070079endif()
Ed Tanous904063f2017-03-02 16:48:24 -080080foreach(JAVASCRIPT_ASSET ${JAVASCRIPT_ASSETS})
Ed Tanous93f987d2017-04-17 17:52:36 -070081
82 set(MINIFIED_FILENAME ${CMAKE_CURRENT_BINARY_DIR}/${JAVASCRIPT_ASSET})
83 get_filename_component(FOLDERNAME ${MINIFIED_FILENAME} DIRECTORY)
84 # string(REGEX REPLACE "(\\.[^.]*$)" ".min\\1" OUTPUT_FILENAME ${OUTPUT_FILENAME})
85 file(MAKE_DIRECTORY "${FOLDERNAME}")
Ed Tanous7b4e3da2017-06-26 11:08:40 -070086 if(UGLIFY_MINIFIER)
87 add_custom_command(OUTPUT ${MINIFIED_FILENAME}
Ed Tanous5fceeb42017-06-28 09:43:09 -070088 COMMAND ${UGLIFY_MINIFIER} --compress --mangle
Ed Tanous7b4e3da2017-06-26 11:08:40 -070089 --output "${MINIFIED_FILENAME}"
90 "${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET}"
91 DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET}"
92 COMMENT "Minifying ${JAVASCRIPT_ASSET}"
93 )
94 list(APPEND MINIFIED_ASSETS_OUT ${MINIFIED_FILENAME})
95 endif(UGLIFY_MINIFIER)
96
Ed Tanous93f987d2017-04-17 17:52:36 -070097 # if it's a debug build, use the unminified version
Ed Tanous1e1e38c2017-06-19 16:01:33 -070098 if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT UGLIFY_MINIFIER)
Ed Tanous38bdb982017-03-03 14:19:33 -080099 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET})
100 else()
Ed Tanous93f987d2017-04-17 17:52:36 -0700101 list(APPEND STATIC_ASSETS_OUT ${MINIFIED_FILENAME})
Ed Tanous1e1e38c2017-06-19 16:01:33 -0700102 endif (CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT UGLIFY_MINIFIER)
Ed Tanous904063f2017-03-02 16:48:24 -0800103endforeach(JAVASCRIPT_ASSET)
104
Ed Tanousc9b55212017-06-12 13:25:51 -0700105
106find_program(CSS_MINIFIER cssnano)
107if(NOT CSS_MINIFIER)
108 message("cssnano not found")
Ed Tanous5fceeb42017-06-28 09:43:09 -0700109else()
110 message("Found ${CSS_MINIFIER}")
Ed Tanousc9b55212017-06-12 13:25:51 -0700111endif()
Ed Tanous38bdb982017-03-03 14:19:33 -0800112# for now CSS is included as is
113foreach(CSS_ASSET ${CSS_ASSETS})
Ed Tanous93f987d2017-04-17 17:52:36 -0700114 set(MINIFIED_FILENAME ${CMAKE_CURRENT_BINARY_DIR}/${CSS_ASSET})
115 get_filename_component(FOLDERNAME ${MINIFIED_FILENAME} DIRECTORY)
116 file(MAKE_DIRECTORY "${FOLDERNAME}")
Ed Tanous1e1e38c2017-06-19 16:01:33 -0700117 if(CSS_MINIFIER)
Ed Tanousc9b55212017-06-12 13:25:51 -0700118 add_custom_command(OUTPUT ${MINIFIED_FILENAME}
Ed Tanous5fceeb42017-06-28 09:43:09 -0700119 COMMAND ${CSS_MINIFIER}
Ed Tanousc9b55212017-06-12 13:25:51 -0700120 "${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET}"
121 "${CMAKE_CURRENT_BINARY_DIR}/${CSS_ASSET}"
Ed Tanous93f987d2017-04-17 17:52:36 -0700122
Ed Tanousc9b55212017-06-12 13:25:51 -0700123 DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET}"
124 COMMENT "Minifying ${CSS_ASSET}"
125 )
126 list(APPEND MINIFIED_ASSETS_OUT ${MINIFIED_FILENAME})
127 endif()
Ed Tanous93f987d2017-04-17 17:52:36 -0700128 # if it's a debug build, use the unminified version
Ed Tanousc9b55212017-06-12 13:25:51 -0700129 if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT CSS_MINIFIER)
Ed Tanousc4771fb2017-03-13 13:39:49 -0700130 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET})
131 else()
Ed Tanous93f987d2017-04-17 17:52:36 -0700132 list(APPEND STATIC_ASSETS_OUT ${MINIFIED_FILENAME})
Ed Tanousc9b55212017-06-12 13:25:51 -0700133 endif (CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT CSS_MINIFIER)
Ed Tanousc4771fb2017-03-13 13:39:49 -0700134
Ed Tanous38bdb982017-03-03 14:19:33 -0800135endforeach(CSS_ASSET)
136
137# for now HTML is included as is
138foreach(HTML_ASSET ${HTML_ASSETS})
139 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${HTML_ASSET})
140endforeach(HTML_ASSET)
141
142# for now IMG is included as is
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700143foreach(OTHER_ASSET ${OTHER_ASSETS})
144 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${OTHER_ASSET})
145endforeach(OTHER_ASSET)
Ed Tanous38bdb982017-03-03 14:19:33 -0800146
Ed Tanous93f987d2017-04-17 17:52:36 -0700147# this taret is the dependency that the build script uses to make sure everything is available
148add_custom_target(buildstatic ALL DEPENDS ${STATIC_ASSETS_OUT})
149
150# this target makes sure that assets are minified in debug builds, even if they aren't used
151add_custom_target(minifyassets ALL DEPENDS ${MINIFIED_ASSETS_OUT})
152
Ed Tanous904063f2017-03-02 16:48:24 -0800153
Ed Tanous9b65f1f2017-03-07 15:17:13 -0800154file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/generated)
155
Ed Tanous904063f2017-03-02 16:48:24 -0800156set(CXX_STATIC_ASSETS_OUTPUT_FILE ${CMAKE_BINARY_DIR}/generated/webassets.cpp)
157set(WEBASSET_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/../scripts/build_web_assets.py")
158
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700159if (CMAKE_BUILD_TYPE STREQUAL "Debug")
160 set(DEBUG_MODE "-d")
161endif()
162
Ed Tanous904063f2017-03-02 16:48:24 -0800163add_custom_command(OUTPUT ${CXX_STATIC_ASSETS_OUTPUT_FILE}
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700164 COMMAND ${WEBASSET_SCRIPT} ${DEBUG_MODE}
Ed Tanous904063f2017-03-02 16:48:24 -0800165 -o ${CXX_STATIC_ASSETS_OUTPUT_FILE} -i ${STATIC_ASSETS_OUT}
166
167 DEPENDS ${STATIC_ASSETS_OUT} ${WEBASSET_SCRIPT}
168 COMMENT "Building CPP file ${CXX_STATIC_ASSETS_OUTPUT_FILE}"
169)
170
171add_custom_target(packagestaticcpp ALL DEPENDS ${CXX_STATIC_ASSETS_OUTPUT_FILE})