Skip to content

Commit

Permalink
[wip] draft-292: Minimal mingw build
Browse files Browse the repository at this point in the history
  • Loading branch information
gavv committed Jul 12, 2024
1 parent 195e207 commit e55137e
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 1 deletion.
10 changes: 9 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ supported_platforms = [
'linux',
'unix',
'darwin',
'windows',
'android',
]

Expand Down Expand Up @@ -568,6 +569,8 @@ if not meta.platform:
meta.platform = 'darwin'
elif 'gnu' in meta.host:
meta.platform = 'unix'
elif 'mingw' in meta.host:
meta.platform = 'windows'

if not meta.platform and meta.host == meta.build:
if os.name == 'posix':
Expand Down Expand Up @@ -757,7 +760,7 @@ if GetOption('override_targets'):
for t in GetOption('override_targets').split(','):
env['ROC_TARGETS'] += ['target_' + t]
else:
if meta.platform in ['linux', 'darwin', 'unix']:
if meta.platform in ['linux', 'darwin', 'unix', 'windows']:
env.Append(ROC_TARGETS=[
'target_pc',
])
Expand Down Expand Up @@ -789,6 +792,11 @@ else:
'target_darwin',
])

if meta.platform in ['windows']:
env.Append(ROC_TARGETS=[
'target_windows',
])

if meta.platform in ['android']:
env.Append(ROC_TARGETS=[
'target_android',
Expand Down
1 change: 1 addition & 0 deletions scripts/scons_plugin/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def getverstr():
version_formats = [
r'(\b[0-9]+\.[0-9]+\.[0-9]+\b)',
r'(\b[0-9]+\.[0-9]+\b)',
r'(\b[0-9]+)-win32\b',
]

full_text = env.GetCommandOutput(compiler + ' --version')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2024 Roc Streaming authors
*
* 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/.
*/

//! @file roc_core/target_windows/roc_core/cpu_instructions.h
//! @brief CPU-specific instructions.

#ifndef ROC_CORE_CPU_INSTRUCTIONS_H_
#define ROC_CORE_CPU_INSTRUCTIONS_H_

#include "roc_core/stddefs.h"

namespace roc {
namespace core {

//! CPU pause instruction.
//! @remarks
//! Doesn't include any memory barriers, so the caller is responsible to
//! insert them into the loop. Allowed to expand to nothing.
inline void cpu_relax() {
YieldProcessor();
}

} // namespace core
} // namespace roc

#endif // ROC_CORE_CPU_INSTRUCTIONS_H_
33 changes: 33 additions & 0 deletions src/internal_modules/roc_core/target_windows/roc_core/cpu_traits.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2024 Roc Streaming authors
*
* 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/.
*/

//! @file roc_core/target_windows/roc_core/cpu_traits.h
//! @brief CPU traits.

#ifndef ROC_CORE_CPU_TRAITS_H_
#define ROC_CORE_CPU_TRAITS_H_

#include "roc_core/stddefs.h"

//! Values of ROC_CPU_ENDIAN indicating little- or big-endian CPU.
#define ROC_CPU_BE 1
#define ROC_CPU_LE 2

// CPU endianess.
// Assume that windows always runs on little-endian.
#define ROC_CPU_ENDIAN ROC_CPU_LE

// Detect CPU bitness.

#ifdef _WIN64
#define ROC_CPU_BITS 64
#else
#define ROC_CPU_BITS 32
#endif

#endif // ROC_CORE_CPU_TRAITS_H_
32 changes: 32 additions & 0 deletions src/internal_modules/roc_core/target_windows/roc_core/stddefs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2024 Roc Streaming authors
*
* 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/.
*/

//! @file roc_core/target_windows/roc_core/stddefs.h
//! @brief Commonly used types and functions.

#ifndef ROC_CORE_STDDEFS_H_
#define ROC_CORE_STDDEFS_H_

#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdarg>
#include <cstddef>
#include <ctime>
#include <new>

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <windows.h>
#include <winnt.h>

#endif // ROC_CORE_STDDEFS_H_

0 comments on commit e55137e

Please sign in to comment.