Skip to content

Commit 98cc46e

Browse files
committed
move Windows code into a module
1 parent a803745 commit 98cc46e

File tree

11 files changed

+42
-35
lines changed

11 files changed

+42
-35
lines changed

src/lib.rs

+7-20
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,10 @@ use std::thread::{self, JoinHandle};
6969
mod os_pipe;
7070
#[cfg(feature = "parallel")]
7171
mod parallel;
72-
// These modules are all glue to support reading the MSVC version from
73-
// the registry and from COM interfaces
74-
#[cfg(windows)]
75-
mod registry;
76-
#[cfg(windows)]
77-
#[macro_use]
78-
mod winapi;
79-
#[cfg(windows)]
80-
mod com;
81-
#[cfg(windows)]
82-
mod setup_config;
83-
#[cfg(windows)]
84-
mod vs_instances;
85-
#[cfg(windows)]
86-
mod windows_sys;
87-
88-
pub mod windows_registry;
72+
mod windows;
73+
// Regardless of whether this should be in this crate's public API,
74+
// it has been since 2015, so don't break it.
75+
pub use windows::find_tools as windows_registry;
8976

9077
/// A builder for compilation of a native library.
9178
///
@@ -2195,7 +2182,7 @@ impl Build {
21952182
} else {
21962183
"ml.exe"
21972184
};
2198-
let mut cmd = windows_registry::find(&target, tool).unwrap_or_else(|| self.cmd(tool));
2185+
let mut cmd = windows::find_tools::find(&target, tool).unwrap_or_else(|| self.cmd(tool));
21992186
cmd.arg("-nologo"); // undocumented, yet working with armasm[64]
22002187
for directory in self.include_directories.iter() {
22012188
cmd.arg("-I").arg(&**directory);
@@ -2551,7 +2538,7 @@ impl Build {
25512538
traditional
25522539
};
25532540

2554-
let cl_exe = windows_registry::find_tool(target, "cl.exe");
2541+
let cl_exe = windows::find_tools::find_tool(target, "cl.exe");
25552542

25562543
let tool_opt: Option<Tool> = self
25572544
.env_tool(env)
@@ -3022,7 +3009,7 @@ impl Build {
30223009

30233010
if lib.is_empty() {
30243011
name = String::from("lib.exe");
3025-
let mut cmd = match windows_registry::find(&target, "lib.exe") {
3012+
let mut cmd = match windows::find_tools::find(&target, "lib.exe") {
30263013
Some(t) => t,
30273014
None => self.cmd("lib.exe"),
30283015
};

src/os_pipe/windows.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::windows_sys::{CreatePipe, INVALID_HANDLE_VALUE};
1+
use crate::windows::windows_sys::{CreatePipe, INVALID_HANDLE_VALUE};
22
use std::{fs::File, io, os::windows::prelude::*, ptr};
33

44
/// NOTE: These pipes do not support IOCP.

src/parallel/job_token/windows.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{
33
io, ptr,
44
};
55

6-
use crate::windows_sys::{
6+
use crate::windows::windows_sys::{
77
OpenSemaphoreA, ReleaseSemaphore, WaitForSingleObject, FALSE, HANDLE, SEMAPHORE_MODIFY_STATE,
88
THREAD_SYNCHRONIZE, WAIT_ABANDONED, WAIT_FAILED, WAIT_OBJECT_0, WAIT_TIMEOUT,
99
};

src/com.rs src/windows/com.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#![allow(unused)]
99

10-
use crate::{
10+
use crate::windows::{
1111
winapi::{IUnknown, Interface},
1212
windows_sys::{
1313
CoInitializeEx, SysFreeString, SysStringLen, BSTR, COINIT_MULTITHREADED, HRESULT, S_FALSE,

src/windows_registry.rs src/windows/find_tools.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@ pub fn find_vs_version() -> Result<VsVers, String> {
159159

160160
#[cfg(windows)]
161161
mod impl_ {
162-
use crate::com;
163-
use crate::registry::{RegistryKey, LOCAL_MACHINE};
164-
use crate::setup_config::SetupConfiguration;
165-
use crate::vs_instances::{VsInstances, VswhereInstance};
162+
use crate::windows::com;
163+
use crate::windows::registry::{RegistryKey, LOCAL_MACHINE};
164+
use crate::windows::setup_config::SetupConfiguration;
165+
use crate::windows::vs_instances::{VsInstances, VswhereInstance};
166166
use std::convert::TryFrom;
167167
use std::env;
168168
use std::ffi::OsString;

src/windows/mod.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//! These modules are all glue to support reading the MSVC version from
2+
//! the registry and from COM interfaces.
3+
4+
// This is used in the crate's public API, so don't use #[cfg(windows)]
5+
pub mod find_tools;
6+
7+
#[cfg(windows)]
8+
pub(crate) mod windows_sys;
9+
10+
#[cfg(windows)]
11+
mod registry;
12+
#[cfg(windows)]
13+
#[macro_use]
14+
mod winapi;
15+
#[cfg(windows)]
16+
mod com;
17+
#[cfg(windows)]
18+
mod setup_config;
19+
#[cfg(windows)]
20+
mod vs_instances;

src/registry.rs src/windows/registry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use crate::windows_sys::{
11+
use crate::windows::windows_sys::{
1212
RegCloseKey, RegEnumKeyExW, RegOpenKeyExW, RegQueryValueExW, ERROR_NO_MORE_ITEMS,
1313
ERROR_SUCCESS, HKEY, HKEY_LOCAL_MACHINE, KEY_READ, KEY_WOW64_32KEY, REG_SZ,
1414
};

src/setup_config.rs src/windows/setup_config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#![allow(bad_style)]
99
#![allow(unused)]
1010

11-
use crate::{
11+
use crate::windows::{
1212
com::{BStr, ComPtr},
1313
winapi::{
1414
IUnknown, IUnknownVtbl, Interface, LCID, LPCOLESTR, LPCWSTR, LPFILETIME, LPSAFEARRAY,

src/vs_instances.rs src/windows/vs_instances.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::convert::TryFrom;
44
use std::io::BufRead;
55
use std::path::PathBuf;
66

7-
use crate::setup_config::{EnumSetupInstances, SetupInstance};
7+
use crate::windows::setup_config::{EnumSetupInstances, SetupInstance};
88

99
pub enum VsInstance {
1010
Com(SetupInstance),

src/winapi.rs src/windows/winapi.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::os::raw;
1111

1212
pub type wchar_t = u16;
1313

14-
pub use crate::windows_sys::{FILETIME, GUID, HRESULT, SAFEARRAY};
14+
pub use crate::windows::windows_sys::{FILETIME, GUID, HRESULT, SAFEARRAY};
1515

1616
pub type REFIID = *const IID;
1717
pub type IID = GUID;
@@ -37,7 +37,7 @@ macro_rules! DEFINE_GUID {
3737
$name:ident, $l:expr, $w1:expr, $w2:expr,
3838
$b1:expr, $b2:expr, $b3:expr, $b4:expr, $b5:expr, $b6:expr, $b7:expr, $b8:expr
3939
) => {
40-
pub const $name: $crate::winapi::GUID = $crate::winapi::GUID {
40+
pub const $name: $crate::windows::winapi::GUID = $crate::windows::winapi::GUID {
4141
data1: $l,
4242
data2: $w1,
4343
data3: $w2,
@@ -121,10 +121,10 @@ macro_rules! RIDL {
121121
$l:expr, $w1:expr, $w2:expr,
122122
$b1:expr, $b2:expr, $b3:expr, $b4:expr, $b5:expr, $b6:expr, $b7:expr, $b8:expr
123123
) => (
124-
impl $crate::winapi::Interface for $interface {
124+
impl $crate::windows::winapi::Interface for $interface {
125125
#[inline]
126-
fn uuidof() -> $crate::winapi::GUID {
127-
$crate::winapi::GUID {
126+
fn uuidof() -> $crate::windows::winapi::GUID {
127+
$crate::windows::winapi::GUID {
128128
data1: $l,
129129
data2: $w1,
130130
data3: $w2,
File renamed without changes.

0 commit comments

Comments
 (0)