www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - dub cross compilation binary extension

reply Andre Pany <andre s-e-a-p.de> writes:
Hi,

I had set up a cross compilation from Windows to Raspberry Pi 
using LDC and GCC toolchain. Almost everything is working fine. 
Dub creates a binary which is runnable on the Raspberry Pi. There 
is only 1 small issue. Dub creates the executable with the 
windows file extension ".exe".
Is there anything I can do to force dub not to include the 
windows file extension?

dub.json
{
	"name": "test",
	"dflags-ldc": ["-mtriple=arm-linux-gnueabihf", 
"-gcc=arm-linux-gnueabihf-gcc"],
	"lflags-ldc": 
["-LC:\\D\\ldc2-1.4.0-beta1-win32-msvc\\bin\\ldc-build-runtime.tmp\\lib\\"]
}

dub build --compiler=ldc2 -v

My current workaround is to have a batch file which renames the 
file automatically. But I want to write a blog post and this 
workaround looks ugly.

Kind regards
André
Sep 26
parent reply Joakim <dlang joakim.fea.st> writes:
On Tuesday, 26 September 2017 at 17:48:06 UTC, Andre Pany wrote:
 Hi,

 I had set up a cross compilation from Windows to Raspberry Pi 
 using LDC and GCC toolchain. Almost everything is working fine. 
 Dub creates a binary which is runnable on the Raspberry Pi. 
 There is only 1 small issue. Dub creates the executable with 
 the windows file extension ".exe".
 Is there anything I can do to force dub not to include the 
 windows file extension?

 dub.json
 {
 	"name": "test",
 	"dflags-ldc": ["-mtriple=arm-linux-gnueabihf", 
 "-gcc=arm-linux-gnueabihf-gcc"],
 	"lflags-ldc": 
 ["-LC:\\D\\ldc2-1.4.0-beta1-win32-msvc\\bin\\ldc-build-runtime.tmp\\lib\\"]
 }

 dub build --compiler=ldc2 -v

 My current workaround is to have a batch file which renames the 
 file automatically. But I want to write a blog post and this 
 workaround looks ugly.

 Kind regards
 André
Dub is not meant for cross-compilation yet, it will need patches. I'm surprised just passing those flags worked. I mean to look at it and submit a pull. Until then, renaming will be needed, or you could submit a pull for that yourself.
Sep 26
parent Andre Pany <andre s-e-a-p.de> writes:
On Wednesday, 27 September 2017 at 04:08:39 UTC, Joakim wrote:
 On Tuesday, 26 September 2017 at 17:48:06 UTC, Andre Pany wrote:
 Hi,

 I had set up a cross compilation from Windows to Raspberry Pi 
 using LDC and GCC toolchain. Almost everything is working 
 fine. Dub creates a binary which is runnable on the Raspberry 
 Pi. There is only 1 small issue. Dub creates the executable 
 with the windows file extension ".exe".
 Is there anything I can do to force dub not to include the 
 windows file extension?

 dub.json
 {
 	"name": "test",
 	"dflags-ldc": ["-mtriple=arm-linux-gnueabihf", 
 "-gcc=arm-linux-gnueabihf-gcc"],
 	"lflags-ldc": 
 ["-LC:\\D\\ldc2-1.4.0-beta1-win32-msvc\\bin\\ldc-build-runtime.tmp\\lib\\"]
 }

 dub build --compiler=ldc2 -v

 My current workaround is to have a batch file which renames 
 the file automatically. But I want to write a blog post and 
 this workaround looks ugly.

 Kind regards
 André
Dub is not meant for cross-compilation yet, it will need patches. I'm surprised just passing those flags worked. I mean to look at it and submit a pull. Until then, renaming will be needed, or you could submit a pull for that yourself.
Thanks for the information. I wasn't sure I might miss some config value in dub json. I will create a dub issue. Maybe some new config parameter "targetExtension" makes sense to override the operation system specific executable file extension. Kind regards Andre
Sep 29