Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
mass10 committed Jun 1, 2024
1 parent a4b302c commit 471aec4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
14 changes: 5 additions & 9 deletions cli/application/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ fn execute_command(commands: &[&str]) -> Result<(), Box<dyn std::error::Error>>

/// MSBuild.exe のパスを返します。
fn detect_msbuild() -> String {
let msbuild = util::getenv("PP_MSBUILD");
if msbuild != "" {
return msbuild;
}
return "MSBuild.exe".to_string();
}

Expand All @@ -47,13 +43,13 @@ pub fn run_build() -> Result<(), Box<dyn std::error::Error>> {
info!("##### START BUILD #####");

// ビルドの出力ファイル
const OUT_PATH: &str = r#"bin\Release\PTouchPrintSender.exe"#;
const OUT_PATH: &str = r"PtouchPrintSenderApp\bin\Release\PTouchPrintSender.exe";

// 最初のタイムスタンプ
let former_filetime = util::get_filetime(OUT_PATH).unwrap_or_default();

// ソリューションをビルドします。
build_solution("PTouchPrintSender.sln")?;
build_solution(r"PtouchPrintSenderApp\PTouchPrintSender.sln")?;

// ビルド後のタイムスタンプ
let current_filetime = util::get_filetime(OUT_PATH)?;
Expand All @@ -69,13 +65,13 @@ pub fn run_build() -> Result<(), Box<dyn std::error::Error>> {
}

fn build_if_needed() -> Result<(), Box<dyn std::error::Error>> {
if util::exists_file(r"bin\Release\PTouchPrintSender.exe") {
if util::exists_file(r"PtouchPrintSenderApp\bin\Release\PTouchPrintSender.exe") {
// バイナリが存在する場合はビルドをスキップします。
return Ok(());
}

// ソリューションをビルドします。
build_solution("PTouchPrintSender.sln")?;
build_solution(r"PtouchPrintSenderApp\PTouchPrintSender.sln")?;

return Ok(());
}
Expand All @@ -88,7 +84,7 @@ pub fn run_print(path: &str, dryrun: bool) -> Result<(), Box<dyn std::error::Err
build_if_needed()?;

let mut command: Vec<&str> = vec![];
command.push(r"bin\Release\PtouchPrintSender.exe");
command.push(r"PtouchPrintSenderApp\bin\Release\PtouchPrintSender.exe");

if dryrun {
command.push("--dryrun");
Expand Down
1 change: 1 addition & 0 deletions cli/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pub fn get_filetime(path: &str) -> Result<String, Box<dyn std::error::Error>> {
///
/// # Returns
/// 環境変数
#[allow(unused)]
pub fn getenv(name: &str) -> String {
return std::env::var(name).unwrap_or_else(|_| "".to_string());
}
2 changes: 1 addition & 1 deletion make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@REM * Rust によって記述されています。rustup が必要です。
@REM

@SET PP_MSBUILD=C:¥Program Files (x86)¥Microsoft Visual Studio¥2019¥Community¥MSBuild¥Current¥Bin¥MSBuild.exe
@SET PATH=C:¥Program Files (x86)¥Microsoft Visual Studio¥2019¥Community¥MSBuild¥Current¥Bin;%PATH%

@cargo fmt
@cargo run -- %*

0 comments on commit 471aec4

Please sign in to comment.