mirror of
https://github.com/msojocs/wechat-web-devtools-linux.git
synced 2025-07-22 00:00:04 +08:00
feat: 编译器支持wxml引用
This commit is contained in:
parent
a9446efa16
commit
bbfa5b6dc5
File diff suppressed because one or more lines are too long
1416
compiler/test/wcc/lla/3/linux_output.js
Normal file
1416
compiler/test/wcc/lla/3/linux_output.js
Normal file
File diff suppressed because it is too large
Load Diff
8
compiler/test/wcc/lla/3/log.md
Normal file
8
compiler/test/wcc/lla/3/log.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
x 大小13
|
||||||
|
|
||||||
|
引用文件 6,7 下标5,6
|
||||||
|
9,10
|
||||||
|
|
||||||
|
m0 - m9
|
||||||
|
|
||||||
|
gz1 - gz11
|
30
compiler/test/wcc/lla/3/node_output.json
Normal file
30
compiler/test/wcc/lla/3/node_output.json
Normal file
File diff suppressed because one or more lines are too long
26
compiler/test/wcc/lla/3/wine_output.json
Normal file
26
compiler/test/wcc/lla/3/wine_output.json
Normal file
File diff suppressed because one or more lines are too long
134
compiler/test/wcc/lla/lla3.js
Normal file
134
compiler/test/wcc/lla/lla3.js
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
const { spawn, spawnSync } = require("child_process");
|
||||||
|
const path = require("path");
|
||||||
|
const fs = require("fs");
|
||||||
|
const { exit } = require("process");
|
||||||
|
|
||||||
|
const projectPath = "/mnt/disk1/WeChatProjects/miniprogram-demo/miniprogram/";
|
||||||
|
const config = [
|
||||||
|
"-d",
|
||||||
|
"--split",
|
||||||
|
">_<109",
|
||||||
|
"-xc",
|
||||||
|
"9>_<109./miniprogram_npm/miniprogram-barrage/index.wxml>_<1090>_<109./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml>_<1090>_<109./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml>_<1090>_<109./miniprogram_npm/wxml-to-canvas/index.wxml>_<1090>_<109./page/API/index.wxml>_<1091>_<109set-tab-bar>_<109./page/API/components/set-tab-bar/set-tab-bar.wxml>_<1090>_<109./page/cloud/index.wxml>_<1090>_<109./page/component/index.wxml>_<1090>_<109./page/extend/index.wxml>_<1090",
|
||||||
|
"-lla",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index>_<109./miniprogram_npm/miniprogram-recycle-view/recycle-item>_<109./miniprogram_npm/miniprogram-recycle-view/recycle-view>_<109./miniprogram_npm/wxml-to-canvas/index>_<109./page/API/index>_<109./page/API/components/set-tab-bar/set-tab-bar>_<109./page/cloud/index>_<109./page/component/index>_<109./page/extend/index",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxml",
|
||||||
|
"./page/API/index.wxml",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxml",
|
||||||
|
"./page/cloud/index.wxml",
|
||||||
|
"./page/common/foot.wxml",
|
||||||
|
"./page/common/head.wxml",
|
||||||
|
"./page/component/index.wxml",
|
||||||
|
"./page/extend/index.wxml",
|
||||||
|
"-gn",
|
||||||
|
"$gwx",
|
||||||
|
];
|
||||||
|
|
||||||
|
const test_wine = () => {
|
||||||
|
const wine = spawn(
|
||||||
|
path.resolve(__dirname, "../../../../package.nw/js/vendor/wcc.exe"),
|
||||||
|
config,
|
||||||
|
{
|
||||||
|
cwd: projectPath,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const spwanData = [],
|
||||||
|
errData = [];
|
||||||
|
wine.stdout.on("data", (e) => {
|
||||||
|
spwanData.push(e);
|
||||||
|
});
|
||||||
|
wine.stderr.on("data", (e) => {
|
||||||
|
errData.push(e);
|
||||||
|
});
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
wine.on("close", (n) => {
|
||||||
|
console.log("wine n: ", n);
|
||||||
|
if (0 === n) {
|
||||||
|
let result = Buffer.concat(spwanData).toString();
|
||||||
|
result = JSON.parse(result);
|
||||||
|
// result = result.generateFunctionContent["__COMMON__"];
|
||||||
|
// delete result.generateFunctionContent["__COMMON__"];
|
||||||
|
result = JSON.stringify(result, null, 4)
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.resolve(__dirname, "./3/wine_output.json"),
|
||||||
|
result
|
||||||
|
);
|
||||||
|
// process.stdout.write(result);
|
||||||
|
resolve(result);
|
||||||
|
} else {
|
||||||
|
process.stderr.write(
|
||||||
|
"wine error:",
|
||||||
|
Buffer.concat(errData).toString()
|
||||||
|
);
|
||||||
|
// process.stderr.write(Buffer.concat(spwanData).toString());
|
||||||
|
reject(n);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const test_node = () => {
|
||||||
|
const node_exec = spawn(
|
||||||
|
path.resolve(__dirname, "../../../nodejs/wcc"),
|
||||||
|
config,
|
||||||
|
{
|
||||||
|
cwd: projectPath,
|
||||||
|
env: {
|
||||||
|
WX_DEBUG_COMPILER_OUTPUT: path.resolve(__dirname, "./3"),
|
||||||
|
},
|
||||||
|
// stdio: 'inherit'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const spwanData = [],
|
||||||
|
errData = [];
|
||||||
|
node_exec.stdout.on("data", (e) => {
|
||||||
|
spwanData.push(e);
|
||||||
|
// console.log(e.toString())
|
||||||
|
});
|
||||||
|
node_exec.stderr.on("data", (e) => {
|
||||||
|
errData.push(e);
|
||||||
|
// console.log(e.toString())
|
||||||
|
});
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
node_exec.on("close", (n) => {
|
||||||
|
console.log("node n: ", n);
|
||||||
|
if (0 === n) {
|
||||||
|
let result = Buffer.concat(spwanData).toString();
|
||||||
|
// require('fs').writeFileSync('/mnt/disk2/wechat-web-devtools-linux/tmp/llw2.json', result)
|
||||||
|
// process.stdout.write(result);
|
||||||
|
result = JSON.parse(result);
|
||||||
|
// fs.writeFileSync(
|
||||||
|
// path.resolve(__dirname, "./3/node_output1.json"),
|
||||||
|
// JSON.stringify(result, null, 4)
|
||||||
|
// );
|
||||||
|
// result = result.generateFunctionContent["__COMMON__"];
|
||||||
|
// delete result.generateFunctionContent["__COMMON__"];
|
||||||
|
result = JSON.stringify(result, null, 4)
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.resolve(__dirname, "./3/node_output.json"),
|
||||||
|
result
|
||||||
|
);
|
||||||
|
resolve(result);
|
||||||
|
} else {
|
||||||
|
process.stderr.write(Buffer.concat(errData).toString());
|
||||||
|
// process.stderr.write(Buffer.concat(spwanData).toString());
|
||||||
|
reject(n);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const test = async () => {
|
||||||
|
try {
|
||||||
|
const node_result = await test_node();
|
||||||
|
const wine_result = await test_wine();
|
||||||
|
console.log("结果是否一致:", wine_result.trim() === node_result);
|
||||||
|
} catch (err) {
|
||||||
|
console.error("错误:", err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
test();
|
59
compiler/test/wcc/lla/t.js
Normal file
59
compiler/test/wcc/lla/t.js
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
var x = [
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxml",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxml",
|
||||||
|
|
||||||
|
"../../../common/head.wxml",
|
||||||
|
"../../../common/foot.wxml",
|
||||||
|
"./page/API/index.wxml",
|
||||||
|
"./page/cloud/index.wxml",
|
||||||
|
"./page/common/foot.wxml",
|
||||||
|
|
||||||
|
"./page/common/head.wxml",
|
||||||
|
"./page/component/index.wxml",
|
||||||
|
"./page/extend/index.wxml",
|
||||||
|
];
|
||||||
|
const config = {
|
||||||
|
num: 4,
|
||||||
|
};
|
||||||
|
let content = "";
|
||||||
|
const funcName = "$gwx";
|
||||||
|
const source = fs
|
||||||
|
.readFileSync(path.resolve(__dirname, "./3/linux_output.js"))
|
||||||
|
.toString();
|
||||||
|
console.log(
|
||||||
|
path.join(
|
||||||
|
path.dirname("./page/API/components/set-tab-bar/set-tab-bar.wxml"),
|
||||||
|
"../../../common/head.wxml"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
// "./page/common/head.wxml"
|
||||||
|
process.exit(0);
|
||||||
|
// 引入解析
|
||||||
|
const deps = source.matchAll(/_ai\(.*?,x\[(\d+)\],.*?,x\[(\d+)\],\d+,\d+\)/g);
|
||||||
|
console.log(deps);
|
||||||
|
for (let dep of deps) {
|
||||||
|
console.log(dep[0]);
|
||||||
|
console.log(dep[1]);
|
||||||
|
console.log(dep[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// gz函数2
|
||||||
|
const exp = `function gz\\${funcName}_${
|
||||||
|
config.num + 1
|
||||||
|
}\\(\\)\\{[\\s\\S]*?__WXML_GLOBAL__\\.ops_cached\\.\\${funcName}_${
|
||||||
|
config.num + 1
|
||||||
|
}\n}`;
|
||||||
|
|
||||||
|
// console.log('exp --- ', exp)
|
||||||
|
const gz = source.match(new RegExp(exp));
|
||||||
|
// console.log(gz)
|
||||||
|
content += gz[0].replace(
|
||||||
|
new RegExp(`\\${funcName}\\_\\d+`, "g"),
|
||||||
|
`${config.funcName}_1`
|
||||||
|
);
|
2407
compiler/test/wcc/llw/3/linux_output.js
Normal file
2407
compiler/test/wcc/llw/3/linux_output.js
Normal file
File diff suppressed because it is too large
Load Diff
6
compiler/test/wcc/llw/3/log.md
Normal file
6
compiler/test/wcc/llw/3/log.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
x 元素个数:13
|
||||||
|
第6、7 npm 下标5、6
|
||||||
|
|
||||||
|
gz1 - gz11
|
||||||
|
m0 - m10
|
||||||
|
XC_0 - XC_
|
27
compiler/test/wcc/llw/3/node_output.json
Normal file
27
compiler/test/wcc/llw/3/node_output.json
Normal file
File diff suppressed because one or more lines are too long
27
compiler/test/wcc/llw/3/wine_output.json
Normal file
27
compiler/test/wcc/llw/3/wine_output.json
Normal file
File diff suppressed because one or more lines are too long
130
compiler/test/wcc/llw/llw3.js
Normal file
130
compiler/test/wcc/llw/llw3.js
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
const { spawn, spawnSync } = require("child_process");
|
||||||
|
const path = require("path");
|
||||||
|
const fs = require("fs");
|
||||||
|
const { exit } = require("process");
|
||||||
|
|
||||||
|
const projectPath = "/mnt/disk1/WeChatProjects/miniprogram-demo/miniprogram/";
|
||||||
|
const config = [
|
||||||
|
"-d",
|
||||||
|
"--split",
|
||||||
|
">_<4685",
|
||||||
|
"-cc",
|
||||||
|
"9>_<4685./miniprogram_npm/miniprogram-barrage/index.wxml>_<46850>_<4685./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml>_<46850>_<4685./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml>_<46850>_<4685./miniprogram_npm/wxml-to-canvas/index.wxml>_<46850>_<4685./page/API/index.wxml>_<46851>_<4685set-tab-bar>_<4685./page/API/components/set-tab-bar/set-tab-bar.wxml>_<46850>_<4685./page/cloud/index.wxml>_<46850>_<4685./page/component/index.wxml>_<46850>_<4685./page/extend/index.wxml>_<46850",
|
||||||
|
"-llw",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index>_<4685./miniprogram_npm/miniprogram-recycle-view/recycle-item>_<4685./miniprogram_npm/miniprogram-recycle-view/recycle-view>_<4685./miniprogram_npm/wxml-to-canvas/index>_<4685./page/API/index>_<4685./page/API/components/set-tab-bar/set-tab-bar>_<4685./page/cloud/index>_<4685./page/component/index>_<4685./page/extend/index",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxml",
|
||||||
|
"./page/API/index.wxml",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxml",
|
||||||
|
"./page/cloud/index.wxml",
|
||||||
|
"./page/common/foot.wxml",
|
||||||
|
"./page/common/head.wxml",
|
||||||
|
"./page/component/index.wxml",
|
||||||
|
"./page/extend/index.wxml",
|
||||||
|
"-gn",
|
||||||
|
"$gwx",
|
||||||
|
];
|
||||||
|
|
||||||
|
const test_wine = () => {
|
||||||
|
const wine = spawn(
|
||||||
|
path.resolve(__dirname, "../../../../package.nw/js/vendor/wcc.exe"),
|
||||||
|
config,
|
||||||
|
{
|
||||||
|
cwd: projectPath,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const spwanData = [],
|
||||||
|
errData = [];
|
||||||
|
wine.stdout.on("data", (e) => {
|
||||||
|
spwanData.push(e);
|
||||||
|
});
|
||||||
|
wine.stderr.on("data", (e) => {
|
||||||
|
errData.push(e);
|
||||||
|
});
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
wine.on("close", (n) => {
|
||||||
|
console.log("wine n: ", n);
|
||||||
|
if (0 === n) {
|
||||||
|
let result = Buffer.concat(spwanData).toString();
|
||||||
|
result = JSON.parse(result);
|
||||||
|
// delete result.generateFunctionContent["__COMMON__"];
|
||||||
|
result = JSON.stringify(result, null, 4)
|
||||||
|
// result = result.generateFunctionContent["__COMMON__"];
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.resolve(__dirname, "./3/wine_output.json"),
|
||||||
|
result
|
||||||
|
);
|
||||||
|
// process.stdout.write(result);
|
||||||
|
resolve(result);
|
||||||
|
} else {
|
||||||
|
process.stderr.write(
|
||||||
|
"wine error:",
|
||||||
|
Buffer.concat(errData).toString()
|
||||||
|
);
|
||||||
|
// process.stderr.write(Buffer.concat(spwanData).toString());
|
||||||
|
reject(n);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const test_node = () => {
|
||||||
|
const node_exec = spawn(
|
||||||
|
path.resolve(__dirname, "../../../nodejs/wcc"),
|
||||||
|
config,
|
||||||
|
{
|
||||||
|
cwd: projectPath,
|
||||||
|
env: {
|
||||||
|
WX_DEBUG_COMPILER_OUTPUT: path.resolve(__dirname, "./3"),
|
||||||
|
},
|
||||||
|
// stdio: 'inherit'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const spwanData = [],
|
||||||
|
errData = [];
|
||||||
|
node_exec.stdout.on("data", (e) => {
|
||||||
|
spwanData.push(e);
|
||||||
|
// console.log(e.toString())
|
||||||
|
});
|
||||||
|
node_exec.stderr.on("data", (e) => {
|
||||||
|
errData.push(e);
|
||||||
|
// console.log(e.toString())
|
||||||
|
});
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
node_exec.on("close", (n) => {
|
||||||
|
console.log("node n: ", n);
|
||||||
|
if (0 === n) {
|
||||||
|
let result = Buffer.concat(spwanData).toString();
|
||||||
|
// require('fs').writeFileSync('/mnt/disk2/wechat-web-devtools-linux/tmp/llw2.json', result)
|
||||||
|
// process.stdout.write(result);
|
||||||
|
result = JSON.parse(result);
|
||||||
|
// delete result.generateFunctionContent["__COMMON__"];
|
||||||
|
result = JSON.stringify(result, null, 4)
|
||||||
|
// result = result.generateFunctionContent["__COMMON__"];
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.resolve(__dirname, "./3/node_output.json"),
|
||||||
|
result
|
||||||
|
);
|
||||||
|
resolve(result);
|
||||||
|
} else {
|
||||||
|
process.stderr.write(Buffer.concat(errData).toString());
|
||||||
|
// process.stderr.write(Buffer.concat(spwanData).toString());
|
||||||
|
reject(n);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const test = async () => {
|
||||||
|
try {
|
||||||
|
const node_result = await test_node();
|
||||||
|
const wine_result = await test_wine();
|
||||||
|
console.log("结果是否一致:", wine_result.trim() === node_result);
|
||||||
|
} catch (err) {
|
||||||
|
console.error("错误:", err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
test();
|
16
compiler/test/wcc/llw/t.js
Normal file
16
compiler/test/wcc/llw/t.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
|
|
||||||
|
var x=['./miniprogram_npm/miniprogram-barrage/index.wxml','./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml','./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml','./miniprogram_npm/wxml-to-canvas/index.wxml','./page/API/components/set-tab-bar/set-tab-bar.wxml','../../../common/head.wxml','../../../common/foot.wxml','./page/API/index.wxml','./page/cloud/index.wxml','./page/common/foot.wxml','./page/common/head.wxml','./page/component/index.wxml','./page/extend/index.wxml'];
|
||||||
|
const config = {
|
||||||
|
num: 4
|
||||||
|
}
|
||||||
|
const source = fs.readFileSync(path.resolve(__dirname, './3/linux_output.js')).toString()
|
||||||
|
const m0Exp = `var m${config.num}=function\\(e,s,r,gg\\){[\\s\\S]*{f:m${config.num},j:\\[.*?\\],i:\\[.*?\\],ti:\\[(.*?)\\],ic:\\[.*?\\]}`
|
||||||
|
console.log('exp --- ', m0Exp)
|
||||||
|
let m0 = source.match(new RegExp(m0Exp))
|
||||||
|
const compIndex = m0[1].match(/\d+/g)
|
||||||
|
console.log(compIndex)
|
||||||
|
for(let index of compIndex)
|
||||||
|
console.log(x[index])
|
||||||
|
m0 = m0[0].replace(new RegExp(`m${config.num}`, 'g'), 'm0').replace(new RegExp(`x\\[${config.num}\\]`, 'g'), 'x[0]')
|
@ -110,16 +110,6 @@ const test_wine = () => {
|
|||||||
};
|
};
|
||||||
const test_node = () => {
|
const test_node = () => {
|
||||||
|
|
||||||
// const node_exec1 = spawnSync(
|
|
||||||
// path.resolve(__dirname, "../../compiler/nodejs/wcc"),
|
|
||||||
// config,
|
|
||||||
// {
|
|
||||||
// cwd: projectPath,
|
|
||||||
// // stdio: 'inherit'
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
// console.log(node_exec1.stdout.toString())
|
|
||||||
// return
|
|
||||||
const node_exec = spawn(
|
const node_exec = spawn(
|
||||||
path.resolve(__dirname, "../../compiler/nodejs/wcc"),
|
path.resolve(__dirname, "../../compiler/nodejs/wcc"),
|
||||||
config,
|
config,
|
||||||
@ -155,44 +145,13 @@ const test_node = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// const node_exec = spawn(
|
|
||||||
// path.resolve(__dirname, "../../compiler/nodejs/wcc"),
|
|
||||||
// config,
|
|
||||||
// {
|
|
||||||
// cwd: projectPath,
|
|
||||||
// // stdio: 'inherit'
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
// const spwanData = [],
|
|
||||||
// errData = [];
|
|
||||||
// node_exec.stdout.on("data", (e) => {
|
|
||||||
// spwanData.push(e);
|
|
||||||
// console.log(e.toString())
|
|
||||||
// });
|
|
||||||
// node_exec.stderr.on("data", (e) => {
|
|
||||||
// errData.push(e);
|
|
||||||
// console.log(e.toString())
|
|
||||||
// });
|
|
||||||
// node_exec.on("close", (n) => {
|
|
||||||
// console.log("n: ", n);
|
|
||||||
// if (0 === n) {
|
|
||||||
// const result = Buffer.concat(spwanData).toString();
|
|
||||||
// require('fs').writeFileSync(path.resolve(__dirname, '../../tmp/llw2.json'), result)
|
|
||||||
// // process.stdout.write(result);
|
|
||||||
// } else {
|
|
||||||
// process.stderr.write(Buffer.concat(errData).toString());
|
|
||||||
// // process.stderr.write(Buffer.concat(spwanData).toString());
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
|
||||||
const test = async () => {
|
const test = async () => {
|
||||||
try {
|
try {
|
||||||
// const wine_result = await test_wine();
|
const wine_result = await test_wine();
|
||||||
const node_result = await test_node();
|
const node_result = await test_node();
|
||||||
|
console.log(wine_result === node_result)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error('错误:', err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
test();
|
test();
|
15
compiler/test/wcsc/3/node_output.json
Normal file
15
compiler/test/wcsc/3/node_output.json
Normal file
File diff suppressed because one or more lines are too long
15
compiler/test/wcsc/3/wine_output.json
Normal file
15
compiler/test/wcsc/3/wine_output.json
Normal file
File diff suppressed because one or more lines are too long
0
compiler/test/wcsc/compare/nodejs.json
Normal file
0
compiler/test/wcsc/compare/nodejs.json
Normal file
127
compiler/test/wcsc/ll3.js
Normal file
127
compiler/test/wcsc/ll3.js
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
const { spawn, spawnSync } = require("child_process");
|
||||||
|
const path = require("path");
|
||||||
|
const fs = require("fs");
|
||||||
|
const { exit } = require("process");
|
||||||
|
|
||||||
|
const projectPath = "/mnt/disk1/WeChatProjects/miniprogram-demo/miniprogram/";
|
||||||
|
const config = [
|
||||||
|
"-db",
|
||||||
|
"-pc",
|
||||||
|
"9",
|
||||||
|
"./page/component/index.wxss",
|
||||||
|
"./page/API/index.wxss",
|
||||||
|
"./page/cloud/index.wxss",
|
||||||
|
"./page/extend/index.wxss",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxss",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxss",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxss",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxss",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxss",
|
||||||
|
"./app.wxss",
|
||||||
|
"./common/lib/weui.wxss",
|
||||||
|
"./page/common/common.wxss",
|
||||||
|
"./page/common/index.wxss",
|
||||||
|
"./page/common/lib/weui.wxss",
|
||||||
|
];
|
||||||
|
|
||||||
|
const test_wine = () => {
|
||||||
|
const wine = spawn(
|
||||||
|
path.resolve(__dirname, "../../../package.nw/js/vendor/wcsc.exe"),
|
||||||
|
config,
|
||||||
|
{
|
||||||
|
cwd: projectPath,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const spwanData = [],
|
||||||
|
errData = [];
|
||||||
|
wine.stdout.on("data", (e) => {
|
||||||
|
spwanData.push(e);
|
||||||
|
});
|
||||||
|
wine.stderr.on("data", (e) => {
|
||||||
|
errData.push(e);
|
||||||
|
});
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
wine.on("close", (n) => {
|
||||||
|
console.log("wine n: ", n);
|
||||||
|
if (0 === n) {
|
||||||
|
let result = Buffer.concat(spwanData).toString();
|
||||||
|
result = JSON.parse(result);
|
||||||
|
// delete result.generateFunctionContent["__COMMON__"];
|
||||||
|
result = JSON.stringify(result, null, 4);
|
||||||
|
// result = result.generateFunctionContent["__COMMON__"];
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.resolve(__dirname, "./3/wine_output.json"),
|
||||||
|
result
|
||||||
|
);
|
||||||
|
// process.stdout.write(result);
|
||||||
|
resolve(result);
|
||||||
|
} else {
|
||||||
|
process.stderr.write(
|
||||||
|
"wine error:",
|
||||||
|
Buffer.concat(errData).toString()
|
||||||
|
);
|
||||||
|
// process.stderr.write(Buffer.concat(spwanData).toString());
|
||||||
|
reject(n);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const test_node = () => {
|
||||||
|
const node_exec = spawn(
|
||||||
|
path.resolve(__dirname, "../../nodejs/wcsc"),
|
||||||
|
config,
|
||||||
|
{
|
||||||
|
cwd: projectPath,
|
||||||
|
env: {
|
||||||
|
WX_DEBUG_COMPILER_OUTPUT: path.resolve(__dirname, "./3"),
|
||||||
|
},
|
||||||
|
// stdio: 'inherit'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const spwanData = [],
|
||||||
|
errData = [];
|
||||||
|
node_exec.stdout.on("data", (e) => {
|
||||||
|
spwanData.push(e);
|
||||||
|
// console.log(e.toString())
|
||||||
|
});
|
||||||
|
node_exec.stderr.on("data", (e) => {
|
||||||
|
errData.push(e);
|
||||||
|
// console.log(e.toString())
|
||||||
|
});
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
node_exec.on("close", (n) => {
|
||||||
|
console.log("node n: ", n);
|
||||||
|
if (0 === n) {
|
||||||
|
let result = Buffer.concat(spwanData).toString();
|
||||||
|
// require('fs').writeFileSync('/mnt/disk2/wechat-web-devtools-linux/tmp/llw2.json', result)
|
||||||
|
// process.stdout.write(result);
|
||||||
|
result = JSON.parse(result);
|
||||||
|
// delete result.generateFunctionContent["__COMMON__"];
|
||||||
|
result = JSON.stringify(result, null, 4);
|
||||||
|
// result = result.generateFunctionContent["__COMMON__"];
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.resolve(__dirname, "./3/node_output.json"),
|
||||||
|
result
|
||||||
|
);
|
||||||
|
resolve(result);
|
||||||
|
} else {
|
||||||
|
process.stderr.write(Buffer.concat(errData).toString());
|
||||||
|
// process.stderr.write(Buffer.concat(spwanData).toString());
|
||||||
|
reject(n);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const test = async () => {
|
||||||
|
try {
|
||||||
|
const node_result = await test_node();
|
||||||
|
const wine_result = await test_wine();
|
||||||
|
console.log("结果是否一致:", wine_result.trim() === node_result);
|
||||||
|
} catch (err) {
|
||||||
|
console.error("错误:", err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
test();
|
Loading…
x
Reference in New Issue
Block a user