BrettMayson / HEMTT

Build System for Arma 3
http://hemtt.dev/
GNU General Public License v2.0
113 stars 40 forks source link

Binarizer not found warning not displayed on Linux #265

Closed jonpas closed 4 years ago

jonpas commented 4 years ago

HEMTT Version: 0.7.4 (stable) Project: Any

Description:

Output some information about used or unused binarizer (Windows/Linux) as is the case with armake2.

Steps to reproduce:

Additional information:

N/A

HEMTT Output:

N/A

BrettMayson commented 4 years ago

This should already be the case

BrettMayson commented 4 years ago

hemtt build --debug will also tell you where the binarize executable was found

jonpas commented 4 years ago

Debug does indeed, but it's crowded in a lot of other debug data, and it does it only on Windows if binarizer is found. I think that's pretty important to show to the user and should be displayed in normal mode. At least if it's binarizing or not binarizing.

BrettMayson commented 4 years ago
if match armake2::find_binarize_exe() {
    Ok(p) => {
        debug!("binarize found at {:?}", p);
        p.exists()
    }
    Err(_) => false,
} {
    true
} else {
    warnmessage!("Unable to locate binarize.exe", "Files will be packed as is");
    false
};

It prints a message if binarize is not found

jonpas commented 4 years ago

I am not seeing the warning message anywhere (release or normal build).

if {
    // code
} {
    true
} else {
    // code
}

How does this work?

BrettMayson commented 4 years ago
match armake2::find_binarize_exe() {
    Ok(p) => {
        debug!("binarize found at {:?}", p);
        p.exists()
    }
    Err(_) => false,
}

find_binarize_exe returns a Result<Path, Error>, the match is used to get the path if it is Ok. If it is Ok it calls p.exists() which will return a boolean. The find_binarize_exe was unable to find the executable then it ignores the error and just returns false. The resulting boolean is then what is fed into the wrapping if statement. It's not

if {
  // code
} {

}

it's

if (code) {

}
jonpas commented 4 years ago

Alright, I see.

And I also see why it doesn't work. That match will never run if this is not on Windows. Rust does lazy evaluation, so as soon as cfg!(windows) is false, it stops evaluating that condition, meaning match find_binarize_exe() will never run and thus never print an error.

274