-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/openshwprojects/OpenBK7231T…
…_App # Conflicts: # src/cmnds/cmd_eventHandlers.c # src/driver/drv_tuyaMCU.c
- Loading branch information
Showing
40 changed files
with
15,477 additions
and
4,988 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"recommendations": [ | ||
"ms-vscode.cpptools" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"editor.formatOnPaste": true, | ||
"editor.formatOnSave": true, | ||
"C_Cpp.formatting": "vcFormat", | ||
"C_Cpp.codeAnalysis.runAutomatically": false, | ||
"C_Cpp.clang_format_style": "{ BasedOnStyle: LLVM, UseTab: Always, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Attach, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0, AccessModifierOffset: -4, NamespaceIndentation: All, FixNamespaceComments: false }", | ||
"C_Cpp.autocompleteAddParentheses": true, | ||
"files.exclude": { | ||
"**/*.o": true, | ||
"node_modules": true | ||
}, | ||
"editor.insertSpaces": false, | ||
"editor.tabSize": 4, | ||
"editor.detectIndentation": false, | ||
"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: LLVM, UseTab: Always, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Attach, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0, AccessModifierOffset: -4, NamespaceIndentation: All, FixNamespaceComments: false }" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
const gulp = require("gulp"); | ||
const uglify = require("gulp-uglify"); | ||
const cssnano = require("gulp-cssnano"); | ||
const through = require("through2"); | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
const readline = require("readline"); | ||
|
||
const destination = "new_http.c"; | ||
|
||
function dumpFileSize() { | ||
return through.obj(function (file, enc, cb) { | ||
console.log( | ||
`Processing ${file.basename}, original length ${file.stat.size}` | ||
); | ||
cb(null, file); | ||
}); | ||
} | ||
|
||
/** This function injects C for a const field in new_http.c */ | ||
function generateCode(field_name, is_script) { | ||
return through.obj(function (file, enc, cb) { | ||
if (file.isBuffer()) { | ||
const contents = file.contents; | ||
|
||
let output = String(contents); | ||
output = output.replace(/\"/g, '\\"'); | ||
console.log( | ||
`Processing ${file.basename}, reduced length ${contents.length}` | ||
); | ||
|
||
const prefix = is_script ? "<script type='text/javascript'>" : "<style>"; | ||
const suffix = is_script ? "</script>" : "</style>"; | ||
output = `const char ${field_name}[] = "${prefix}${output}${suffix}";`; | ||
|
||
const target_path = path.join(path.dirname(file.path), destination); | ||
//console.log(`Updated ${target_path}`); | ||
|
||
const rl = readline.createInterface({ | ||
input: fs.createReadStream(target_path), | ||
crlfDelay: Infinity, | ||
}); | ||
|
||
const merged_contents = []; | ||
const marker_start = `//region_start ${field_name}`; | ||
const marker_end = `//region_end ${field_name}`; | ||
let region_state = 0; | ||
|
||
rl.on("line", (line) => { | ||
if (line.trim() === marker_start) { | ||
region_state = 1; | ||
merged_contents.push(marker_start); | ||
merged_contents.push(output); | ||
merged_contents.push(marker_end); | ||
} else { | ||
//Skip all existing content lines till region ends | ||
if (region_state === 1) { | ||
if (line.trim() === marker_end) { | ||
region_state = 2; | ||
} | ||
} else { | ||
merged_contents.push(line); | ||
} | ||
} | ||
}); | ||
|
||
rl.on("close", () => { | ||
if (region_state === 0) { | ||
//Starting marker was not found, append | ||
|
||
merged_contents.push(""); | ||
merged_contents.push(marker_start); | ||
merged_contents.push(output); | ||
merged_contents.push(marker_end); | ||
} | ||
|
||
if (region_state === 1) { | ||
cb(`Ending marker "${marker_end}" was not found.`, file); | ||
} else { | ||
fs.writeFile( | ||
target_path, | ||
merged_contents.join("\r\n"), | ||
"utf8", | ||
(err) => { | ||
cb(err, file); | ||
} | ||
); | ||
} | ||
}); | ||
|
||
return; | ||
} | ||
|
||
cb(null, file); | ||
}); | ||
} | ||
|
||
function minifyJs() { | ||
return gulp | ||
.src("./src/httpserver/script.js") | ||
.pipe(dumpFileSize()) | ||
.pipe(uglify()) | ||
.pipe(generateCode("pageScript", true)); | ||
} | ||
|
||
function minifyHassDiscoveryJs() { | ||
return gulp | ||
.src("./src/httpserver/script_ha_discovery.js") | ||
.pipe(dumpFileSize()) | ||
.pipe(uglify()) | ||
.pipe(generateCode("ha_discovery_script", true)); | ||
} | ||
|
||
function minifyCss() { | ||
return gulp | ||
.src("./src/httpserver/style.css") | ||
.pipe(dumpFileSize()) | ||
.pipe(cssnano()) | ||
.pipe(generateCode("htmlHeadStyle", false)); | ||
} | ||
|
||
exports.default = gulp.series(minifyJs, minifyHassDiscoveryJs, minifyCss); |
Oops, something went wrong.