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

chore: Update MSYS2 Windows 32 and 64 bit toolchain and build scripts #4314

Open
wants to merge 39 commits into
base: main
Choose a base branch
from

Conversation

elecpower
Copy link
Collaborator

@elecpower elecpower commented Nov 13, 2023

Summary of changes:

  • based on previous MSYS2 64-bit scripts
  • environment aware MSYS2 Win 32 and 64-bit toolchain and compile scripts
  • amendments for changes to MSYS2 package contents, Qt 5.15.2, support tools and make things work
  • add cli options and parameters
  • support v2.10 change using hwdefs
  • use repo supported radio types and libsims rather than independent lists hardcoded in the scripts

Todo:

  • update documentation (after testing and approval)

@elecpower elecpower added documentation Improvements or additions to documentation compilation Related to compiling the firmware and firmware options labels Nov 13, 2023
@elecpower elecpower marked this pull request as draft November 13, 2023 05:04
@offer-shmuely
Copy link
Contributor

tried to make my environment buildable again
the msys2_setup_buildenv_stage1_32_64.sh succeded
the msys2_setup_buildenv_stage2_32_64.sh does not pass the
read -p "Press any key to continue or ctrl+C to abort"

I comment out the "read -p ..."

next failure is

image

@elecpower
Copy link
Collaborator Author

Usually not running the latest version of aqt as this is a newer option. The new build script does not specify a version.

@mha1
Copy link
Contributor

mha1 commented Nov 30, 2023

@offer-shmuely If you haven't done so: the new install scripts will not work on an existing MSYS2 installation. You need to deinstall MSYS2 entirely an re-install MSYS2 using the new install guide and scripts.

@offer-shmuely
Copy link
Contributor

Not familiar with MSYS
Where is the “new install guide”?

@mha1
Copy link
Contributor

mha1 commented Nov 30, 2023

oops, idk if Neil already update the how-to. but it's similar to the current one. deinstall MSYS2 and try the new scripts

@pfeerick
Copy link
Member

Is this ready to go or was more work needed?

Build Simulator: $(bool_to_text ${BUILD_SIMULATOR})
Pause after each step: $(bool_to_text ${STEP_PAUSE})
"
read -p "Press any key to continue or ctrl+C to abort"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only Enter works, thus "Press Enter key to continue or Ctrl+C to abort".

Edit the file <MSYS2 install directory>\mingw64.ini eg C:\msys64\mingw64.ini
- Uncomment the line #MSYS2_PATH_TYPE=inherit
- Save the file
"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO better, than setting an operating system wide setting for EdgeTX, would be to explicitly use -DARM_TOOLCHAIN_DIR in EdgeTX CMake line, e.g. here then with ARM GNU 11.3.1 -DARM_TOOLCHAIN_DIR="C:\Program Files (x86)\Arm GNU Toolchain arm-none-eabi\11.3 rel1\bin".

Setting something system wide might affect users building other (non EdgeTX) code on their systems.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently this does not work anyway as there are spaces in the path.
Let's just say there was robust discussion when I posted these new scripts about how best to pass the ARM path.
I too prefer the -D method.

@rotorman
Copy link
Member

rotorman commented Apr 16, 2024

Tested this PR under Win11 Pro 23H2 64-bit. With the comments and changes I posted above and below this post, all worked (was able to build radio firmware, Companion, Simulator binary and library and create an installer executable).

This PR should remove tools/setup_buildenv_msys2_stage1.sh and tools/setup_buildenv_msys2_stage2.sh (as it is replacing the scripts with 4 new files named differently).

After my comments are worked in, I see no issue merging this PR into main. I would also update the Wiki page https://github.com/EdgeTX/edgetx/wiki/Build-Instructions-under-Windows-10-%28MSYS2%29 accordingly, e.g. to also update the CMAKE_PREFIX_PATH to $HOME/qt/5.15.2/mingw81_64.

For someone wanting to test, here the full working CMake line for RM Zorro:

 cmake -G "MSYS Makefiles" -Wno-dev -DCMAKE_PREFIX_PATH=$HOME/qt/5.15.2/mingw81_64 -DSDL2_LIBRARY_PATH=/mingw64/bin/ -DPCB=X7 -DPCBREV=ZORRO -DDEFAULT_MODE=2 -DLUA_MIXER=YES -DARM_TOOLCHAIN_DIR="C:\Program Files (x86)\Arm GNU Toolchain arm-none-eabi\11.3 rel1\bin" -DCMAKE_BUILD_TYPE=Release ../

@elecpower
Copy link
Collaborator Author

This PR was built well before the infamous ADC refactor was released (which keeps on giving). Also Peter has needed to do some tricks to keep the compilations working with updates to the MSYS packages. So it does need revisiting.
I'll put it to the test again and take onboard your latest feedback. Once we are okay with the result its time to do some updated documentation.

@elecpower
Copy link
Collaborator Author

The ADC refactor broke Companion compile as the hw def json files are not where CMake expects. Companion compiles, it just does not have any definitions to load for the radio profiles. So a fix required.

@pfeerick
Copy link
Member

Really need to make the json generation recursive (i.e. a bit like what tools/generate_hw_defs.sh or tools/generate_yaml.sh does) so that it can be it's own build step, rather than depending on calling libsimulator builds for all desired radios you want the companion build to support. Maybe something like the AddHardwareDefTarget macro could work?

@elecpower
Copy link
Collaborator Author

elecpower commented May 12, 2024

That's the direction I am going. I take that approach in my Linux dev environment.

@elecpower elecpower force-pushed the elecpower/msys2-32-64-scripts branch from ae39924 to 29b183e Compare May 15, 2024 13:07
@elecpower
Copy link
Collaborator Author

@pfeerick @rotorman okay so the scripts are working but I need to do more use cases tests before recommending merging.
The hardware definitions generation is painfully slow due to resetting the cmake environment for each radio so any thoughts would be most welcome.
Feel free to give them a spin and let me know of any issues/suggestions.

@markomajic
Copy link

Were there any changes/updates to this since May? I wanted to setup a Windows dev environment to play around a bit with EdgeTX code and it's been a struggle. I tried on two different Windows 11 (both 23H2) with what's currently available for download from www.msys2.org (msys2-x86_64-20240727) without success... On the first machine, there were some random errors/warnings during "stage 2" script - but it was able to compile firmware but not companion, libsimulator or simulator (all targets reported as not present in the Makefile). On the second machine things looked better (but turned out worse) as I didn't notice and errors or warnings during "stage 2" but... All targets (including firmware) were missing from the Makefile (I did run 'make configure')... Just checking if there are updated "recipes" out there?

I was able to deploy a working dev environment by following https://github.com/EdgeTX/edgetx/wiki/Build-Instructions-under-Ubuntu-20.04 "recipe" (but only when I switched to 22.04 from 20.04!?) and, I should say, with VS.Code's "remote connection" feature directly into WSL's VM (and built in graphics support) - it's really a nice and comfy dev environment and a refreshing departure for a lifelong C/C++ guy coddled by IDE-hand-holding - takes me back to the university days (and that's going some ways back lol)... But I'd really prefer to build Windows binaries (it just seems easier seeing as I have all Windows machines) so I've been banging my head against the wall for the past few days... Thx!!

@elecpower
Copy link
Collaborator Author

Since v2.10 you do need to compile the libsimulator before Companion and Simulator.

@markomajic
Copy link

Thanks for the reply... I am not able to build libsimulator either - it seems that none of the targets are generated in the makefile (I get the message "*** No rule to make target 'libsimulator'. Stop."...

It seems that Qt either wasn't (fully) installed or was installed but somewhere were the CMake cannot find it...

But... I suppose this probably isn't the right forum for these kinds of questions (and cries for help ;-)) - my apologies...

@elecpower elecpower force-pushed the elecpower/msys2-32-64-scripts branch from fb56dc4 to 476fba5 Compare October 20, 2024 20:48
@elecpower elecpower marked this pull request as ready for review November 5, 2024 21:18
@elecpower
Copy link
Collaborator Author

elecpower commented Nov 5, 2024

Now supports v2.10 hwdefs and uses repo supported radios and libsims

@elecpower
Copy link
Collaborator Author

@pfeerick I have finished my testing and tinkering so now just bug fixes anyone else finds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compilation Related to compiling the firmware and firmware options documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants