mirror of
https://github.com/tsl0922/ttyd.git
synced 2025-12-21 19:34:19 +01:00
cmake: remove xxd dependency
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -48,5 +48,4 @@ build
|
||||
.idea/
|
||||
|
||||
# Project files
|
||||
html.h
|
||||
!init.d
|
||||
|
||||
@@ -59,13 +59,6 @@ find_library(LIBUV_LIBRARIES NAMES uv libuv HINTS ${PC_LIBUV_LIBDIR})
|
||||
find_package_handle_standard_args(LIBUV DEFAULT_MSG LIBUV_LIBRARIES LIBUV_INCLUDE_DIRS)
|
||||
mark_as_advanced(LIBUV_INCLUDE_DIRS LIBUV_LIBRARIES)
|
||||
|
||||
find_program(CMAKE_XXD NAMES xxd)
|
||||
add_custom_command(OUTPUT html.h
|
||||
COMMAND ${CMAKE_XXD} -i index.html html.h
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src
|
||||
COMMENT "Generating html.h from index.html")
|
||||
list(APPEND SOURCE_FILES html.h)
|
||||
|
||||
set(INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR} ${LIBWEBSOCKETS_INCLUDE_DIRS} ${JSON-C_INCLUDE_DIRS} ${LIBUV_INCLUDE_DIRS})
|
||||
set(LINK_LIBS ${OPENSSL_LIBRARIES} ${LIBWEBSOCKETS_LIBRARIES} ${JSON-C_LIBRARIES} ${LIBUV_LIBRARIES})
|
||||
|
||||
|
||||
@@ -9,4 +9,4 @@ install [Yarn](https://yarnpkg.com), and run: `yarn install`.
|
||||
|
||||
## Publish
|
||||
|
||||
Run `yarn run build`, this will compile the inlined html to `../src/index.html`.
|
||||
Run `yarn run build`, this will compile the inlined html to `../src/html.h`.
|
||||
|
||||
@@ -1,6 +1,39 @@
|
||||
const { src, dest, task } = require("gulp");
|
||||
const clean = require('gulp-clean');
|
||||
const inlinesource = require('gulp-inline-source');
|
||||
const inlineSource = require('gulp-inline-source');
|
||||
const rename = require("gulp-rename");
|
||||
const through = require('through2');
|
||||
|
||||
const toCHeader = () => {
|
||||
return through.obj((file, enc, cb) => {
|
||||
const buf = file.contents;
|
||||
const len = buf.length;
|
||||
let idx = 0;
|
||||
let data = "unsigned char index_html[] = {\n ";
|
||||
|
||||
for (const value of buf) {
|
||||
idx++;
|
||||
|
||||
let current = value < 0 ? value + 256 : value;
|
||||
|
||||
data += "0x";
|
||||
data += (current >>> 4).toString(16);
|
||||
data += (current & 0xF).toString(16);
|
||||
|
||||
if (idx === len) {
|
||||
data += "\n";
|
||||
} else {
|
||||
data += idx % 12 === 0 ? ",\n " : ", ";
|
||||
}
|
||||
}
|
||||
|
||||
data += "};\n";
|
||||
data += `unsigned int index_html_len = ${len};\n`;
|
||||
file.contents = Buffer.from(data);
|
||||
|
||||
return cb(null, file);
|
||||
});
|
||||
};
|
||||
|
||||
task('clean', () => {
|
||||
return src('dist', {read: false, allowEmpty: true})
|
||||
@@ -9,6 +42,8 @@ task('clean', () => {
|
||||
|
||||
task('default', () => {
|
||||
return src('dist/index.html')
|
||||
.pipe(inlinesource())
|
||||
.pipe(inlineSource())
|
||||
.pipe(toCHeader())
|
||||
.pipe(rename("html.h"))
|
||||
.pipe(dest('../src/'));
|
||||
});
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-clean": "^0.4.0",
|
||||
"gulp-inline-source": "^4.0.0",
|
||||
"gulp-rename": "^2.0.0",
|
||||
"html-webpack-plugin": "^3.2.0",
|
||||
"husky": "^4.0.6",
|
||||
"lint-staged": "^10.0.3",
|
||||
@@ -48,6 +49,7 @@
|
||||
"scssfmt": "^1.0.7",
|
||||
"style-loader": "^1.0.1",
|
||||
"terser-webpack-plugin": "^2.2.2",
|
||||
"through2": "^3.0.1",
|
||||
"ts-loader": "^6.2.1",
|
||||
"tslint": "^5.20.1",
|
||||
"tslint-loader": "^3.5.4",
|
||||
|
||||
@@ -3291,6 +3291,11 @@ gulp-inline-source@^4.0.0:
|
||||
plugin-error "~1.0.1"
|
||||
through2 "~2.0.0"
|
||||
|
||||
gulp-rename@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/gulp-rename/-/gulp-rename-2.0.0.tgz#9bbc3962b0c0f52fc67cd5eaff6c223ec5b9cf6c"
|
||||
integrity sha512-97Vba4KBzbYmR5VBs9mWmK+HwIf5mj+/zioxfZhOKeXtx5ZjBk57KFlePf5nxq9QsTtFl0ejnHE3zTC9MHXqyQ==
|
||||
|
||||
gulp@^4.0.2:
|
||||
version "4.0.2"
|
||||
resolved "https://registry.yarnpkg.com/gulp/-/gulp-4.0.2.tgz#543651070fd0f6ab0a0650c6a3e6ff5a7cb09caa"
|
||||
@@ -6502,6 +6507,15 @@ read-pkg@^3.0.0:
|
||||
string_decoder "~1.1.1"
|
||||
util-deprecate "~1.0.1"
|
||||
|
||||
"readable-stream@2 || 3":
|
||||
version "3.5.0"
|
||||
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.5.0.tgz#465d70e6d1087f6162d079cd0b5db7fbebfd1606"
|
||||
integrity sha512-gSz026xs2LfxBPudDuI41V1lka8cxg64E66SGe78zJlsUofOg/yqwezdIcdfwik6B4h8LFmWPA9ef9X3FiNFLA==
|
||||
dependencies:
|
||||
inherits "^2.0.3"
|
||||
string_decoder "^1.1.1"
|
||||
util-deprecate "^1.0.1"
|
||||
|
||||
readable-stream@^3.0.6, readable-stream@^3.1.1, readable-stream@^3.4.0:
|
||||
version "3.4.0"
|
||||
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.4.0.tgz#a51c26754658e0a3c21dbf59163bd45ba6f447fc"
|
||||
@@ -7730,6 +7744,13 @@ through2@^2.0.0, through2@^2.0.3, through2@~2.0.0:
|
||||
readable-stream "~2.3.6"
|
||||
xtend "~4.0.1"
|
||||
|
||||
through2@^3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/through2/-/through2-3.0.1.tgz#39276e713c3302edf9e388dd9c812dd3b825bd5a"
|
||||
integrity sha512-M96dvTalPT3YbYLaKaCuwu+j06D/8Jfib0o/PxbVt6Amhv3dUAtW6rTV1jPgJSBG83I/e04Y6xkVdVhSRhi0ww==
|
||||
dependencies:
|
||||
readable-stream "2 || 3"
|
||||
|
||||
through@^2.3.6:
|
||||
version "2.3.8"
|
||||
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
|
||||
|
||||
34000
src/html.h
Normal file
34000
src/html.h
Normal file
File diff suppressed because it is too large
Load Diff
1
src/index.html
vendored
1
src/index.html
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user