Browse Source

Add a uwp-universal target to build all uwp arches at once

This is identical to how the cross-android-universal target works.
Supported UWP arches are: x86, x86_64, arm64. This covers 100% of
Windows 10 machines:
https://docs.microsoft.com/en-us/windows/msix/package/device-architecture

Advantages are the same as Android:
1. Most people will build apps that target multiple (or all) archs
2. Easier to build and ship all arches at once
3. Easier to download two tarballs rather than six

Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/551>
zrythm
Nirbheek Chauhan 3 years ago
parent
commit
533ef280d3
  1. 37
      README.md
  2. 7
      cerbero/config.py
  3. 13
      config/cross-uwp-universal.cbc
  4. 1
      config/win64.cbc
  5. 29
      config/windows.config
  6. BIN
      data/images/vs-installer-uwp-workload.png

37
README.md

@ -128,15 +128,16 @@ iOS x86_64 | `cross-ios-x86-64.cbc` @@ -128,15 +128,16 @@ iOS x86_64 | `cross-ios-x86-64.cbc`
On Windows, config files are used to select the architecture and variants are
used to select the toolchain (MinGW, MSVC, UWP):
Target | Config file | Variant
:---------------------------------|:----------------------|:-------
MinGW x86 | `win32.cbc` |
MinGW x86_64 | `win64.cbc` |
MSVC x86 | `win32.cbc` | visualstudio
MSVC x86_64 | `win64.cbc` | visualstudio
Universal Windows Platform x86 | `win32.cbc` | uwp
Universal Windows Platform x86_64 | `win64.cbc` | uwp
Universal Windows Platform ARM64 | `cross-win-arm64.cbc` | uwp
Target | Config file | Variant
:---------------|:--------------------------|:-------
MinGW x86 | `win32.cbc` |
MinGW x86_64 | `win64.cbc` |
MSVC x86 | `win32.cbc` | visualstudio
MSVC x86_64 | `win64.cbc` | visualstudio
UWP x86 | `win32.cbc` | uwp
UWP x86_64 | `win64.cbc` | uwp
UWP ARM64 | `cross-win-arm64.cbc` | uwp
UWP Universal | `cross-uwp-universal.cbc | (implicitly uwp)
Example usage:
@ -147,15 +148,15 @@ $ ./cerbero-uninstalled -c config/win32.cbc package gstreamer-1.0 @@ -147,15 +148,15 @@ $ ./cerbero-uninstalled -c config/win32.cbc package gstreamer-1.0
# Target MSVC 32-bit
$ ./cerbero-uninstalled -c config/win64.cbc -v visualstudio package gstreamer-1.0
# Target Universal Windows Platform, x86_64
# Target UWP, x86_64
$ ./cerbero-uninstalled -c config/win64.cbc -v uwp package gstreamer-1.0
# Target Universal Windows Platform, Cross ARM64
# Target UWP, Cross ARM64
$ ./cerbero-uninstalled -c config/cross-win-arm64.cbc -v uwp package gstreamer-1.0
```
Note: Universal Windows Platform targets are currently experimental.
# Target UWP, All Supported Arches
$ ./cerbero-uninstalled -c config/cross-uwp-universal.cbc package gstreamer-1.0
```
# Enabling Optional Features with Variants
@ -358,7 +359,13 @@ MinGW. Both the Community build and the Professional build are supported. @@ -358,7 +359,13 @@ MinGW. Both the Community build and the Professional build are supported.
You must install the latest Windows 10 SDK when installing Visual Studio as
shown below. You do not need any older Windows SDKs.
![Select the Desktop development with C++ workload](/data/images/vs2017-installer-workloads.png)
![Select the 'Desktop development with C++' workload](/data/images/vs2017-installer-workloads.png)
If you want to build for UWP (aka Universal Windows Platform), you have to use
VS 2017 or newer, and you must *also* select the Universal Windows Platform
workload:
![Select both 'Desktop development with C++' and 'Universal Windows Platform development' workloads](/data/images/vs-installer-uwp-workload.png)
You can find all versions of Visual Studio at:
https://visualstudio.microsoft.com/vs/older-downloads/

7
cerbero/config.py

@ -285,12 +285,17 @@ class Config (object): @@ -285,12 +285,17 @@ class Config (object):
if self.vs_install_path:
m.message('Using Visual Studio installed at {!r}'.format(self.vs_install_path))
m.message('Install prefix will be {}'.format(self.prefix))
# Store current os.environ data
arches = []
if isinstance(self.universal_archs, dict):
arches = self.arch_config.keys()
for c in list(self.arch_config.values()):
self._create_path(c.local_sources)
self._create_path(c.sources)
self._create_path(c.logs)
m.message('Install prefix will be {}'.format(self.prefix))
if arches:
m.message('Building the following arches: ' + ' '.join(arches))
def do_setup_env(self):
self._create_path(self.prefix)

13
config/cross-uwp-universal.cbc

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
from cerbero.config import Platform, Architecture
target_platform = Platform.WINDOWS
variants.uwp = True
# NOTE: This gets overridden in the arch-specific cbc files
target_arch = Architecture.UNIVERSAL
universal_archs = {
# Path is relative to this file
Architecture.ARM64: "cross-win-arm64.cbc",
Architecture.X86: "win32.cbc",
Architecture.X86_64: "win64.cbc",
}

1
config/win64.cbc

@ -1,3 +1,2 @@ @@ -1,3 +1,2 @@
from cerbero.config import Architecture
arch = Architecture.X86_64
target_arch = Architecture.X86_64

29
config/windows.config

@ -81,6 +81,21 @@ def cmd(command, args=None, wrapper=None): @@ -81,6 +81,21 @@ def cmd(command, args=None, wrapper=None):
wrapper = []
return EnvValueCmd(wrapper + ['%s%s' % (tools_prefix, command)] + args)
# 'universal' is set by cerbero itself when building under a universal regime
# so that we can construct different paths to include/lib directories to where
# they actually are. Without this we don't know where the headers/libs will
# actually end up
if universal_archs:
incl_dir = os.path.join(prefix, target_arch, 'include')
lib_dir = os.path.join(prefix, target_arch, 'lib')
else:
incl_dir = os.path.join(prefix, 'include')
lib_dir = os.path.join(prefix, 'lib')
if target_arch != Architecture.UNIVERSAL and not os.path.exists(incl_dir):
os.makedirs(incl_dir)
if target_arch != Architecture.UNIVERSAL and not os.path.exists(lib_dir):
os.makedirs(lib_dir)
# Default GCC compiler flags
mingw_env_for_build_system['CPPFLAGS'] = EnvValueArg(arch_flags)
mingw_env_for_build_system['CFLAGS'] = EnvValueArg(arch_flags)
@ -110,9 +125,9 @@ if variants.uwp: @@ -110,9 +125,9 @@ if variants.uwp:
# When not cross-compiling, this is set using C{,PLUS}_INCLUDE_PATH in cerbero/config.py
if cross:
mingw_env_for_build_system['CPPFLAGS'] += ['-I' + os.path.join(prefix, 'include')]
mingw_env_for_build_system['CFLAGS'] += ['-I' + os.path.join(prefix, 'include')]
mingw_env_for_build_system['CXXFLAGS'] += ['-I' + os.path.join(prefix, 'include')]
mingw_env_for_build_system['CPPFLAGS'] += ['-I' + incl_dir]
mingw_env_for_build_system['CFLAGS'] += ['-I' + incl_dir]
mingw_env_for_build_system['CXXFLAGS'] += ['-I' + incl_dir]
ccache = use_ccache and ['ccache'] or []
@ -145,7 +160,7 @@ msvc_env_for_build_system['CXX'] = EnvValueCmd('cl') @@ -145,7 +160,7 @@ msvc_env_for_build_system['CXX'] = EnvValueCmd('cl')
msvc_env_for_build_system['AR'] = EnvValueCmd('lib')
# MinGW toolchain config env
mingw_env_for_toolchain['LIBRARY_PATH'] = EnvValuePath(['{}/lib{}'.format(prefix, lib_suffix)])
mingw_env_for_toolchain['LIBRARY_PATH'] = EnvValuePath([lib_dir])
# General env vars that should always be set
env['PERL'] = 'perl'
@ -168,7 +183,7 @@ env['lt_cv_deplibs_check_method'] = 'pass_all' @@ -168,7 +183,7 @@ env['lt_cv_deplibs_check_method'] = 'pass_all'
env['ac_cv_lib_bz2_BZ2_bzlibVersion'] = 'yes'
env['ac_cv_c_attribute_aligned'] = '64'
if platform == Platform.WINDOWS:
if platform == Platform.WINDOWS and target_arch != Architecture.UNIVERSAL:
# Make's job server is buggy and broken on Windows, which causes it to
# either hang or print server errors like:
# 2068442963 [sig] make 18324 sig_dispatch_pending: Win32 error 298 releasing sigcatch_nosync(0x150)
@ -197,8 +212,8 @@ if platform == Platform.WINDOWS: @@ -197,8 +212,8 @@ if platform == Platform.WINDOWS:
# We want the MSVC compiler and linker to find the headers and libraries
# provided by recipes built by us, so append to INCLUDE and LIB.
# NOTE: We do not want to add the MinGW toolchain paths here
msvc_env_for_toolchain['INCLUDE'] += [os.path.join(prefix, 'include')]
msvc_env_for_toolchain['LIB'] += [os.path.join(prefix, 'lib' + lib_suffix)]
msvc_env_for_toolchain['INCLUDE'] += [incl_dir]
msvc_env_for_toolchain['LIB'] += [lib_dir]
msvc_env_for_toolchain['WINDRES'] = EnvValueCmd('rc')
if variants.uwp:
meson_properties['needs_exe_wrapper'] = 'true'

BIN
data/images/vs-installer-uwp-workload.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Loading…
Cancel
Save