blob: 6e5bc2b5bd358e4470c110df99a1bb83629cd1b4 [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 Tanousd4649872017-06-20 10:24:35 -070073find_program(UGLIFY_MINIFIER uglifyjs)
Ed Tanous1e1e38c2017-06-19 16:01:33 -070074if(NOT UGLIFY_MINIFIER)
75 message("uglifyjs not found")
Ed Tanous5fceeb42017-06-28 09:43:09 -070076else()
77 message("Found ${UGLIFY_MINIFIER}")
Ed Tanous1e1e38c2017-06-19 16:01:33 -070078endif()
Ed Tanous904063f2017-03-02 16:48:24 -080079foreach(JAVASCRIPT_ASSET ${JAVASCRIPT_ASSETS})
Ed Tanous93f987d2017-04-17 17:52:36 -070080
81 set(MINIFIED_FILENAME ${CMAKE_CURRENT_BINARY_DIR}/${JAVASCRIPT_ASSET})
82 get_filename_component(FOLDERNAME ${MINIFIED_FILENAME} DIRECTORY)
83 # string(REGEX REPLACE "(\\.[^.]*$)" ".min\\1" OUTPUT_FILENAME ${OUTPUT_FILENAME})
84 file(MAKE_DIRECTORY "${FOLDERNAME}")
Ed Tanous7b4e3da2017-06-26 11:08:40 -070085 if(UGLIFY_MINIFIER)
86 add_custom_command(OUTPUT ${MINIFIED_FILENAME}
Ed Tanous5fceeb42017-06-28 09:43:09 -070087 COMMAND ${UGLIFY_MINIFIER} --compress --mangle
Ed Tanous7b4e3da2017-06-26 11:08:40 -070088 --output "${MINIFIED_FILENAME}"
89 "${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET}"
90 DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET}"
91 COMMENT "Minifying ${JAVASCRIPT_ASSET}"
92 )
93 list(APPEND MINIFIED_ASSETS_OUT ${MINIFIED_FILENAME})
94 endif(UGLIFY_MINIFIER)
95
Ed Tanous93f987d2017-04-17 17:52:36 -070096 # if it's a debug build, use the unminified version
Ed Tanous1e1e38c2017-06-19 16:01:33 -070097 if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT UGLIFY_MINIFIER)
Ed Tanous38bdb982017-03-03 14:19:33 -080098 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET})
99 else()
Ed Tanous93f987d2017-04-17 17:52:36 -0700100 list(APPEND STATIC_ASSETS_OUT ${MINIFIED_FILENAME})
Ed Tanous1e1e38c2017-06-19 16:01:33 -0700101 endif (CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT UGLIFY_MINIFIER)
Ed Tanous904063f2017-03-02 16:48:24 -0800102endforeach(JAVASCRIPT_ASSET)
103
Ed Tanousc9b55212017-06-12 13:25:51 -0700104
105find_program(CSS_MINIFIER cssnano)
106if(NOT CSS_MINIFIER)
107 message("cssnano not found")
Ed Tanous5fceeb42017-06-28 09:43:09 -0700108else()
109 message("Found ${CSS_MINIFIER}")
Ed Tanousc9b55212017-06-12 13:25:51 -0700110endif()
Ed Tanous38bdb982017-03-03 14:19:33 -0800111# for now CSS is included as is
112foreach(CSS_ASSET ${CSS_ASSETS})
Ed Tanous93f987d2017-04-17 17:52:36 -0700113 set(MINIFIED_FILENAME ${CMAKE_CURRENT_BINARY_DIR}/${CSS_ASSET})
114 get_filename_component(FOLDERNAME ${MINIFIED_FILENAME} DIRECTORY)
115 file(MAKE_DIRECTORY "${FOLDERNAME}")
Ed Tanous1e1e38c2017-06-19 16:01:33 -0700116 if(CSS_MINIFIER)
Ed Tanousc9b55212017-06-12 13:25:51 -0700117 add_custom_command(OUTPUT ${MINIFIED_FILENAME}
Ed Tanous5fceeb42017-06-28 09:43:09 -0700118 COMMAND ${CSS_MINIFIER}
Ed Tanousc9b55212017-06-12 13:25:51 -0700119 "${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET}"
120 "${CMAKE_CURRENT_BINARY_DIR}/${CSS_ASSET}"
Ed Tanous93f987d2017-04-17 17:52:36 -0700121
Ed Tanousc9b55212017-06-12 13:25:51 -0700122 DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET}"
123 COMMENT "Minifying ${CSS_ASSET}"
124 )
125 list(APPEND MINIFIED_ASSETS_OUT ${MINIFIED_FILENAME})
126 endif()
Ed Tanous93f987d2017-04-17 17:52:36 -0700127 # if it's a debug build, use the unminified version
Ed Tanousc9b55212017-06-12 13:25:51 -0700128 if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT CSS_MINIFIER)
Ed Tanousc4771fb2017-03-13 13:39:49 -0700129 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET})
130 else()
Ed Tanous93f987d2017-04-17 17:52:36 -0700131 list(APPEND STATIC_ASSETS_OUT ${MINIFIED_FILENAME})
Ed Tanousc9b55212017-06-12 13:25:51 -0700132 endif (CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT CSS_MINIFIER)
Ed Tanousc4771fb2017-03-13 13:39:49 -0700133
Ed Tanous38bdb982017-03-03 14:19:33 -0800134endforeach(CSS_ASSET)
135
136# for now HTML is included as is
137foreach(HTML_ASSET ${HTML_ASSETS})
138 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${HTML_ASSET})
139endforeach(HTML_ASSET)
140
141# for now IMG is included as is
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700142foreach(OTHER_ASSET ${OTHER_ASSETS})
143 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${OTHER_ASSET})
144endforeach(OTHER_ASSET)
Ed Tanous38bdb982017-03-03 14:19:33 -0800145
Ed Tanous93f987d2017-04-17 17:52:36 -0700146# this taret is the dependency that the build script uses to make sure everything is available
147add_custom_target(buildstatic ALL DEPENDS ${STATIC_ASSETS_OUT})
148
149# this target makes sure that assets are minified in debug builds, even if they aren't used
150add_custom_target(minifyassets ALL DEPENDS ${MINIFIED_ASSETS_OUT})
151
Ed Tanous904063f2017-03-02 16:48:24 -0800152
Ed Tanous9b65f1f2017-03-07 15:17:13 -0800153file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/generated)
154
Ed Tanous904063f2017-03-02 16:48:24 -0800155set(CXX_STATIC_ASSETS_OUTPUT_FILE ${CMAKE_BINARY_DIR}/generated/webassets.cpp)
156set(WEBASSET_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/../scripts/build_web_assets.py")
157
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700158if (CMAKE_BUILD_TYPE STREQUAL "Debug")
159 set(DEBUG_MODE "-d")
160endif()
161
Ed Tanous904063f2017-03-02 16:48:24 -0800162add_custom_command(OUTPUT ${CXX_STATIC_ASSETS_OUTPUT_FILE}
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700163 COMMAND ${WEBASSET_SCRIPT} ${DEBUG_MODE}
Ed Tanous904063f2017-03-02 16:48:24 -0800164 -o ${CXX_STATIC_ASSETS_OUTPUT_FILE} -i ${STATIC_ASSETS_OUT}
165
166 DEPENDS ${STATIC_ASSETS_OUT} ${WEBASSET_SCRIPT}
167 COMMENT "Building CPP file ${CXX_STATIC_ASSETS_OUTPUT_FILE}"
168)
169
170add_custom_target(packagestaticcpp ALL DEPENDS ${CXX_STATIC_ASSETS_OUTPUT_FILE})