Skip to content

Crate to detect everything needed to build/link things on Windows.

License

Notifications You must be signed in to change notification settings

den-mentiei/thound

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

T H O U N D

Latest Version MIT licensed API

Overview

The purpose of this is to find the folders that contain libraries you may need to link against, on Windows, if you are linking with any compiled C or C++ code. This will be necessary for many non-C++ programming language environments that wnat to provide compatibility.

Getting started

Add thound to your Cargo.toml:

[dependencies]
thound = "0.1"

Usage

The usage is pretty straight-forward, just call the only available function and use the result with information contained:

fn main() {
	let info = thound::find_vc_and_windows_sdk();
	println!("{info:#?}");
}

...and it will emit something like the following:

Some(
    Info {
        sdk: Some(
            SdkInfo {
                major_version: 10,
                root: "C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.22000.0",
                um_lib_path: "C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.22000.0\\um\\x64",
                ucrt_lib_path: "C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.22000.0\\ucrt\\x64",
            },
        ),
        toolchain: Some(
            ToolchainInfo {
                exe_path: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.36.32532\\bin\\Hostx64\\x64",
                lib_path: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.36.32532\\lib\\x64",
            },
        ),
    },
)

Implementation notes

One of the goals for this implementation was to be as dependency-free and quick compiling as possible. As a result, this crate has zero dependencies except std.

Having no dependencies, means the code contains the minimal Windows API & COM shenanigans, required to do its job. Those could be replaced by windows-rs, but it wasn't done on purpose.

Note

The following is originally written by Jonathan Blow and it mirrors my thoughts and explains the reason for this crate to exist.

// I hate this kind of code. The fact that we have to do this at all
// is stupid, and the actual maneuvers we need to go through
// are just painful. If programming were like this all the time,
// I would quit.
//
// Because this is such an absurd waste of time, I felt it would be
// useful to package the code in an easily-reusable way

Alternatives

Microsoft provides its own solution to this problem, called "vswhere", is a much bigger program (a binary then!) I don't want to deal with in most cases.

License

This crate is licensed under the MIT license. Implementation is a Rust port of the Original code by Jonathan Blow, which was released under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Thound by you, shall be licensed as MIT, without any additional terms or conditions.

About

Crate to detect everything needed to build/link things on Windows.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages