* docs: 更新文档 对不起我忘记拆分 commit 了 优化 winget 安装运行库命令 添加 一键修复运行库.ps1 将 image 文件夹重命名为 images 添加账号切换执行时机说明 土下座 Co-authored-by: SherkeyXD <57581480+SherkeyXD@users.noreply.github.com> * docs: 跟上学姐的脚步 * fix: cli docs --------- Co-authored-by: SherkeyXD <57581480+SherkeyXD@users.noreply.github.com>
5.9 KiB
order, icon
| order | icon |
|---|---|
| 1 | iconoir:developer |
Getting Started with Development
Introduction to GitHub Pull Request flow
I don't know programming but just want to modify some JSON files/documents, how can I do it?
Welcome to the GitHub Pull Request Tutorial that anyone can understand (purely web-based on Github.com)
I can program, but I've never used GitHub/C++/..., what can I do?
-
If you have forked this repository a long time ago, please go to
Settings, scroll down to the bottom, and clickDelete Repository. -
Go to MAA main repository and click
Fork, thenCreate fork. -
Clone the
devbranch of the (forked) repository to local with submodules:git clone --recurse-submodules <link to your forked repo> -b devIf you are using a Git GUI such as Visual Studio that does not include
--recurse-submodules, dogit submodule update --initafter cloning to clone the submodules. -
Download pre-built third-party libraries
A Python environment is required; please search for a Python installation tutorial if needed.
python maadeps-download.py -
Configure development environment
- Download and install
Visual Studio 2022 Community. During installation, selectDesktop development with C++and.NET Desktop Development.
- Download and install
-
Double-click to open the file
MAA.sln. Visual Studio will load the project automatically. -
Run a build to test whether the development environment has been configured correctly. Choose
Release&x64, right-clickMaaWpfGuito set it as the startup project, and run it. If the build is successful, theMaaWpfGuiwindow will appear. You can connect to the emulator in order to confirm again that the development environment has been configured correctly. -
Now you are free to contribute to MAA.
-
Remember to commit once you have proper number of changes. Don't forget to write a commit message.
If you are a beginner of git, you might want to make changes on a newly created branch instead of committing to
devdirectlygit branch your_own_branch git checkout your_own_branchso that your new commits would grow on the new branch, without being interrupted by updates of
dev -
After development, push your local changes to the remote (your own repository).
git push origin dev -
Go to MAA repository and submit a Pull Request. Wait until the administrator approves it. Please note that the changes should be based on
devinstead ofmasterbranch, and should be merged todevbranch as well. -
When there are changes from other contributors on upstreaming MAA repository, it might be necessary for you to add them to your own branch.
-
Add MAA upstream repository.
git remote add upstream https://github.com/MaaAssistantArknights/MaaAssistantArknights.git -
Fetch upstream changes from the repository.
git fetch upstream -
rebase (recommended) or merge changes.
git rebase upstream/devor
git merge -
Repeat step 7-10.
-
Note: operations regarding Git can be done by VS2022 instead of command line tools, using the Git changes tab.
MAA file formatting requirements
MAA uses a series of formatting tools to ensure that the code and resource files in the repository are visually unified for easy maintenance and reading.
Please ensure that it has been formatted before submission, or enable Pre commit Hooks for automatic formatting.
The currently enabled formatting tools are as follows:
| File Type | Format Tool |
|---|---|
| C++ | clang-format |
| Json/Yaml | Prettier |
| Markdown | markdownlint |
Use Pre-commit Hooks to Automatically Format Code
-
Ensure that you have Python and Node environments on your computer.
-
Execute the following command in the root directory of the project:
pip install pre-commit pre-commit install
If pre-commit still cannot be used after pip install, please check if the pip installation path has been added to the PATH.
The formatting tool will automatically run every time you submit to ensure that your code format conforms to the style guide.
Enable clang-format in Visual Studio
-
Install clang-format version 17 or higher.
python -m pip install clang-format -
Use tools like 'Everything' to locate the installation location of clang-format.exe. As a reference, if you are using Anaconda, clang-format.exe will be installed in YourAnacondaPath/Scripts/clang-format.exe.
-
In Visual Studio, search for 'clang-format' in Tools-Options.
-
Click
Enable ClangFormat supportand selectUse custom clang-format.exe fileand choose theclang-format.exelocated in Step 2.
You are all set with the clang-format integrated in Visual Studio supporting c++20 features!
You can also format with tools\ClangFormatter\clang-formatter.py directly, by executing in the root folder of the project:
python tools\ClangFormatter\clang-formatter.py --clang-format=PATH\TO\YOUR\clang-format.exe --input=src\MaaCore
Develop in cloud using GitHub codespace
Create GitHub codespace with pre-configured C++ dev environments:
Then follow the instructions in vscode or Linux tutorial to configure GCC 12 and the CMake project.
