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

Add Windows implementations. #45

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d9ad23f
Add Windows implementations.
kazatsuyu Oct 23, 2021
cd3b210
Fix several environment variable error.
kazatsuyu Oct 23, 2021
a44d566
Fix generating build.gradle.kts bug.
kazatsuyu Oct 23, 2021
99c2c05
add egui example
zeerooth Oct 25, 2021
549addd
fix egui template on desktop
zeerooth Oct 25, 2021
3b2e730
Merge branch 'master' into egui-example
zeerooth Oct 28, 2021
ff8916e
bump egui_wgpu_backend to 0.14 in egui template
zeerooth Oct 28, 2021
a394f85
egui template: handle Resumed/Suspended events, start without a surfa…
zeerooth Oct 30, 2021
a6783d3
enable fullscreen in android by default
zeerooth Oct 30, 2021
18b8526
Merge branch 'master' into feature/windows
kazatsuyu Oct 31, 2021
0162ea4
Merge branch 'feature/windows' of https://github.com/kazatsuyu/cargo-…
zeerooth Nov 3, 2021
dda5123
enable windows in CI
zeerooth Nov 3, 2021
4e7e2d4
revert the accidental commits from another PR
zeerooth Nov 3, 2021
c1ded18
Fix build errors.
kazatsuyu Nov 4, 2021
8c8486d
Merge branch 'master' into feature/windows
kazatsuyu Nov 4, 2021
0f40b7b
Fix macos build errors.
kazatsuyu Nov 5, 2021
13831f6
Avoid Windows invalid UNC path.
kazatsuyu Nov 5, 2021
437f29e
Link assets directory on build time
kazatsuyu Nov 5, 2021
e366a81
Fix path errors.
kazatsuyu Nov 5, 2021
469c7ce
Fix symlink target path mistake.
kazatsuyu Nov 6, 2021
76f04bf
Refix symlink path.
kazatsuyu Nov 6, 2021
6f4ae53
Revert "Refix symlink path."
kazatsuyu Nov 9, 2021
c06a750
Revert "Fix symlink target path mistake."
kazatsuyu Nov 9, 2021
cafeca5
Revert "Link assets directory on build time"
kazatsuyu Nov 9, 2021
266f2d0
Symlink for windows.
kazatsuyu Nov 13, 2021
d0dab09
Add error message for unpriviledged Windows.
kazatsuyu Nov 13, 2021
1280bd3
Add missing trailing newline in Cargo.toml
kazatsuyu Nov 13, 2021
7037e0c
Remove syncAssets task.
kazatsuyu Nov 13, 2021
10d7cc8
Remove one level of redundant `assets`
kazatsuyu Nov 14, 2021
fa4862a
Refactoring a little
kazatsuyu Nov 14, 2021
879f42f
Use Clobber::FileOrDirectory instead of Clobber::File
kazatsuyu Nov 14, 2021
e45a1fc
Merge branch 'master' into feature/windows
zeerooth Nov 15, 2021
a64450a
add simple prefix_path tests
zeerooth Nov 15, 2021
2cdd8d3
Merge branch 'master' into feature/windows
kazatsuyu Nov 28, 2021
0cd4a6a
Use original target path in error message.
kazatsuyu Nov 28, 2021
2a1de52
Use std symlink function instead of WinAPI
kazatsuyu Nov 28, 2021
a4bd539
Add Windows specific Env struct.
kazatsuyu Nov 28, 2021
398db8c
update README.md with information about Windows support
zeerooth Nov 29, 2021
4ce2044
resolve conflicts
zeerooth Dec 14, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
matrix:
rust_version: [stable, beta, nightly]
platform:
# - { target: x86_64-pc-windows-msvc, os: windows-latest }
- { target: x86_64-pc-windows-msvc, os: windows-latest }
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest }
- { target: x86_64-apple-darwin, os: macos-latest }

Expand Down
108 changes: 108 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ bicycle = { git = "https://github.com/BrainiumLLC/bicycle", rev = "28080e0c6fa40
bossy = "0.2.1"
colored = "1.9.3"
deunicode = "1.1.1"
dunce = "1.0.2"
english-numbers = "0.3.3"
env_logger = "0.7.1"
heck = "0.3.1"
Expand Down Expand Up @@ -62,7 +63,15 @@ ureq = "2.2.0"
freedesktop_entry_parser = "1.1"
lexical-core = "0.7.6"

[target.'cfg(windows)'.dependencies]
const-utf16 = "0.2.1"
windows = "0.21.1"

[build-dependencies]
bicycle = { git = "https://github.com/BrainiumLLC/bicycle", rev = "28080e0c6fa4067d9dd1b0f2b7322b6b32178e1f" }
hit = "0.1.0"
home = "0.5.3"

[target.'cfg(windows)'.build-dependencies]
embed-resource = "1.6.4"
windows = "0.21.1"
27 changes: 27 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,31 @@ fn main() {
)
.expect("failed to process actions");
}

#[cfg(windows)]
{
// Embed application manifest
let resource_path = manifest_dir.join("cargo-mobile-manifest.rc");
let manifest_path = manifest_dir.join("cargo-mobile.exe.manifest");
println!("cargo:rerun-if-changed={}", resource_path.display());
println!("cargo:rerun-if-changed={}", manifest_path.display());
embed_resource::compile("cargo-mobile-manifest.rc");

// Build winapi bindings
windows::build! {
Windows::Win32::{
Foundation::MAX_PATH,
System::{
Diagnostics::Debug::{GetLastError, WIN32_ERROR},
Memory::LocalFree,
SystemInformation::{VerifyVersionInfoW, VerSetConditionMask},
SystemServices::{VER_EQUAL, VER_GREATER_EQUAL},
Registry::HKEY_LOCAL_MACHINE,

},
UI::Shell::{ASSOCF_INIT_IGNOREUNKNOWN, AssocQueryStringW, CommandLineToArgvW, SHRegGetPathW},
Storage::FileSystem::CreateHardLinkW,
},
}
}
}
2 changes: 2 additions & 0 deletions cargo-mobile-manifest.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#define RT_MANIFEST 24
1 RT_MANIFEST "cargo-mobile.exe.manifest"
40 changes: 40 additions & 0 deletions cargo-mobile.exe.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity
type="win32"
name="cargo-mobile"
version="0.1.0.0"
processorArchitecture="x86"
/>
<description>cargo-mobile</description>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
</application>
</compatibility>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<!--
UAC settings:
- app should run at same integrity level as calling process
- app does not need to manipulate windows belonging to
higher-integrity-level processes
-->
<requestedExecutionLevel
level="asInvoker"
uiAccess="false"
/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
2 changes: 1 addition & 1 deletion src/android/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub enum Error {
MetadataFailed(metadata::Error),
Unsupported,
ProjectDirAbsent { project_dir: PathBuf },
OpenFailed(bossy::Error),
OpenFailed(os::OpenFileError),
CheckFailed(CompileLibError),
BuildFailed(BuildError),
RunFailed(RunError),
Expand Down
9 changes: 3 additions & 6 deletions src/android/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use super::{
use crate::{
env::ExplicitEnv as _,
opts::{self, FilterLevel, NoiseLevel, Profile},
os::{consts, gradlew_command},
util::{
self,
cli::{Report, Reportable},
Expand All @@ -19,11 +20,7 @@ use std::{
};

fn gradlew(config: &Config, env: &Env) -> bossy::Command {
let gradlew_path = config.project_dir().join("gradlew");
bossy::Command::pure(&gradlew_path)
.with_env_vars(env.explicit_env())
.with_arg("--project-dir")
.with_arg(config.project_dir())
gradlew_command(&config.project_dir()).with_env_vars(env.explicit_env())
}

#[derive(Debug)]
Expand Down Expand Up @@ -371,7 +368,7 @@ impl<'a> Device<'a> {
pub fn stacktrace(&self, config: &Config, env: &Env) -> Result<(), StacktraceError> {
// -d = print and exit
let logcat_command = adb::adb(env, &self.serial_no).with_args(&["logcat", "-d"]);
let stack_command = bossy::Command::pure("ndk-stack")
let stack_command = bossy::Command::pure(env.ndk.home().join(consts::NDK_STACK))
.with_env_vars(env.explicit_env())
.with_env_var(
"PATH",
Expand Down
22 changes: 13 additions & 9 deletions src/android/jnilibs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use super::{config::Config, target::Target};
#[cfg(windows)]
use crate::os;
use crate::{
target::TargetTrait as _,
util::{
Expand Down Expand Up @@ -118,15 +120,17 @@ impl JniLibs {
pub fn symlink_lib(&self, src: &Path) -> Result<(), SymlinkLibError> {
log::info!("symlinking lib {:?} in jniLibs dir {:?}", src, self.path);
if src.is_file() {
ln::force_symlink(
src,
self.path.join(
src.file_name()
.expect("developer error: file had no file name"),
),
ln::TargetStyle::File,
)
.map_err(SymlinkLibError::SymlinkFailed)
let dest = self.path.join(
src.file_name()
.expect("developer error: file had no file name"),
);
#[cfg(not(windows))]
ln::force_symlink(src, &dest, ln::TargetStyle::File)
.map_err(SymlinkLibError::SymlinkFailed)?;
#[cfg(windows)]
os::ln::force_hard_link_or_copy_file(src, &dest)
.map_err(SymlinkLibError::SymlinkFailed)?;
Ok(())
} else {
Err(SymlinkLibError::SourceMissing(src.to_owned()))
}
Expand Down
16 changes: 10 additions & 6 deletions src/android/ndk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use super::{
source_props::{self, SourceProps},
target::Target,
};
use crate::util::cli::{Report, Reportable};
use crate::{
os::consts,
util::cli::{Report, Reportable},
};
use once_cell_regex::regex_multi_line;
use std::{
collections::HashSet,
Expand Down Expand Up @@ -45,8 +48,8 @@ pub enum Compiler {
impl Compiler {
fn as_str(&self) -> &'static str {
match self {
Compiler::Clang => "clang",
Compiler::Clangxx => "clang++",
Compiler::Clang => consts::CLANG,
Compiler::Clangxx => consts::CLANGXX,
}
}
}
Expand All @@ -61,8 +64,8 @@ pub enum Binutil {
impl Binutil {
fn as_str(&self) -> &'static str {
match self {
Binutil::Ar => "ar",
Binutil::Ld => "ld",
Binutil::Ar => consts::AR,
Binutil::Ld => consts::LD,
}
}
}
Expand Down Expand Up @@ -260,7 +263,8 @@ impl Env {

fn readelf_path(&self, triple: &str) -> Result<PathBuf, MissingToolError> {
MissingToolError::check_file(
self.tool_dir()?.join(format!("{}-readelf", triple)),
self.tool_dir()?
.join(format!("{}-{}", triple, consts::READELF)),
"readelf",
)
}
Expand Down
Loading