Skip to content

Commit

Permalink
Python is no longer required for compiling to Next
Browse files Browse the repository at this point in the history
  • Loading branch information
Duefectu committed Jan 11, 2024
1 parent edeb452 commit 1c74aa3
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions ZXBStudio/BuildSystem/ZXProjectBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class ZXProjectBuilder
OutputLogWritter.WriteLine("Project path: " + project.ProjectPath);
OutputLogWritter.WriteLine("Building program " + mainFile);
OutputLogWritter.WriteLine("Building starts at " + startTime);

var proc = Process.Start(new ProcessStartInfo(Path.GetFullPath(ZXOptions.Current.ZxbcPath), $"\"{mainFile}\" " + args) { WorkingDirectory = project.ProjectPath, RedirectStandardError = true, CreateNoWindow = true });

string logOutput;
Expand Down Expand Up @@ -131,6 +131,7 @@ private static bool BuildNexFile(byte[] binary, ZXBuildSettings settings, ZXProj

// Create .bin file
{
outputLogWritter.WriteLine("Creating .bin file...");
binFile = Path.Combine(project.ProjectPath, Path.GetFileNameWithoutExtension(settings.MainFile) + ".bin");
if (File.Exists(binFile))
{
Expand Down Expand Up @@ -161,9 +162,9 @@ private static bool BuildNexFile(byte[] binary, ZXBuildSettings settings, ZXProj
// Main file
{
int[] nextBank16K = { 255, 5, 2, 0 };
int bank = org/16384;
int offset = org-(bank * 16384);
if(bank<0 || bank > 3)
int bank = org / 16384;
int offset = org - (bank * 16384);
if (bank < 0 || bank > 3)
{
outputLogWritter.WriteLine("Error: Invalid ORG direction, must be >0 and <65535");
return false;
Expand Down Expand Up @@ -210,7 +211,8 @@ private static bool BuildNexFile(byte[] binary, ZXBuildSettings settings, ZXProj
Process process = new Process();
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
process.StartInfo.FileName = "python";
CheckNextCreator();
process.StartInfo.FileName = Path.Combine(Path.GetDirectoryName(ZXOptions.Current.ZxbcPath), "python", "python.exe");
process.StartInfo.Arguments = string.Format("{0} nex.cfg {1}",
Path.Combine(Path.GetDirectoryName(ZXOptions.Current.ZxbcPath), "tools", "nextcreator.py"),
Path.GetFileNameWithoutExtension(settings.MainFile) + ".nex");
Expand All @@ -228,12 +230,17 @@ private static bool BuildNexFile(byte[] binary, ZXBuildSettings settings, ZXProj
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardOutput = true;
}
outputLogWritter.WriteLine(string.Format("{0} {1}",
process.StartInfo.FileName,
process.StartInfo.Arguments));
process.Start();
process.WaitForExit();

if (!File.Exists(nexFile))
{
outputLogWritter.WriteLine("Error building .nex file");
outputLogWritter.WriteLine(process.StartInfo.WorkingDirectory);

using (StreamReader reader = process.StandardOutput)
{
string output = reader.ReadToEnd();
Expand All @@ -256,6 +263,19 @@ private static bool BuildNexFile(byte[] binary, ZXBuildSettings settings, ZXProj
}


private static void CheckNextCreator()
{
var fNCexe = Path.Combine(Path.GetDirectoryName(ZXOptions.Current.ZxbcPath), "tools", "nextcreator.exe");
if (File.Exists(fNCexe))
{
return;
}

File.Copy(ZXOptions.Current.ZxbcPath, fNCexe);
return;
}


public static ZXProgram? BuildDebug(TextWriter OutputLogWritter)
{
try
Expand Down

0 comments on commit 1c74aa3

Please sign in to comment.