Powershell script for propgcc.
alatnet
Posts: 80
Created a powershell script to essentially compile propgcc programs via command line.
example:
example:
$files = @( "ext1.cpp", "ext2.cpp" ) $propwarepath="D:\\Compilers\\PropWare\\share\\PropWare" $includepaths = @( "-I .", "-I $propwarepath\include", "-I $propwarepath\include\c++" ) $librarypaths = @( "-L .", "-L $propwarepath\lib\xmm-split\" ) $libraries = @( "-lpropware" ) PropCompile.ps1 -projectName "Test" -projectExt ".cpp" -compilemode "xmm" -files $files -includepaths $includepaths -librarypaths $librarypaths -libraries $libraries
<# .SYNOPSIS Powershell script to manage propgcc compilation. .DESCRIPTION Powershell script to manage propgcc compilation in an easy to use manner. .PARAMETER clean Cleans the directory of compiled files. .PARAMETER dumpobj Dumps the elf object. .PARAMETER projectName Project name. This is also the main file that has the main function. This is Mandatory! .PARAMETER projectExt What the extension of the main project file uses. Can be .c, .cpp, .cogc, or .cogcpp Defaults to .c. .PARAMETER files List of extra files to compile that are usually included with the main project. Do not add headers, only .c, .cpp, .cogc, and .cogcpp Note, this is an array! .PARAMETER defines List of defines to declare when compiling. Note, this is an array! You must prepend each entry with "-D ". .PARAMETER compilemode Which compile mode to use. Valid compile modes: lmm, cmm, xmm, xmmc, cog .PARAMETER cflags C Flags to use when compiling c or cogc files. Defaults to "-Os -m32bit-doubles -fno-exceptions -std=c99". Note, this is an array! .PARAMETER cxxflags C++ Flags to use when compiling cpp or cogcpp files. Defaults to "-Os -m32bit-doubles -fno-exceptions -fno-rtti -std=c++0x". Note, this is an array! .PARAMETER loaderflags Loader flags for propeller-loader. Defaults to "-s -x". Note, this is an array! .PARAMETER objdumpflags Object dump flags for propeller-elf-objdump.exe. Defaults to "-h". Note, this is an array! .PARAMETER includepaths Include paths to use when compiling. Defaults to "-I .". Note, this is an array! You must prepend each entry with "-I ". .PARAMETER librarypaths Library paths to use when compiling. Defaults to "-L .". Note, this is an array! You must prepend each entry with "-L ". .PARAMETER libraries Libraries to use when compiling. Defaults to "-lsimpletools". Note, this is an array! .PARAMETER builddir Where to place compiled objects. Defaults to "build/" .PARAMETER compilerpath Where the compilers are located. Defaults to "C:\\'Program Files (x86)'\\SimpleIDE\\propeller-gcc\\bin\\" .EXAMPLE $files = @( "ext1.cpp", "ext2.cpp" ) $propwarepath="D:\\Compilers\\PropWare\\share\\PropWare" $includepaths = @( "-I .", "-I $propwarepath\include", "-I $propwarepath\include\c++" ) $librarypaths = @( "-L .", "-L $propwarepath\lib\$compilelib\" ) $libraries = @( "-lpropware" ) PropCompile.ps1 -projectName "Test" -projectExt ".cpp" -compilemode "xmm" -compilelib "xmm-split" -files $files -includepaths $includepaths -librarypaths $librarypaths -libraries $libraries #> param ( [switch]$clean, [switch]$dumpobj, #dump the elf file (for simpleide?) [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [string]$projectName = "", #main project name [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [string]$projectExt = ".c", #main project's extension [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [array]$files = @(), [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [array]$defines= @(), [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [string]$compilemode = "cmm", #compile mode type [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [array]$cflags = @( #c compiler flags "-Os", "-m32bit-doubles", "-fno-exceptions", "-std=c99" ), [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [array]$cxxflags = @( #cpp compiler flags "-Os", "-m32bit-doubles", "-fno-exceptions", "-fno-rtti", "-std=c++0x" ), [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [array]$loaderflags = @( #loader flags "-s", "-x" ), [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [array]$objdumpflags = @( #obj dumper flags "-h" ), [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [array]$includepaths = @( #include paths "-I ." ), [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [array]$librarypaths = @( #library paths "-L ." ), [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [array]$libraries = @( #libraries to use "-lsimpletools" ), [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [string]$builddir="build/", #where to store the object files [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] $compilerpath="C:\\'Program Files (x86)'\\SimpleIDE\\propeller-gcc\\bin\\" #where the propgcc compiler files are ) #c compiler $CC="propeller-elf-gcc.exe" #cpp compiler $CXX="propeller-elf-g++.exe" #loader $LOADER="propeller-load.exe" #obj dumper $OBJDUMP="propeller-elf-objdump.exe" #main project file name (do not edit) $MAINFILE="'$projectName$projectExt'" #output project file (do not edit) $OUTFILE="'$projectName.elf'" #output project binary (do not edit) $BINARYFILE="'$projectName.binary'" #output project pex (do not edit) $PEXFILE="'$projectName.pex'" #for testing functions and actually managing files (do not edit) $OUTFILE_T="$projectName.elf" $BINARYFILE_T="$projectName.binary" $PEXFILE_T="$projectName.pex" #cleanup if ($clean){ Write-Host "Cleaning" if (Test-Path $builddir){ Remove-Item $builddir -Recurse | Out-Null } if (Test-Path $OUTFILE_T){ Remove-Item $OUTFILE_T | Out-Null } if (Test-Path $BINARYFILE_T){ Remove-Item $BINARYFILE_T | Out-Null } if(Test-Path $PEXFILE_T){ Remove-Item $PEXFILE_T | Out-Null } exit } #make build directory if (Test-Path $builddir){ Write-Host "Build Dir Exists" Remove-Item $builddir -Recurse | Out-Null New-Item $builddir -ItemType "directory" | Out-Null } else { Write-Host "Build Dir Doesnt Exist" New-Item $builddir -ItemType "directory" | Out-Null } #remove old elf if (Test-Path $OUTFILE_T){ Remove-Item $OUTFILE_T } #remove old binary if (Test-Path $BINARYFILE_T){ Remove-Item $BINARYFILE_T } #remove old sd binary if(Test-Path $PEXFILE_T){ Remove-Item $PEXFILE_T | Out-Null } #compile a c file function CompileC($src){ $filename=[IO.Path]::GetFileNameWithoutExtension($file) $obj="$builddir$($filename).o" Invoke-Expression "$compilerpath$CC $defines $includepaths $librarypaths $cflags -m$compilemode -c $SRC -o $OBJ" return $obj } #compile a cpp file function CompileCPP($src){ $filename=[IO.Path]::GetFileNameWithoutExtension($file) $obj="$builddir$($filename).opp" Invoke-Expression "$compilerpath$CXX $defines $includepaths $librarypaths $cxxflags -m$compilemode -c $SRC -o $OBJ" return $obj } #compile a cog c file function CompileCogC($src){ $filename=[IO.Path]::GetFileNameWithoutExtension($file) $obj="$builddir$($filename).co" Invoke-Expression "$compilerpath$CC $defines $includepaths $librarypaths $cflags -mcog -c $SRC -o $OBJ" return $obj } #compile a cog cpp file function CompileCogCPP($src){ $filename=[IO.Path]::GetFileNameWithoutExtension($file) $obj="$builddir$($filename).copp" Invoke-Expression "$compilerpath$CXX $defines $includepaths $librarypaths $cxxflags -mcog -c $SRC -o $OBJ" return $obj } #object array for when compiling the main program $objs=@() #compile object files foreach($file in $files){ $ext = [IO.Path]::GetExtension($file) if($ext -eq ".c"){ Write-Host "Compiling C File: $file" $objs += CompileC($file) }elseif($ext -eq ".cpp"){ Write-Host "Compiling CPP File: $file" $objs += CompileCPP($file) }elseif($ext -eq ".cogc"){ Write-Host "Compiling Cog C File: $file" $objs += CompileCogC($file) }elseif($ext -eq ".cogcpp"){ Write-Host "Compiling Cog Cpp File: $file" $objs += CompileCogCPP($file) } } #compile program if($projectExt -eq ".c"){ Write-Host "Compiling C Project" Invoke-Expression "$compilerpath$CC $defines $includepaths $librarypaths -o $OUTFILE $objs $CCFLAGS -m$compilemode $MAINFILE $libraries" }elseif($projectExt -eq ".cpp"){ Write-Host "Compiling CPP Project" Invoke-Expression "$compilerpath$CXX $defines$includepaths $librarypaths -o $OUTFILE $objs $cxxflags -m$compilemode $MAINFILE $libraries" } #make a loadable file Invoke-Expression "$compilerpath$LOADER $loaderflags $OUTFILE" if($dumpobj){ #hell if i know. probably for simpletools. Invoke-Expression "$compilerpath$OBJDUMP $objdumpflags $OUTFILE" }
Comments
But.... have you considered using an existing build system instead of reinventing the wheel?
Would like to use makefile but since im on windows with WSL, makefiles dont seem to like the windows version of propgcc and propgcc doesnt seem to want to compile or something, i'll have to check on that.
Dont like CMake cus of problems trying to compile a different project.
If running inside WSL, don't use the Windows version of PropGCC. Use the Linux version directly inside WSL. Life will be much easier that way. Treat it like a VM and do everything from within WSL - check out code, edit the code, compile the code, I think you can even load your program to the Propeller from within WSL but don't quote me on that last one.
If you ever want to try CMake again, feel free to reach out. I've successfully integrated it into a number of different projects on both Linux and Windows and may be able to get you past whatever problem you had.
As for propeller-loader support in WSL, it should work since Com ports are mapped to /dev/ttyS<n>.
Though may need to chmod it first or something.
Was able to communicate to a Pi Zero W via usb serial gadget in WSL.
Propgcc will not compile cus of binutils and texinfo...
Tried two forks off of it but i guess my up to date version of ubuntu in WSL just will not compile them...
On top of that, the windows release of propgcc-1.9.0-alpha doesnt generate correct binaries...
Hello!
What, um. version is your UBUNTU in WSL ? I'm using a fairly recent version of SuSe, in this case its their SLES 15 (or thereabouts.)
uname: Linux alatnet-PC 4.4.0-17763-Microsoft #379-Microsoft Wed Mar 06 19:16:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux
lsb_release:
Distributor ID: Ubuntu
Description: Ubuntu 19.04
Release: 19.04
Codename: disco
And here's mine:
And you're not alone in that problem. I attempted to build the whole business on my older laptop who was running Slackware64-14.2 and ran into those brickwalls.
Oh and where'd you obtain your copy of PropGCC?
Roughly.
As for propgcc: https://github.com/parallaxinc/propgcc
Along with some forks from there.
There's also an issue that has patches to supposedly fix it but i dont know why they dont seem apply for me.
Okay. I meant the host, your Windows 10 laptop. It might not be as up to date as the circumstances allow.
Latest version of windows 10 as applicable due to 1903 not released to all users yet.
When i tried to compile my program, it's saying that it cant find libstdc++. Doesnt seem to be in "propeller-elf/lib" which is where it is with the other installation of the propgcc that i have.
If you're doing C++, you have to stick with 4
Doesnt create a working elf/binary file.
So what problem are you running into?
I can use the simpleIDE compilers fine and it'll create the elf/binary fine though.
I've attached the two binary files. you can hands down tell the difference in size and in content.
the sIDE version has readable strings where as the gcc4 version does not.
Note, this project is to work with a YM2612 and uses an Character LCD with an I2C backpack to work.
It displays debug information on the LCD.
If you want to debug it yourself, be my quest, but if you're asking for help, we need more information. What exact commands are you using to compile, what is your code, and what's the error message that makes you say "this binary doesn't work"?
CPP Compiler: propeller-elf-g++.exe
Loader: propeller-load.exe
CPP Flags: -Os -m32bit-doubles -fno-exceptions -fno-rtti -std=c++0x
Using propware includes and CMM library (-lpropware).
Compiling CPP Files: $CXX $defines $includepaths $libararypaths $cxxflags -mcmm -c $SRC -o $OBJ
Compiling the main file: $CXX $defines $includepaths $librarypaths -o $OUTFILE $objs $cxxflags -mcmm $MAINFILE $libraries
Creating the binary file: $LOADER -s -x $OUTFILE
What i expect it to do is display "Hello, World!" on the upper part of the LCD and "Hello propeller!" on the lower part of the LCD and then run some YM2612 test code but it doesnt do that at all.
Well, I have the code downloaded and it builds "out of the box" as soon as I wrapped it with a simple CMake file. I've found an I2C "backpack" for one of my LCD displays so I'll see if I can get some things figured out.
I've took a quick gander at the code and it all looks reasonable. I have looked at every line yet, so can you answer one quick question: it's not using more than a single cog at the moment, right? There's no extra cog start invocations buried deep in some other file (other than main.cpp), right?
Going to do something fancy with streaming a VGM with another cog later though, once i get the YM2612 to actually play correct sounds...
I do like propware compared to simpleide though. works quite nicely.
I've used this breadboard power supply and a custom built power supply with a 12V ac adapter and they seem to be getting hot. On my custom one, the 5V LM1117_T -5.0 component heats up where as the 3v3 LD1117V33 is absolutely fine. Im guessing it's the same with the breadboard powersupply...
And when i modify the YM_WRITE_WAIT and YM_RESET_WAIT to 10x or 100x, the LCD display will sometimes get garbled...
Btw, you might consider extending the LiquidCrystal_I2C class to inherit from PropWare::PrintCapable, that way you can use PropWare's Printer wrapper for easier printing.
Also, while searching for the problem, I updated the LiquidCrystal class to make use of the I2CMaster return codes by using the check_errors() macro everywhere.
And finally, have you considered extending the LiquidCrystal class to implement the PropWare::PrintCapable interface? This would allow you to wrap LiquidCrystal with a PropWare::Printer object and give you really easy formatted writing.
I've attached the updated project. Only files changed are main.cpp and the two LiquidCrystal files.
Always happens on "Res." or "Playing".
And apparently im having the opposite problem now. my propgcc installation works but the simpleide one doesnt.
Weird...
EDIT: If i take out the serial output code "pwOut" it works fine.
EDIT2: ok, i might be hitting a power problem. I think it's the 5v on this breadboard power supply that i have: https://www.ebay.com/itm/Mini-USB-MB102-Breadboard-Power-Supply-Solderless-3-3V-5V-DC-7-12V-for-Arduino/263325131846
I have the MB102 mini usb one.
It keeps heating up really bad to the point that if i touch it, it's probably hot enough to burn or cause really bad discomfort.
I'm absolute rubbish with hardware, so I'll let others jump to help with power problems