gfx/vr/service/openvr/moz.build
author Nika Layzell <nika@thelayzells.com>
Tue, 25 Sep 2018 17:34:53 +0200
changeset 504874 e0f95dd96d5458f60980f1e8b3f846beed6e5817
parent 504111 c12b84f575c3fe48d72f3c8c24a54b3dee1cc985
child 504886 9bfe29337ffe3d93cd060077e2e999e72bb9b7cf
permissions -rw-r--r--
Bug 1448426 - Wrap windows.h to avoid problematic define statements, r=froydnj,glandium By default, windows.h exposes a large number of problematic define statements which are UpperCamelCase, such as a define from `CreateWindow` to `CreateWindow{A,W}`. As many of these names are generic (e.g. CreateFile, CreateWindow), they can mess up Gecko code that may legitimately have its own methods with the same names. The header also defines some traditional SCREAMING_SNAKE_CASE defines which can mess up our code by conflicting with local values. This patch adds a simple code generator which generates wrappers for these defines, and uses them to wrap the windows.h wrapper using the `stl_wrappers` mechanism, allowing us to use windows.h in more places. Differential Revision: https://phabricator.services.mozilla.com/D10932

# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

FINAL_LIBRARY = 'xul'

DEFINES['VR_API_PUBLIC'] = True

# Windows.h wrappers conflict with internal methods in openvr
DEFINES['MOZ_DISABLE_WINDOWS_WRAPPER'] = True

if CONFIG['OS_ARCH'] == 'WINNT':
    if CONFIG['HAVE_64BIT_BUILD']:
        DEFINES['WIN64'] = True
    else:
        DEFINES['WIN32'] = True

if CONFIG['OS_ARCH'] == 'Darwin':
    DEFINES['POSIX'] = True
    DEFINES['OSX'] = True
    if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
        CXXFLAGS += ['-xobjective-c++']

if CONFIG['OS_ARCH'] == 'Linux':
    DEFINES['POSIX'] = True
    DEFINES['LINUX'] = True
    if CONFIG['HAVE_64BIT_BUILD']:
        DEFINES['LINUX64'] = True
    else:
        DEFINES['LINUX32'] = True

LOCAL_INCLUDES += [
    '/toolkit/components/jsoncpp/include',
]

USE_LIBS += [
    'jsoncpp',
]

EXPORTS += [
    'headers/openvr.h',
]

SOURCES += [
    'src/dirtools_public.cpp',
    'src/envvartools_public.cpp',
    'src/hmderrors_public.cpp',
    'src/openvr_api_public.cpp',
    'src/pathtools_public.cpp',
    'src/sharedlibtools_public.cpp',
    'src/strtools_public.cpp',
    'src/vrpathregistry_public.cpp',
]

if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
    # Harmless warnings in 3rd party code
    CXXFLAGS += [
        '-Wno-error=parentheses',
        '-Wno-error=unused-variable',
    ]