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

Refactoring of build.py and bugfixes to improve the support of Windows #8074

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

easymoney322
Copy link
Contributor

I've made some changes to build.py:

  • Removed consecutive slashes that would occur in some places due to path concatenation;
  • Replaced cp/mv system calls on windows with shutil.copy2 and os.replace respectively. Now you can use system shells such as PowerShell or CMD to build;
  • Fixed os.rename causing windows-specific error except FileExistsError if the ./rustdesk-{version}-install.exe still existed after the previous build. This also improves ACLs handling;
  • Replaced system calls for python3 on Windows to use python instead, as it's the default python3 binary, and the python2 is deprecated. This should allow to build on the new systems without symlinking python3 to python;

It might be better to use some kind of logic (like getting and parsing the output of python -V and python3 -V respectively) to determine which binary to use, and then calling the binary directly, but I find it unnecessary complicated as Python 2 is deprecated anyway.

I've tested it with nightly workflow, as well as with python ./build.py --hwcodec --flutter and .\build.py --portable --hwcodec --flutter --vram --skip-portable-pack with both CMD ans PS shells, and it compiles and works.
However, the deprecated non-flutter build doesn't compile (it doesn't compile on the master branch either: NotADirectoryError: [WinError 267] The directory name is invalid: '../../resources') due to a problem with passing res_dir to the ./generate.py.

I'm planning to make a CI (or at least scripts) for building the Windows version natively on Windows or Windows containers, if this pull request gets merged. The reason is that, when you only need a Windows binary (e.g. developing on Win), it would be faster to compile only Windows-version.

…f the file './rustdesk-{version}-install.exe' already existed. Swapped windows system calls for python to use the default 'python' instead of 'python3'.

FileExistsError exception would occur during the rename operation if the file existed. So, to avoid using try\except blocks with unlinking or deleting, we can just check the existance of the path, and respect filesystem ACLs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant