Skip to content

Commit

Permalink
Improve Windows Platform Support
Browse files Browse the repository at this point in the history
1. Use `python` instead of `python3` on Windows.
2. Replace backslash with slash.
  • Loading branch information
Teddy-van-Jerry committed Mar 25, 2024
1 parent 6a25094 commit c10a5f8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -3,7 +3,7 @@ name = "pytv"
description = "Python Templated Verilog"
repository = "https://github.com/autohdw/pytv"
authors = ["Teddy van Jerry <me@teddy-van-jerry.org>"]
version = "0.3.2"
version = "0.3.3"
readme = "README.md"
license = "GPL-3.0-or-later"
keywords = ["verilog", "python", "template", "generation"]
Expand Down
11 changes: 7 additions & 4 deletions src/convert.rs
Expand Up @@ -71,7 +71,7 @@ impl Convert {
output = output.replace(ext.to_str().unwrap(), "v");
}
output
})
}).replace("\\", "/")
}

/// Generates the output Python file name based on the input file name and configuration.
Expand Down Expand Up @@ -149,16 +149,19 @@ impl Convert {

/// Runs the Python code to generate verilog.
///
/// The command `python3` should be available to call.
/// The command `python3` (`python` for Windows) should be available to call.
pub fn run_python(&self) -> IoResult<()> {
let py_file = self.output_python_file_name();
let v_file = self.output_file_name();
let v_file_f = std::fs::File::create(&v_file)?;
let output = std::process::Command::new("python3")
#[cfg(not(target_family = "windows"))]
let python_cmd = "python3";
#[cfg(target_family = "windows")]
let python_cmd = "python";
let output = std::process::Command::new(python_cmd)
.arg(&py_file)
.stdout(v_file_f)
.output()?;
dbg!(&output);
if !output.status.success() {
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
Expand Down
4 changes: 0 additions & 4 deletions src/inst.rs
Expand Up @@ -81,10 +81,6 @@ impl Convert {
}

fn print_inst<W: Write>(&self, stream: &mut W, inst_str: &str) -> Result<(), Box<dyn Error>> {
print!(
"{}",
Self::apply_protected_inst_group_regex(inst_str).as_str()
);
let inst_map: serde_yaml::Value =
serde_yaml::from_str(&self.apply_protected_verilog_regex(
Self::apply_protected_inst_group_regex(inst_str).as_str(),
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Expand Up @@ -2,7 +2,6 @@ use pytv::Convert;

fn main() {
let convert = Convert::from_args();
println!("{:#?}", convert);
convert
.convert_to_file()
.unwrap_or_else(|err| eprintln!("Error: {}", err));
Expand Down

0 comments on commit c10a5f8

Please sign in to comment.