As mobile app development continues to evolve, it's essential to stay ahead of the curve by leveraging innovative tools and technologies. In this post, we'll explore how Electronic Arts (EA) successfully integrated Visual Studio's cross-platform support into their workflow, allowing for seamless development on Windows and debugging on Linux.

At EA, our Frostbite Engine has a significant Linux component that powers dedicated servers for many of our most popular games. When Microsoft announced the addition of Linux support in a Visual Studio workload, we were intrigued! Our game developers are accustomed to working within a Windows environment, so we initially considered forcing them to develop directly on Linux. However, we realized this might be too drastic a change, and instead opted for cross-compilation from Windows using clang.

We developed our own internal build setup using a proprietary tool that generates various output formats (vcxproj, csproj, make files, etc.). When adding Linux support, we decided to maintain our primary workflow on Windows-based PCs with Visual Studio. This allowed us to leverage the familiar environment and minimize disruptions for our developers. Additionally, we required a Continuous Integration/Build Farm (CI) that could validate code compilation on Linux without needing separate VMs or remote systems – a crucial requirement.

To facilitate cross-compilation, we employed a "Canadian cross" compiler setup. By combining the LLVM and GCC toolchains built on a Linux machine with Windows clang, we created a powerful cross-compiler environment. This setup allowed us to:

  • Use LLVM
  • Combine the Windows version of LLVM with the Linux version on the Windows machine for targeting Linux
  • Utilize the GCC toolchain with LLVM
  • Pass specific flags (e.g., -target x86_64-pc-linux-gnu and -sysroot=)

After assembling our toolchain, we generated makefiles that built our code using the cross-compiler setup. We then created vcxproj files of type "Linux Makefile" and a .sln file for integration with Visual Studio.

Visual Studio Integration

To enable seamless development and debugging, developers need to install the 'Linux Development with C++' workload in Visual Studio. Once installed, we leverage the built-in features of Linux Makefile projects:

  • Build code by selecting "Build" within Visual Studio, which executes our cross-compiler and outputs binaries.
  • Deploy and debug on a Linux host using the built-in debugging capabilities.

Debugging on WSL

We can configure our generator to use two different deployment/debugging setups: WSL (Windows Subsystem for Linux) and Remote Linux Host. The most convenient setup is WSL, especially for headless unit tests or console applications that don't require rendering to screen.

When using WSL, the binaries are accessible directly from the current Windows machine, eliminating the need for deployment and reducing build times. This is particularly useful when working with large binaries that can add seconds to an incremental build and debug session.

Here's an example of building EASTL, an open-source library developed at EA, using Visual Studio Linux Makefile Projects and our cross-compiler:

By setting the Remote Build Root, Project, and Deploy directories to WSL paths on my Windows machine, I can debug seamlessly without copying binaries. This is achieved by configuring my environment to use WSL when running, which launches the test binary in WSL and connects the debugger using Visual Studio's gdb debugger.

Conclusion

In this post, we've explored how EA successfully integrated Visual Studio's cross-platform support into our workflow, enabling seamless development on Windows and debugging on Linux. By leveraging the 'Linux Development with C++' workload and configuring our generator to use WSL, we've streamlined our workflows and improved developer productivity.