Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust-project: remove hardcoded mode file in OSS build #659

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jazzdan
Copy link
Contributor

@jazzdan jazzdan commented May 17, 2024

With this patch I am able to run the following command in a non-fbcode buck project and get a functioning rust-project.json file:

rust-project develop --prefer-rustup-managed-toolchain //my:target

Fixes #519

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 17, 2024
@jazzdan
Copy link
Contributor Author

jazzdan commented May 17, 2024

I have this test too but not sure how useful it would be

fn test_select_mode() {
    // Test default behavior without the fbcode_build feature
    assert_eq!(select_mode(None), None);
    assert_eq!(
        select_mode(Some("custom-mode")),
        Some("custom-mode".to_owned())
    );

    // Test behavior with the fbcode_build feature enabled
    #[cfg(all(feature = "fbcode_build", target_os = "macos"))]
    {
        assert_eq!(select_mode(None), Some("@fbcode//mode/mac".to_owned()));
        assert_eq!(
            select_mode(Some("custom-mode")),
            Some("custom-mode".to_owned())
        );
    }

    #[cfg(all(feature = "fbcode_build", target_os = "windows"))]
    {
        assert_eq!(select_mode(None), Some("@fbcode//mode/win".to_owned()));
        assert_eq!(
            select_mode(Some("custom-mode")),
            Some("custom-mode".to_owned())
        );
    }

    #[cfg(all(
        feature = "fbcode_build",
        not(any(target_os = "macos", target_os = "windows"))
    ))]
    {
        assert_eq!(select_mode(None), None);
        assert_eq!(
            select_mode(Some("custom-mode")),
            Some("custom-mode".to_owned())
        );
    }
}

@davidbarsky
Copy link
Contributor

I have this test too but not sure how useful it would be

fn test_select_mode() {
    // Test default behavior without the fbcode_build feature
    assert_eq!(select_mode(None), None);
    assert_eq!(
        select_mode(Some("custom-mode")),
        Some("custom-mode".to_owned())
    );

    // Test behavior with the fbcode_build feature enabled
    #[cfg(all(feature = "fbcode_build", target_os = "macos"))]
    {
        assert_eq!(select_mode(None), Some("@fbcode//mode/mac".to_owned()));
        assert_eq!(
            select_mode(Some("custom-mode")),
            Some("custom-mode".to_owned())
        );
    }

    #[cfg(all(feature = "fbcode_build", target_os = "windows"))]
    {
        assert_eq!(select_mode(None), Some("@fbcode//mode/win".to_owned()));
        assert_eq!(
            select_mode(Some("custom-mode")),
            Some("custom-mode".to_owned())
        );
    }

    #[cfg(all(
        feature = "fbcode_build",
        not(any(target_os = "macos", target_os = "windows"))
    ))]
    {
        assert_eq!(select_mode(None), None);
        assert_eq!(
            select_mode(Some("custom-mode")),
            Some("custom-mode".to_owned())
        );
    }
}

It'd be great to have this test because the CI will be running with and without fbcode build :)

@jazzdan
Copy link
Contributor Author

jazzdan commented May 19, 2024

@davidbarsky done!

@facebook-github-bot
Copy link
Contributor

@davidbarsky has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

using rust-project external to facebook
3 participants