blob: 8011e6eb926965ece492173558cded8194bd74f4 [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}
79 COMMAND closure-compiler --language_in=ECMASCRIPT5
80 --js "${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET}"
81 --js_output_file "${MINIFIED_FILENAME}"
82 --compilation_level SIMPLE_OPTIMIZATIONS
83 --angular_pass
84 DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET}"
85 COMMENT "Minifying ${JAVASCRIPT_ASSET}"
86 )
87
88
89 list(APPEND MINIFIED_ASSETS_OUT ${MINIFIED_FILENAME})
90 # if it's a debug build, use the unminified version
Ed Tanous1ccd57c2017-03-21 13:15:58 -070091 if (CMAKE_BUILD_TYPE STREQUAL "Debug")
Ed Tanous38bdb982017-03-03 14:19:33 -080092 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET})
93 else()
Ed Tanous93f987d2017-04-17 17:52:36 -070094 list(APPEND STATIC_ASSETS_OUT ${MINIFIED_FILENAME})
Ed Tanous1ccd57c2017-03-21 13:15:58 -070095 endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
Ed Tanous904063f2017-03-02 16:48:24 -080096endforeach(JAVASCRIPT_ASSET)
97
Ed Tanousc9b55212017-06-12 13:25:51 -070098
99find_program(CSS_MINIFIER cssnano)
100if(NOT CSS_MINIFIER)
101 message("cssnano not found")
102endif()
Ed Tanous38bdb982017-03-03 14:19:33 -0800103# for now CSS is included as is
104foreach(CSS_ASSET ${CSS_ASSETS})
Ed Tanous93f987d2017-04-17 17:52:36 -0700105 set(MINIFIED_FILENAME ${CMAKE_CURRENT_BINARY_DIR}/${CSS_ASSET})
106 get_filename_component(FOLDERNAME ${MINIFIED_FILENAME} DIRECTORY)
107 file(MAKE_DIRECTORY "${FOLDERNAME}")
Ed Tanousc9b55212017-06-12 13:25:51 -0700108 if(CSS_MINIFIER)
109 message(FATAL_ERROR "cssnano not found!")
110
111 add_custom_command(OUTPUT ${MINIFIED_FILENAME}
112 COMMAND cssnano
113 "${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET}"
114 "${CMAKE_CURRENT_BINARY_DIR}/${CSS_ASSET}"
Ed Tanous93f987d2017-04-17 17:52:36 -0700115
Ed Tanousc9b55212017-06-12 13:25:51 -0700116 DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET}"
117 COMMENT "Minifying ${CSS_ASSET}"
118 )
119 list(APPEND MINIFIED_ASSETS_OUT ${MINIFIED_FILENAME})
120 endif()
Ed Tanous93f987d2017-04-17 17:52:36 -0700121 # if it's a debug build, use the unminified version
Ed Tanousc9b55212017-06-12 13:25:51 -0700122 if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT CSS_MINIFIER)
Ed Tanousc4771fb2017-03-13 13:39:49 -0700123 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET})
124 else()
Ed Tanous93f987d2017-04-17 17:52:36 -0700125 list(APPEND STATIC_ASSETS_OUT ${MINIFIED_FILENAME})
Ed Tanousc9b55212017-06-12 13:25:51 -0700126 endif (CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT CSS_MINIFIER)
Ed Tanousc4771fb2017-03-13 13:39:49 -0700127
Ed Tanous38bdb982017-03-03 14:19:33 -0800128endforeach(CSS_ASSET)
129
130# for now HTML is included as is
131foreach(HTML_ASSET ${HTML_ASSETS})
132 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${HTML_ASSET})
133endforeach(HTML_ASSET)
134
135# for now IMG is included as is
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700136foreach(OTHER_ASSET ${OTHER_ASSETS})
137 list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${OTHER_ASSET})
138endforeach(OTHER_ASSET)
Ed Tanous38bdb982017-03-03 14:19:33 -0800139
Ed Tanous93f987d2017-04-17 17:52:36 -0700140# this taret is the dependency that the build script uses to make sure everything is available
141add_custom_target(buildstatic ALL DEPENDS ${STATIC_ASSETS_OUT})
142
143# this target makes sure that assets are minified in debug builds, even if they aren't used
144add_custom_target(minifyassets ALL DEPENDS ${MINIFIED_ASSETS_OUT})
145
Ed Tanous904063f2017-03-02 16:48:24 -0800146
Ed Tanous9b65f1f2017-03-07 15:17:13 -0800147file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/generated)
148
Ed Tanous904063f2017-03-02 16:48:24 -0800149set(CXX_STATIC_ASSETS_OUTPUT_FILE ${CMAKE_BINARY_DIR}/generated/webassets.cpp)
150set(WEBASSET_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/../scripts/build_web_assets.py")
151
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700152if (CMAKE_BUILD_TYPE STREQUAL "Debug")
153 set(DEBUG_MODE "-d")
154endif()
155
Ed Tanous904063f2017-03-02 16:48:24 -0800156add_custom_command(OUTPUT ${CXX_STATIC_ASSETS_OUTPUT_FILE}
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700157 COMMAND ${WEBASSET_SCRIPT} ${DEBUG_MODE}
Ed Tanous904063f2017-03-02 16:48:24 -0800158 -o ${CXX_STATIC_ASSETS_OUTPUT_FILE} -i ${STATIC_ASSETS_OUT}
159
160 DEPENDS ${STATIC_ASSETS_OUT} ${WEBASSET_SCRIPT}
161 COMMENT "Building CPP file ${CXX_STATIC_ASSETS_OUTPUT_FILE}"
162)
163
164add_custom_target(packagestaticcpp ALL DEPENDS ${CXX_STATIC_ASSETS_OUTPUT_FILE})