-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
compile_for_everything()
to embed the manifest in the test binary
And also do this for the harp test binary, which starts R and tests UTF-8 related capabilities.
- Loading branch information
1 parent
3495301
commit 2d9c0b5
Showing
14 changed files
with
186 additions
and
50 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* locale.rs | ||
* | ||
* Copyright (C) 2024 Posit Software, PBC. All rights reserved. | ||
* | ||
*/ | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::test::r_test; | ||
|
||
#[test] | ||
fn test_locale() { | ||
// These tests assert that we've embedded our Application Manifest file correctly in `build.rs` | ||
r_test(|| { | ||
let latin1 = harp::parse_eval_base("l10n_info()$`Latin-1`").unwrap(); | ||
let latin1 = bool::try_from(latin1).unwrap(); | ||
assert!(!latin1); | ||
|
||
let utf8 = harp::parse_eval_base("l10n_info()$`UTF-8`").unwrap(); | ||
let utf8 = bool::try_from(utf8).unwrap(); | ||
assert!(utf8); | ||
|
||
let codepage = harp::parse_eval_base("l10n_info()$codepage").unwrap(); | ||
let codepage = i32::try_from(codepage).unwrap(); | ||
assert_eq!(codepage, 65001); | ||
|
||
let system_codepage = harp::parse_eval_base("l10n_info()$system.codepage").unwrap(); | ||
let system_codepage = i32::try_from(system_codepage).unwrap(); | ||
assert_eq!(system_codepage, 65001); | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// build.rs | ||
// | ||
// Copyright (C) 2024 Posit Software, PBC. All rights reserved. | ||
// | ||
// | ||
|
||
use std::path::Path; | ||
extern crate embed_resource; | ||
|
||
fn main() { | ||
// Embed an Application Manifest file on Windows. | ||
// Documented to do nothing on non-Windows. | ||
// We also do this for ark. | ||
// We don't generate a main `harp.exe` binary, but `cargo test` does generate a `harp-*.exe` | ||
// binary for unit testing, and those unit tests also start R and test UTF-8 related capabilities! | ||
// So we need that test executable to include a manifest file too. | ||
let resource = Path::new("resources") | ||
.join("manifest") | ||
.join("harp-manifest.rc"); | ||
embed_resource::compile_for_everything(resource, embed_resource::NONE); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Autogenerated, do not modify! | ||
|
||
// This is a C file that embed-resource compiles for us. | ||
// It helps embed our Windows Application Manifest file. | ||
// https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests | ||
// https://learn.microsoft.com/en-us/cpp/build/reference/manifest-create-side-by-side-assembly-manifest?view=msvc-170 | ||
|
||
// This defines `RT_MANIFEST` to `24`. embed-resource should know how to ensure the header is available. | ||
// https://github.com/nabijaczleweli/rust-embed-resource/issues/11#issuecomment-779295722 | ||
#include <winuser.h> | ||
|
||
// The `1` is a `resource_id` that specifies us as an executable file | ||
1 RT_MANIFEST "harp.exe.manifest" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> | ||
|
||
<assemblyIdentity version="1.0.0.0" name="harp" type="win32"/> | ||
|
||
<description>harp</description> | ||
|
||
<!-- Support UTF-8 code page with R 4.2.0 and newer. --> | ||
<application> | ||
<windowsSettings> | ||
<activeCodePage xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">UTF-8</activeCodePage> | ||
</windowsSettings> | ||
</application> | ||
|
||
<!-- Identify the application security requirements. --> | ||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> | ||
<security> | ||
<requestedPrivileges> | ||
<requestedExecutionLevel level="asInvoker"/> | ||
</requestedPrivileges> | ||
</security> | ||
</trustInfo> | ||
|
||
<!-- Declare compatibility with different versions of Windows. --> | ||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> | ||
<application> | ||
<!-- Windows 10 and Windows 11 --> | ||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> | ||
<!-- Windows 8.1 --> | ||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> | ||
<!-- Windows Vista --> | ||
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> | ||
<!-- Windows 7 --> | ||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> | ||
<!-- Windows 8 --> | ||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> | ||
</application> | ||
</compatibility> | ||
|
||
</assembly> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ | |
|
||
pub mod library; | ||
pub mod line_ending; | ||
mod locale; | ||
pub mod polled_events; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* locale.rs | ||
* | ||
* Copyright (C) 2024 Posit Software, PBC. All rights reserved. | ||
* | ||
*/ | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::test::r_test; | ||
|
||
#[test] | ||
fn test_locale() { | ||
// These tests assert that we've embedded our Application Manifest file correctly in `build.rs` | ||
r_test(|| { | ||
let latin1 = harp::parse_eval_base("l10n_info()$`Latin-1`").unwrap(); | ||
let latin1 = bool::try_from(latin1).unwrap(); | ||
assert!(!latin1); | ||
|
||
let utf8 = harp::parse_eval_base("l10n_info()$`UTF-8`").unwrap(); | ||
let utf8 = bool::try_from(utf8).unwrap(); | ||
assert!(utf8); | ||
|
||
let codepage = harp::parse_eval_base("l10n_info()$codepage").unwrap(); | ||
let codepage = i32::try_from(codepage).unwrap(); | ||
assert_eq!(codepage, 65001); | ||
|
||
let system_codepage = harp::parse_eval_base("l10n_info()$system.codepage").unwrap(); | ||
let system_codepage = i32::try_from(system_codepage).unwrap(); | ||
assert_eq!(system_codepage, 65001); | ||
}) | ||
} | ||
} |