Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix:(workflow yml) try to fix Action Cmake Error on Linux #72

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6f1f337
Update cmake.yml
Stardust-minus Dec 18, 2022
83cda89
Merge branch 'Dice-Developer-Team:newdev' into newdev
Stardust-minus Dec 19, 2022
25c366f
Merge branch 'Dice-Developer-Team:newdev' into newdev
Stardust-minus Dec 22, 2022
5b13360
Merge branch 'Dice-Developer-Team:newdev' into newdev
Stardust-minus Dec 26, 2022
6e31a79
Merge branch 'Dice-Developer-Team:newdev' into newdev
Stardust-minus Dec 29, 2022
1415884
Merge branch 'Dice-Developer-Team:newdev' into newdev
Stardust-minus Feb 5, 2023
2f39ec0
Merge branch 'Dice-Developer-Team:newdev' into newdev
Stardust-minus Mar 14, 2023
12c98d3
Merge branch 'Dice-Developer-Team:newdev' into newdev
Stardust-minus Jun 16, 2023
0b40886
Merge branch 'Dice-Developer-Team:newdev' into newdev
Stardust-minus Mar 24, 2024
0ebff96
Merge branch 'Dice-Developer-Team:newdev' into newdev
Stardust-minus Apr 10, 2024
647db58
Update cmake.yml
Stardust-minus Apr 10, 2024
a623c18
Update cmake.yml
Stardust-minus Apr 10, 2024
629322f
Update cmake.yml
Stardust-minus Apr 10, 2024
f54a4d5
Update cmake.yml
Stardust-minus Apr 10, 2024
9273a2b
Update cmake.yml
Stardust-minus Apr 10, 2024
90d32cb
Update cmake.yml
Stardust-minus Apr 10, 2024
c294dd8
Update cmake.yml
Stardust-minus Apr 10, 2024
19f3ef2
Update cmake.yml
Stardust-minus Apr 10, 2024
6aa2e68
Update cmake.yml
Stardust-minus Apr 10, 2024
3e0b83f
Update cmake.yml
Stardust-minus Apr 10, 2024
a5ac440
Update cmake.yml
Stardust-minus Apr 10, 2024
406c680
Merge branch 'Dice-Developer-Team:newdev' into newdev
Stardust-minus Apr 11, 2024
e51c29a
Update cmake.yml
Stardust-minus Apr 14, 2024
0f1d75d
Update cmake.yml
Stardust-minus Apr 14, 2024
821ffbd
Merge branch 'Dice-Developer-Team:newdev' into newdev
Stardust-minus Apr 15, 2024
2dc297f
Update DicePython.cpp
Stardust-minus Apr 15, 2024
eaff27d
Update DicePython.cpp
Stardust-minus Apr 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ${{github.workspace}}/vcpkg
run: ./bootstrap-vcpkg.sh

- name: Setup Vcpkg PATH
shell: bash
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ${{github.workspace}}/
run: export PATH=$PATH:${{github.workspace}}/vcpkg

- name: 'Setup NuGet Credentials'
shell: 'bash'
Expand All @@ -258,7 +264,7 @@ jobs:

- name: Automake
run: sudo apt-get install autoconf automake autoconf-archive

- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
Expand All @@ -267,20 +273,20 @@ jobs:
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: CC=${{ matrix.cc }} CXX=${{ matrix.cxx }} cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DDLL_SUFFIX=.${{matrix.dll_sfx}} -DVCPKG_OVERLAY_TRIPLETS=${{ github.workspace }}/triplets -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} -DCMAKE_PREFIX_PATH=${{ matrix.path }}
run: sudo CC=${{ matrix.cc }} CXX=${{ matrix.cxx }} vcpkg install && sudo cp -r ${{github.workspace}}/vcpkg_installed/${{ matrix.triplet }}/* ${{github.workspace}}/vcpkg_installed/ && cp -r ${{github.workspace}}/vcpkg_installed ${{github.workspace}}/build && echo "Copy Success." && sudo CC=${{ matrix.cc }} CXX=${{ matrix.cxx }} cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DDLL_SUFFIX=.${{matrix.dll_sfx}} -DVCPKG_OVERLAY_TRIPLETS=${{ github.workspace }}/triplets -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} -DCMAKE_PREFIX_PATH=${{ matrix.path }}

- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE
run: sudo cmake --build . --config $BUILD_TYPE -j2

- name: Test
working-directory: ${{github.workspace}}/build
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C $BUILD_TYPE
run: sudo ctest -C $BUILD_TYPE

- name: Upload
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -335,6 +341,12 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ${{github.workspace}}/vcpkg
run: ./bootstrap-vcpkg.sh

- name: Setup Vcpkg PATH
shell: bash
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ${{github.workspace}}/
run: export PATH=$PATH:${{github.workspace}}/vcpkg

- name: 'Setup NuGet Credentials'
shell: 'bash'
Expand All @@ -347,24 +359,28 @@ jobs:
-name "GitHub"
-username "Dice-Developer-Team"
-password "${{ secrets.GITHUB_TOKEN }}"


- name: Install Automake
run: sudo apt-get install autoconf automake autoconf-archive


- name: Configure CMake
shell: bash
working-directory: ${{github.workspace}}/build
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DDLL_SUFFIX=.${{matrix.dll_sfx}} -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=$ANDROID_NDK_LATEST_HOME/build/cmake/android.toolchain.cmake -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} -DANDROID_ABI="${{ matrix.abi }}" -DCMAKE_SYSTEM_NAME=ANDROID -DANDROID_PLATFORM=21 -DCMAKE_SYSTEM_VERSION=21
run: sudo vcpkg install && sudo cp -r ${{github.workspace}}/vcpkg_installed/${{ matrix.triplet }}/* ${{github.workspace}}/vcpkg_installed/ && cp -r ${{github.workspace}}/vcpkg_installed ${{github.workspace}}/build && echo "Copy Success." && sudo cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DDLL_SUFFIX=.${{matrix.dll_sfx}} -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=$ANDROID_NDK_LATEST_HOME/build/cmake/android.toolchain.cmake -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} -DANDROID_ABI="${{ matrix.abi }}" -DCMAKE_SYSTEM_NAME=ANDROID -DANDROID_PLATFORM=21 -DCMAKE_SYSTEM_VERSION=21

- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE
run: sudo cmake --build . --config $BUILD_TYPE

- name: Test
working-directory: ${{github.workspace}}/build
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C $BUILD_TYPE
run: sudo ctest -C $BUILD_TYPE

- name: Upload
uses: actions/upload-artifact@v3
Expand Down
58 changes: 29 additions & 29 deletions Dice/DicePython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* |_______/ |________| |________| |________| |__|
*
* Dice! QQ Dice Robot for TRPG
* Copyright (C) 2018-2021 w4123���
* Copyright (C) 2018-2021 w4123溯洄
* Copyright (C) 2019-2024 String.Empty
*
* This program is free software: you can redistribute it and/or modify it under the terms
Expand Down Expand Up @@ -57,9 +57,9 @@ static string py_to_gbstring(PyObject* o) {
}
static string py_to_native_string(PyObject* o) {
#ifdef _WIN32
return Py_IS_TYPE(o, &PyUnicode_Type) ? UtoGBK(PyUnicode_AsUnicode(o)) : empty;
return PyObject_TypeCheck(o, &PyUnicode_Type) ? UtoGBK(PyUnicode_AsUnicode(o)) : empty;
#else
return Py_IS_TYPE(o, &PyUnicode_Type) ? PyUnicode_AsUTF8(o) : empty;
return PyObject_TypeCheck(o, &PyUnicode_Type) ? PyUnicode_AsUTF8(o) : empty;
#endif
}
AttrVar py_to_attr(PyObject* o);
Expand All @@ -84,7 +84,7 @@ static AttrIndex py_to_hashable(PyObject* o) {
}
else if (t == &PyUnicode_Type)return UtoGBK(PyUnicode_AsUnicode(o));
else if (t == &PyFloat_Type)return PyFloat_AsDouble(o);
else if (t == &PyBool_Type)return Py_IsTrue(o);
else if (t == &PyBool_Type)return PyObject_TypeCheck(o);
}
return 0;
}
Expand Down Expand Up @@ -564,7 +564,7 @@ PyObject* py_newContext(const AttrObject& obj) {
}
AttrVar py_to_attr(PyObject* o) {
if (!o)return {};
else if (auto t{ Py_TYPE(o) }; t == &PyBool_Type)return bool(Py_IsTrue(o));
else if (auto t{ Py_TYPE(o) }; t == &PyBool_Type)return bool(PyObject_TypeCheck(o));
else if (t == &PyLong_Type) {
auto i{ PyLong_AsLongLong(o) };
return (i == (int)i) ? (int)i : i;
Expand Down Expand Up @@ -744,7 +744,7 @@ static PyObject* PySelfData_set(PyObject* self, PyObject* args) {
auto data{ ((PySelfDataObject*)self)->p };
PyObject* item{ nullptr }, * val{ nullptr };
if (PyArg_ParseTuple(args, "O|O", &item, &val)) {
if (Py_IS_TYPE(item, &PyUnicode_Type) && data->data.is_table()) {
if (PyObject_TypeCheck(item, &PyUnicode_Type) && data->data.is_table()) {
data->data.table->set(py_to_gbstring(item), py_to_attr(val));
data->save();
}
Expand Down Expand Up @@ -846,7 +846,7 @@ PYDEFKEY(getGroupAttr) {
}
if (item.empty()) return py_newContext(chat(gid).shared_from_this());
else if (item == "members") {
if (Py_IS_TYPE(sub, &PyUnicode_Type)) {
if (PyObject_TypeCheck(sub, &PyUnicode_Type)) {
string subitem{ py_to_gbstring(sub)};
auto items{ PyDict_New() };
if (subitem == "card") {
Expand Down Expand Up @@ -1063,7 +1063,7 @@ PYDEFKEY(sendMsg) {
/* Parse arguments */
if (!PyArg_ParseTupleAndKeywords(args, keys, "O|LLL", (char**)kwlist, &msg, &uid, &gid, &chid))return NULL;
AttrObject chat;
if (Py_IS_TYPE(msg, &PyUnicode_Type)) {
if (PyObject_TypeCheck(msg, &PyUnicode_Type)) {
chat = py_to_obj(msg);
AddMsgToQueue(fmt->format(chat->get_str("fwdMsg"), chat), chatInfo{ chat->get_ll("uid") ,chat->get_ll("gid") ,chat->get_ll("chid") });
}
Expand All @@ -1090,7 +1090,7 @@ PYDEFKEY(eventMsg) {
return NULL;
}
AttrObject eve;
if (Py_IS_TYPE(msg, &PyUnicode_Type)) {
if (PyObject_TypeCheck(msg, &PyUnicode_Type)) {
eve = py_to_obj(msg);
}
else {
Expand Down Expand Up @@ -1125,37 +1125,37 @@ static PyMethodDef DiceMethods[] = {
};
static PyModuleDef DiceMaidDef = {
PyModuleDef_HEAD_INIT,
DiceModuleName, //������ģ������
"Python interface for Dice function", //ģ���ĵ�������ΪNULL
-1, //һ��Ϊ-1
DiceMethods //PyMethodDef���ͣ���������
DiceModuleName, //导出的模块名称
"Python interface for Dice function", //模块文档,可以为NULL
-1, //一般为-1
DiceMethods //PyMethodDef类型,导出方法
};
PyMODINIT_FUNC PyInit_DiceMaid(){
auto mod = PyModule_Create(&DiceMaidDef);
if (PyType_Ready(&PyContextType) ||
PyModule_AddObject(mod, "Context", (PyObject*)&PyContextType) < 0) {
console.log("ע��dicemaid.Contextʧ��!", 0b1000);
console.log("注册dicemaid.Context失败!", 0b1000);
Py_DECREF(&PyContextType);
Py_DECREF(mod);
return NULL;
}
else if (PyType_Ready(&PyActor_Type) ||
PyModule_AddObject(mod, "Actor", (PyObject*)&PyActor_Type) < 0) {
console.log("ע��dicemaid.Actorʧ��!", 0b1000);
console.log("注册dicemaid.Actor失败!", 0b1000);
Py_DECREF(&PyActor_Type);
Py_DECREF(mod);
return NULL;
}
else if (PyType_Ready(&PyGameTable_Type) ||
PyModule_AddObject(mod, "GameTable", (PyObject*)&PyGameTable_Type) < 0) {
console.log("ע��dicemaid.GameTableʧ��!", 0b1000);
console.log("注册dicemaid.GameTable失败!", 0b1000);
Py_DECREF(&PyGameTable_Type);
Py_DECREF(mod);
return NULL;
}
else if (PyType_Ready(&PySelfData_Type) ||
PyModule_AddObject(mod, "SelfData", (PyObject*)&PySelfData_Type) < 0) {
console.log("ע��dicemaid.SelfDataʧ��!", 0b1000);
console.log("注册dicemaid.SelfData失败!", 0b1000);
Py_DECREF(&PySelfData_Type);
Py_DECREF(mod);
return NULL;
Expand Down Expand Up @@ -1184,7 +1184,7 @@ PyGlobal::PyGlobal() {
try {
static auto import_dice = PyImport_AppendInittab(DiceModuleName, PyInit_DiceMaid);
if (import_dice) {
console.log("Ԥ��dicemaidģ��ʧ��!", 0b1000);
console.log("预载dicemaid模块失败!", 0b1000);
}
if (!Py_IsInitialized())Py_Initialize();
PyRun_SimpleString("import sys");
Expand All @@ -1193,7 +1193,7 @@ PyGlobal::PyGlobal() {
PyRun_SimpleString("from dicemaid import *");
}
catch (std::exception& e) {
console.log("python��ʼ��ʧ��" + string(e.what()), 0b1);
console.log("python初始化失败" + string(e.what()), 0b1);
}
console.log("Python.Initialized", 0);
}
Expand All @@ -1219,7 +1219,7 @@ static PyObject* Py_CompileScript(string& name) {
auto res{ Py_CompileString(script->c_str(), p->u8string().c_str(), Py_file_input) };
Py_FileScripts[name] = { res,lstWrite };
if (!res) {
console.log(getMsg("self") + "����" + (name = UTF8toGBK(p->u8string())) + "ʧ��: " + py_print_error(), 0b10);
console.log(getMsg("self") + "编译" + (name = UTF8toGBK(p->u8string())) + "失败: " + py_print_error(), 0b10);
PyErr_Clear();
}
return res;
Expand All @@ -1232,7 +1232,7 @@ static PyObject* Py_CompileScript(string& name) {
return Py_StringScripts[name] = res;
}
else {
console.log(getMsg("self") + "����python���ʧ��: " + py_print_error(), 0b10);
console.log(getMsg("self") + "编译python语句失败: " + py_print_error(), 0b10);
PyErr_Clear();
}
return nullptr;
Expand All @@ -1247,7 +1247,7 @@ bool PyGlobal::runFile(const std::filesystem::path& p, const AttrObject& context
auto res{ PyRun_File(fp, p.u8string().c_str(), Py_file_input, global, py_newContext(context))};
fclose(fp);
if (!res) {
console.log(getMsg("self") + "����" + UTF8toGBK(p.u8string()) + "�쳣!" + py_print_error(), 0b10);
console.log(getMsg("self") + "运行" + UTF8toGBK(p.u8string()) + "异常!" + py_print_error(), 0b10);
PyErr_Clear();
return false;
}
Expand All @@ -1263,13 +1263,13 @@ bool PyGlobal::execString(const std::string& s, const AttrObject& context) {
PyObject* mainModule = PyImport_ImportModule("__main__");
PyObject* dict = PyModule_GetDict(mainModule);
if (auto ret{ PyRun_String(GBKtoUTF8(s).c_str(), Py_eval_input, dict, py_newContext(context)) }; !ret) {
console.log(getMsg("self") + "����python����쳣!" + py_print_error(), 0b10);
console.log(getMsg("self") + "运算python语句异常!" + py_print_error(), 0b10);
PyErr_Clear();
}
return true;
}
catch (std::exception& e) {
console.log(getMsg("self") + "����python�ű��쳣!" + e.what(), 0b10);
console.log(getMsg("self") + "运行python脚本异常!" + e.what(), 0b10);
}
return false;
}
Expand All @@ -1278,13 +1278,13 @@ AttrVar PyGlobal::evalString(const std::string& s, const AttrObject& context) {
PyObject* mainModule = PyImport_ImportModule("__main__");
PyObject* dict = PyModule_GetDict(mainModule);
if (auto ret{ PyRun_String(GBKtoUTF8(s).c_str(), Py_eval_input, dict, py_newContext(context)) }; !ret) {
console.log(getMsg("self") + "����python����쳣!" + py_print_error(), 0b10);
console.log(getMsg("self") + "运算python语句异常!" + py_print_error(), 0b10);
PyErr_Clear();
}
else return py_to_attr(ret);
}
catch (std::exception& e) {
console.log(getMsg("self") + "����python�ű��쳣!" + e.what(), 0b10);
console.log(getMsg("self") + "运行python脚本异常!" + e.what(), 0b10);
}
return {};
}
Expand All @@ -1302,15 +1302,15 @@ bool PyGlobal::call_reply(DiceEvent* msg, const AttrVar& action) {
}
else {
Py_DECREF(locals);
console.log(getMsg("self") + "����" + pyScript + "������\n" + py_print_error(), 0b10);
console.log(getMsg("self") + "运行" + pyScript + "出错!\n" + py_print_error(), 0b10);
PyErr_Clear();
msg->set("lang", "Python");
msg->reply(getMsg("strScriptRunErr"));
}
}
}
catch (std::exception& e) {
console.log(getMsg("self") + "����python�ű��쳣!" + e.what(), 0b10);
console.log(getMsg("self") + "运行python脚本异常!" + e.what(), 0b10);
msg->set("lang", "Python");
msg->reply(getMsg("strScriptRunErr"));
}
Expand All @@ -1324,4 +1324,4 @@ bool py_call_event(const AttrObject& eve, const AttrVar& action) {
}
return false;
}
#endif // #ifdef DICE_PYTHON
#endif // #ifdef DICE_PYTHON