mirror of
https://github.com/msojocs/wx-compiler.git
synced 2025-07-19 00:00:04 +08:00
refactor: 迁移CPP
This commit is contained in:
parent
a780f231d3
commit
5b5acb5355
13
.gitignore
vendored
13
.gitignore
vendored
@ -1,12 +1 @@
|
|||||||
node_modules
|
build
|
||||||
test/wcc/**/*-output.json
|
|
||||||
test/wcsc/**/*-output.json
|
|
||||||
test/wcc/**/*-output.js
|
|
||||||
test/wcsc/**/*-output.js
|
|
||||||
test/wcc/**/*_output.json
|
|
||||||
test/wcsc/**/*_output.json
|
|
||||||
test/wcc/**/*_stderr.json
|
|
||||||
test/wcsc/**/*_stderr.json
|
|
||||||
test/wcc/**/linux_err.js
|
|
||||||
test/wcsc/**/linux_err.js
|
|
||||||
nwjs
|
|
49
.vscode/settings.json
vendored
Normal file
49
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"vector": "cpp",
|
||||||
|
"array": "cpp",
|
||||||
|
"atomic": "cpp",
|
||||||
|
"bit": "cpp",
|
||||||
|
"*.tcc": "cpp",
|
||||||
|
"cctype": "cpp",
|
||||||
|
"clocale": "cpp",
|
||||||
|
"cmath": "cpp",
|
||||||
|
"cstdarg": "cpp",
|
||||||
|
"cstddef": "cpp",
|
||||||
|
"cstdint": "cpp",
|
||||||
|
"cstdio": "cpp",
|
||||||
|
"cstdlib": "cpp",
|
||||||
|
"cwchar": "cpp",
|
||||||
|
"cwctype": "cpp",
|
||||||
|
"deque": "cpp",
|
||||||
|
"unordered_map": "cpp",
|
||||||
|
"exception": "cpp",
|
||||||
|
"algorithm": "cpp",
|
||||||
|
"functional": "cpp",
|
||||||
|
"iterator": "cpp",
|
||||||
|
"memory": "cpp",
|
||||||
|
"memory_resource": "cpp",
|
||||||
|
"numeric": "cpp",
|
||||||
|
"optional": "cpp",
|
||||||
|
"random": "cpp",
|
||||||
|
"string": "cpp",
|
||||||
|
"string_view": "cpp",
|
||||||
|
"system_error": "cpp",
|
||||||
|
"tuple": "cpp",
|
||||||
|
"type_traits": "cpp",
|
||||||
|
"utility": "cpp",
|
||||||
|
"fstream": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"iosfwd": "cpp",
|
||||||
|
"iostream": "cpp",
|
||||||
|
"istream": "cpp",
|
||||||
|
"limits": "cpp",
|
||||||
|
"new": "cpp",
|
||||||
|
"ostream": "cpp",
|
||||||
|
"sstream": "cpp",
|
||||||
|
"stdexcept": "cpp",
|
||||||
|
"streambuf": "cpp",
|
||||||
|
"typeinfo": "cpp",
|
||||||
|
"cstring": "cpp"
|
||||||
|
}
|
||||||
|
}
|
16
CMakeLists.txt
Normal file
16
CMakeLists.txt
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.0.0)
|
||||||
|
project(wx_complier VERSION 0.1.0 LANGUAGES C CXX)
|
||||||
|
|
||||||
|
include(CTest)
|
||||||
|
enable_testing()
|
||||||
|
|
||||||
|
add_executable(wcc
|
||||||
|
src/wcc.cpp
|
||||||
|
src/wcc/usage.cpp
|
||||||
|
src/utils/file.cpp
|
||||||
|
)
|
||||||
|
add_executable(wcsc src/wcsc.cpp)
|
||||||
|
|
||||||
|
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
|
||||||
|
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
|
||||||
|
include(CPack)
|
60
CMakeLists1.txt
Normal file
60
CMakeLists1.txt
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.0.0)
|
||||||
|
project(mylrc VERSION 0.1.0)
|
||||||
|
|
||||||
|
find_package(cJSON REQUIRED)
|
||||||
|
find_package(OpenSSL REQUIRED)
|
||||||
|
|
||||||
|
include(CTest)
|
||||||
|
enable_testing()
|
||||||
|
include_directories(./src/include)
|
||||||
|
add_executable(
|
||||||
|
mylrc
|
||||||
|
main.cpp
|
||||||
|
src/common.cpp
|
||||||
|
src/tmc.cpp
|
||||||
|
src/ae.cpp
|
||||||
|
src/ae/keyExpansion.cpp
|
||||||
|
src/ae/storeStateArray.cpp
|
||||||
|
src/ae/shiftRows.cpp
|
||||||
|
src/ae/loadStateArray.cpp
|
||||||
|
src/ae/mixColumns.cpp
|
||||||
|
src/ae/subBytes.cpp
|
||||||
|
src/ae/addRoundKey.cpp
|
||||||
|
src/ka.cpp
|
||||||
|
src/kq.cpp
|
||||||
|
src/print_hex.cpp
|
||||||
|
)
|
||||||
|
target_link_libraries(
|
||||||
|
mylrc
|
||||||
|
PRIVATE cjson
|
||||||
|
OpenSSL::SSL
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(mylrc_test test/test.cpp)
|
||||||
|
add_executable(
|
||||||
|
storeStateArray_test
|
||||||
|
test/storeStateArray_test.cpp
|
||||||
|
src/common.cpp
|
||||||
|
src/ae/storeStateArray.cpp
|
||||||
|
)
|
||||||
|
add_executable(
|
||||||
|
printHex_test
|
||||||
|
test/printHex_test.cpp
|
||||||
|
src/print_hex.cpp
|
||||||
|
)
|
||||||
|
add_executable(
|
||||||
|
md5_test
|
||||||
|
test/md5_test.cpp
|
||||||
|
src/kq.cpp
|
||||||
|
)
|
||||||
|
target_link_libraries(md5_test OpenSSL::SSL)
|
||||||
|
# add_subdirectory(src)
|
||||||
|
add_test(
|
||||||
|
mylrc_test
|
||||||
|
$<TARGET_FILE:mylrc_test>#
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
|
||||||
|
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
|
||||||
|
include(CPack)
|
12
node/.gitignore
vendored
Normal file
12
node/.gitignore
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
node_modules
|
||||||
|
test/wcc/**/*-output.json
|
||||||
|
test/wcsc/**/*-output.json
|
||||||
|
test/wcc/**/*-output.js
|
||||||
|
test/wcsc/**/*-output.js
|
||||||
|
test/wcc/**/*_output.json
|
||||||
|
test/wcsc/**/*_output.json
|
||||||
|
test/wcc/**/*_stderr.json
|
||||||
|
test/wcsc/**/*_stderr.json
|
||||||
|
test/wcc/**/linux_err.js
|
||||||
|
test/wcsc/**/linux_err.js
|
||||||
|
nwjs
|
0
.gitmodules → node/.gitmodules
vendored
0
.gitmodules → node/.gitmodules
vendored
0
package-lock.json → node/package-lock.json
generated
0
package-lock.json → node/package-lock.json
generated
0
test/.gitignore → node/test/.gitignore
vendored
0
test/.gitignore → node/test/.gitignore
vendored
7
src/include/file.h
Normal file
7
src/include/file.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#ifndef __FILE_H__
|
||||||
|
#define __FILE_H__
|
||||||
|
|
||||||
|
int readFile (std::string fileName, std::string result);
|
||||||
|
void getNextArg(std::string &line, std::string &data, char lineEndMark);
|
||||||
|
|
||||||
|
#endif
|
6
src/include/usage.h
Normal file
6
src/include/usage.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef __USAGE_H__
|
||||||
|
#define __USAGE_H__
|
||||||
|
|
||||||
|
int usage();
|
||||||
|
|
||||||
|
#endif
|
72
src/utils/file.cpp
Normal file
72
src/utils/file.cpp
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取文件内容
|
||||||
|
*
|
||||||
|
* @param fileName 文件名
|
||||||
|
* @param result 用于存储文件内容
|
||||||
|
*
|
||||||
|
* @return int 0成功 | -1失败
|
||||||
|
*/
|
||||||
|
int readFile (std::string fileName, std::string &result) {
|
||||||
|
FILE *f = NULL;
|
||||||
|
char temp[1020];
|
||||||
|
char buf[1024];
|
||||||
|
unsigned int len;
|
||||||
|
|
||||||
|
result = "\0";
|
||||||
|
if (fileName.empty()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
f = fopen(fileName.c_str(), "r");
|
||||||
|
if (!f) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
buf[0] = 0;
|
||||||
|
|
||||||
|
memset(buf, 0, sizeof(buf));
|
||||||
|
while (fgets(buf, 1024, f))
|
||||||
|
{
|
||||||
|
len = strlen(buf);
|
||||||
|
result.append(buf, len);
|
||||||
|
}
|
||||||
|
if (f) {
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string& trim(std::string &s)
|
||||||
|
{
|
||||||
|
if (s.empty())
|
||||||
|
{
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
s.erase(0,s.find_first_not_of(" "));
|
||||||
|
s.erase(s.find_last_not_of(" ") + 1);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param line 存储行数据的容器
|
||||||
|
* @param data 配置内容数据
|
||||||
|
* @param lineEndMark 行结束标志 \n
|
||||||
|
*/
|
||||||
|
void getNextArg(std::string &line, std::string &data, char lineEndMark) {
|
||||||
|
int pos = data.find(lineEndMark, 0);
|
||||||
|
std::string lineData;
|
||||||
|
if (pos == -1) {
|
||||||
|
lineData.assign(data);
|
||||||
|
data = "\0";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lineData = data.substr(0, pos);
|
||||||
|
data = data.substr(pos);
|
||||||
|
}
|
||||||
|
trim(lineData);
|
||||||
|
line = lineData;
|
||||||
|
}
|
45
src/wcc.cpp
Normal file
45
src/wcc.cpp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include "include/file.h"
|
||||||
|
#include "include/usage.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
|
string gwxMark = "$gwx";
|
||||||
|
string blankStr = " ";
|
||||||
|
bool hasConfigParam = false;
|
||||||
|
string configPathData;
|
||||||
|
vector<string> fileList;
|
||||||
|
string configData;
|
||||||
|
|
||||||
|
for (int i = 1; i < argc; i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!string("--cofig-path").compare(argv[i])) {
|
||||||
|
hasConfigParam = i + 1 < argc;
|
||||||
|
}
|
||||||
|
if (hasConfigParam) {
|
||||||
|
// 有--config-path参数,下一个参数是路径,跳过
|
||||||
|
i++;
|
||||||
|
configPathData = argv[i];
|
||||||
|
}else {
|
||||||
|
fileList.emplace_back(argv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 有配置文件,从配置文件解析
|
||||||
|
if (hasConfigParam) {
|
||||||
|
int ret = readFile(configPathData, configData);
|
||||||
|
string line;
|
||||||
|
if (0 == ret) {
|
||||||
|
getNextArg(line, configData, '\n');
|
||||||
|
fileList.emplace_back(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
23
src/wcc/usage.cpp
Normal file
23
src/wcc/usage.cpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
//----- (00401726) --------------------------------------------------------
|
||||||
|
int usage()
|
||||||
|
{
|
||||||
|
printf("Wechat WXML Compiler, version %s\n", "v0.5vv_20200413_syb_scopedata");
|
||||||
|
printf(
|
||||||
|
"Usage: %s [-d] [-o OUTPUT] [-xc XComponentDefine] [-om XComponentDefine] [-cb [callback.js...]] [-llcommon] [-llw/-l"
|
||||||
|
"la XCPath] <FILES... | -s <SINGLE_FILE>\n",
|
||||||
|
*a2);
|
||||||
|
printf(" Options:\n");
|
||||||
|
printf(" -d: output code for debug\n");
|
||||||
|
printf(" -o: output destination (default stdout)\n");
|
||||||
|
printf(" -xc: output simplified code for custom component\n");
|
||||||
|
printf(" -cc: output compelete code for custom component\n");
|
||||||
|
printf(" -s: read from stdin\n");
|
||||||
|
printf(" -ds: insert debug wxs info\n");
|
||||||
|
printf(" -cb: add life cycle callback\n");
|
||||||
|
printf(" -llw: compile in lazy load mode (webiew)\n");
|
||||||
|
printf(" -lla: compile in lazy load mode (app service)\n");
|
||||||
|
printf(" args XCPath: custom component paths connected by comma or --split (./page/index,./comp/comp)\n");
|
||||||
|
return 1;
|
||||||
|
}
|
6
src/wcsc.cpp
Normal file
6
src/wcsc.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user