Need help with rebuild all command line
Need help with rebuild all command line
Hello,
I want rebuild all for a Workspace to be
dmd -of=main.exe *.d
where that puts all the D source files on the command line.
Checking "run in bash" in Workspace Options dialog leads to nothing happening at all when I rebuild all from Workspace > Build > Rebuild.
Seems like a bug.
So I need some macro magic to put all .d files in the workspace on the command line in place of bash's *.d
How do I do that?
I want rebuild all for a Workspace to be
dmd -of=main.exe *.d
where that puts all the D source files on the command line.
Checking "run in bash" in Workspace Options dialog leads to nothing happening at all when I rebuild all from Workspace > Build > Rebuild.
Seems like a bug.
So I need some macro magic to put all .d files in the workspace on the command line in place of bash's *.d
How do I do that?
Re: Need help with rebuild all command line
Firstly, the default Bash Command Line is configured for a machine that has WSL installed.
If you don't have WSL installed then it will not work and if want to use a different bash shell like MSYS2 then you'll need to change the Bash Command Line found in the Options, Editor Options, Miscellaneous menu panel.
However, for most cases it will be much easier to just stick with the Windows command line.
Here are some general point regarding running Tools in Zeus:
1. The Options, Editor Options menu, General panel has a Debug tools, macros and executables checkbox. Turning on that option will add extra debug information into the output that will help with debugging, so I would turn it on for now.
2. Zeus has $tag values that can be using to dynamically configure these command lines. To better understand these tags open this file in Zeus:
3. You can run that macro using the Macros, Execute Script menu and entering in this script: ztag.lua
Now you can run that command using the any of these methods:
Note: It is also possible to add a compiler command line options to that workspace using the Compiler panel found in that workspace configuration. That will use the command line for a compile action for any file in that workspace.
However, that is generally not required as there is a compiler command line setup that is attached to the document type.
Cheers Jussi
If you don't have WSL installed then it will not work and if want to use a different bash shell like MSYS2 then you'll need to change the Bash Command Line found in the Options, Editor Options, Miscellaneous menu panel.
However, for most cases it will be much easier to just stick with the Windows command line.
Here are some general point regarding running Tools in Zeus:
1. The Options, Editor Options menu, General panel has a Debug tools, macros and executables checkbox. Turning on that option will add extra debug information into the output that will help with debugging, so I would turn it on for now.
2. Zeus has $tag values that can be using to dynamically configure these command lines. To better understand these tags open this file in Zeus:
Code: Select all
C:\Users\<user id>\AppData\Local\Programs\Zeus (x64)\zScript\ztag.lua
Once a workspace has been created, just use the Workspace, Option menu and in the Project section add in the command line as shown below: Note: The workspace has the option for configuring both Debug and Release mode command lines.I want rebuild all for a Workspace to be
dmd -of=main.exe *.d
Now you can run that command using the any of these methods:
- Workspace, Build Rebuild menu.
- Right clicking on the Project in the Workspace panel and selecting the Build, Rebuild popup menu.
- Editing the Zeus keyboard mapping and binding the WorkspaceRebuild function to any key press combination.
Note: It is also possible to add a compiler command line options to that workspace using the Compiler panel found in that workspace configuration. That will use the command line for a compile action for any file in that workspace.
However, that is generally not required as there is a compiler command line setup that is attached to the document type.
Cheers Jussi
Re: Need help with rebuild all command line
That was all useful information. In fact I do have both WSL and MSYS2, but I agree it's best not to do that.
However my real problem is that the command does not expand *.d into all .d files in the workspace directory before invoking DMD, but rather passes the text *.d to DMD which then says it can't open the file named literally *.d
--- is there a simple equivalent that does expand to all .d files on the command line so I can just get what I want putting a single command where you illustrated above?
However my real problem is that the command
Code: Select all
dmd.exe -of=main.exe *.d
--- is there a simple equivalent that does expand to all .d files on the command line so I can just get what I want putting a single command where you illustrated above?
Re: Need help with rebuild all command line
Since, Zeus is fully scriptable, there will always be a scriptable option that will let you do this. But before going down that path, how do you currently build your D projects 
For example, how would you build a VSCode workspace from inside VSCode
Also doesn't dub already do something like this
Cheers Jussi

For example, how would you build a VSCode workspace from inside VSCode

Also doesn't dub already do something like this

Cheers Jussi
Re: Need help with rebuild all command line
I usually write D on Linux. On Windows I've mostly used MSYS2 and mingw-64 with C or if I have to C++, but DMD is COFF and MSVC compatible. I don't much want to use e.g. VS which I actively dislike, and which I only do when I want to make something very small with the messy but effective C++/CLI that's hard to achieve by another route. I've used dub, but prefer to not do so on occasion, especially for small projects, so I will make my own way with Zeus. Zeus is my path to avoiding all of these defaults and defining my own defaults for projects in D on Windows.
I'd like to be able to write Zeus macros in D. I read the sections on Macros in z.chm and they mention that the macro system is pluggable, so I'm wondering if I could get some sort of access to it via a C API so I can use D in a fashion parallel to the way it is used in Lua. I've written some quite sophisticated low level code with dynamic loading in the presence of two different garbage collectors and no software support of that, so I am up for this.
I'd like to be able to write Zeus macros in D. I read the sections on Macros in z.chm and they mention that the macro system is pluggable, so I'm wondering if I could get some sort of access to it via a C API so I can use D in a fashion parallel to the way it is used in Lua. I've written some quite sophisticated low level code with dynamic loading in the presence of two different garbage collectors and no software support of that, so I am up for this.
Re: Need help with rebuild all command line
On Windows I've mostly used MSYS2
In case you want to use MSYS2, you can setup that Bash command line as mentioned earlier, so that Zeus then opens the MSYS2 Bash shell. But note, this feature has only been tested with WSL.
In general, Zeus will let you do almost anything as it is highly configurable. However, it does leave all of the details on how things get done up to the user.Zeus is my path to avoiding all of these defaults and defining my own defaults for projects in D on Windows.
The scripting layer is definitely pluggable, as can be seen by the many scripting options available in the Options, Editor Options menu, Scripting panel.I read the sections on Macros in z.chm and they mention that the macro system is pluggable
That API is internal use onlyso I'm wondering if I could get some sort of access to it via a C API

I don't know how similar these two languages are, but Zeus can be configured to use the DMDScript as described here: viewtopic.php?p=744&hilit=digital#p744I'd like to be able to write Zeus macros in D
IMPORTANT: Take note of the date of posting for that topic. It was posted a very long time ago, so there is no guarantee it will still work.
However, the Zeus side of that scripting layer is still in place. For example, if you load the talk.vbs macro it still runs, and it uses the same WSH interface.
And having just said the scripting API is internal use only, obviously if WSH is used, then it is actually open

Cheers Jussi
PS: I had a look at the Zeus code base and found a macro tag that might help with this compile configuration. I just need to check if it still works as expected, or if it needs to be tweaked a little.
PPS: I had a quick look at those Zeus DMDScript instructions an the first issue I can see is the binaries that are need come from the DigitalMars web site. Looking at that site those binaries are Win32 so I doubt they will work with the Win64 version of Zeus.
Re: Need help with rebuild all command line
I'm not going to mix in using bash; I mistakenly assumed that was something supplied with Zeus when I checked the box. DMDscript is just an implementation of JavaScript, so not relevant to D. That specific problem could be solved by a small program outside of Zeus but on PATH that takes a command line as its command line arguments and unglobs it into the desired command line and executes it.
I'd like to follow up on your suggestion of scripting being open using WSH, presumably via COM interfaces. Can you say a bit more? There's already a scriptWSH.dll that can be selected as the default in place of Lua in the Editor > Editor Settings scripting tab. Is that pertinent? I'm imagining I need to make my own DLL to add to that list. Any clues appreciated.
I'd like to follow up on your suggestion of scripting being open using WSH, presumably via COM interfaces. Can you say a bit more? There's already a scriptWSH.dll that can be selected as the default in place of Lua in the Editor > Editor Settings scripting tab. Is that pertinent? I'm imagining I need to make my own DLL to add to that list. Any clues appreciated.
Re: Need help with rebuild all command line
Yes it will be a COM object.I'd like to follow up on your suggestion of scripting being open using WSH, presumably via COM interfaces.
If you look at the install steps needed for the DMDScript you will notice one step is to registers a COM object: viewtopic.php?p=744
The other is to create a scriptwsh.dat file that describes how to load and use that that object.
That scriptWSH.dll reads that scriptwsh.dat file and it acts as a bridge between Zeus and the WSH COM object.
Cheers Jussi
PS: It is safe and it is also possible to run both the 32 bit and 64 bit versions of Zeus side by side. Just create a desktop shortcut and use the -s (search the help file for Command Line Arguments for details).
That DMDScript is a good working example of how to write a WSH that works with Zeus and it should work with the 32 bit version.
Re: Need help with rebuild all command line
Thanks for all that! Very interesting, and now first on my list of priorities with Zeus.
I installed the 32-bit Zeus, and followed the DMDscript instructions where you indicated. viewtopic.php?p=744
The dscript.dll was successfully registered using regsvr32 dscript.dll but when I ran test.ds it gave me
C:\Users\sturt\AppData\Local\Programs\Zeus\zScript\test.ds:2: unexpected symbol near '{'Macro script generated '1' Debug, Error and/or Warning message(s).
suggesting it was parsing it as Lua. So I went to Options>Editor_Options...>scripting and changed the active script engine to scriptJS.dll and ran test.ds again. The script executed without error producing
ScriptEngine: JScript
Build: 16384
This is a Digital Mars macro script........
so clearly test.ds isn't being executed using dscript.dll but rather with the currently active scripting module which is JScript from MS.
I tried making scriptWSH.dll be the active scripting module, but then running test.ds gave
Error creating 'Object Rexx' scripting module.
Reason: Invalid class string
Unexpected error creating 'Object Rexx' COM object.
Make sure the Object Rexx Windows Scripting Host has been correctly installed.
so this seems to expect Rexx source for the script.
Somewhere Zeus needs to associate .ds with finding the DMDscript Windows Scripting Engine in dscript.dll and I see no way in the Zeus settings to effect that.
I installed the 32-bit Zeus, and followed the DMDscript instructions where you indicated. viewtopic.php?p=744
The dscript.dll was successfully registered using regsvr32 dscript.dll but when I ran test.ds it gave me
C:\Users\sturt\AppData\Local\Programs\Zeus\zScript\test.ds:2: unexpected symbol near '{'Macro script generated '1' Debug, Error and/or Warning message(s).
suggesting it was parsing it as Lua. So I went to Options>Editor_Options...>scripting and changed the active script engine to scriptJS.dll and ran test.ds again. The script executed without error producing
ScriptEngine: JScript
Build: 16384
This is a Digital Mars macro script........
so clearly test.ds isn't being executed using dscript.dll but rather with the currently active scripting module which is JScript from MS.
I tried making scriptWSH.dll be the active scripting module, but then running test.ds gave
Error creating 'Object Rexx' scripting module.
Reason: Invalid class string
Unexpected error creating 'Object Rexx' COM object.
Make sure the Object Rexx Windows Scripting Host has been correctly installed.
so this seems to expect Rexx source for the script.
Somewhere Zeus needs to associate .ds with finding the DMDscript Windows Scripting Engine in dscript.dll and I see no way in the Zeus settings to effect that.
Last edited by sturt on Sat Mar 16, 2024 7:54 pm, edited 1 time in total.
Re: Need help with rebuild all command line
As mentioned earlier, the Zeus macro tags feature showed hints that an existing macro tag would make it possible to implement this dynamic command line requirement.
That $MEX macro tag, while requiring some minor tweaking to make it work, does in fact provide a solution to this requirement.
Because of the required tweaking, you will need to download the latest Zeus 3.99bl version.
More details on how this tag works can be found here: viewtopic.php?p=13878
In your case, the following command line should produce the required results:
Note, this will return all files in the current directory and Zeus automatically sets that directory to be the directory of the project in question.
You could also directly specify the directory in the command line:
Alternatively, a tag can be used to set the directory, for example the workspace drive and directory ($wdd):
Or the project drive and directory ($pdd) which is equivalent to the current default behaviour:
Cheers Jussi
That $MEX macro tag, while requiring some minor tweaking to make it work, does in fact provide a solution to this requirement.
Because of the required tweaking, you will need to download the latest Zeus 3.99bl version.
More details on how this tag works can be found here: viewtopic.php?p=13878
In your case, the following command line should produce the required results:
Code: Select all
dmd -of=main.exe $MEX<mex-dir.py *.d>
You could also directly specify the directory in the command line:
Code: Select all
dmd -of=main.exe $MEX<mex-dir.py c:\some\directory\ *.d>
Code: Select all
dmd -of=main.exe $MEX<mex-dir.py $wdd *.d>
Code: Select all
dmd -of=main.exe $MEX<mex-dir.py $pdd *.d>
Re: Need help with rebuild all command line
Great, thanks, I'll try that out.
See above, I edited my reply about getting DMDscript running with Zeus (32), and it not associating test.ds with dscript.dll but only with the currently active script module. I followed the instructions precisely.
I imagine that scriptWSH.dll should be the currently active scripting module, but that somehow it needs to be informed about the need to find and use dscript.dll presumably from the registry. Should that be in the file scriptwsh.dat ? I don't know what that line would be, but perhaps something supplying the GUID to find the DLL, or something supplying the name dscript.dll and expecting it to be in zeus\zscripts, for example.
Is there a definition somewhere of what is permitted in the scriptwsh.dat file?
See above, I edited my reply about getting DMDscript running with Zeus (32), and it not associating test.ds with dscript.dll but only with the currently active script module. I followed the instructions precisely.
I imagine that scriptWSH.dll should be the currently active scripting module, but that somehow it needs to be informed about the need to find and use dscript.dll presumably from the registry. Should that be in the file scriptwsh.dat ? I don't know what that line would be, but perhaps something supplying the GUID to find the DLL, or something supplying the name dscript.dll and expecting it to be in zeus\zscripts, for example.
Is there a definition somewhere of what is permitted in the scriptwsh.dat file?
Re: Need help with rebuild all command line
OK, so I am going to write my own Windows Scripting Engine, which I see requires me to implement some of this:
https://learn.microsoft.com/en-us/previ ... pt-engines
Which of these does Zeus need me to implement? Presumably IActiveScript.
Do I also need to supply IActiveScriptParse and/or something else?
It'd be nice to limit the implementation to the Interfaces and methods needed.
https://learn.microsoft.com/en-us/previ ... pt-engines
Which of these does Zeus need me to implement? Presumably IActiveScript.
Do I also need to supply IActiveScriptParse and/or something else?
It'd be nice to limit the implementation to the Interfaces and methods needed.
Re: Need help with rebuild all command line
There were two problems found.I followed the instructions precisely.
1. The first issue, some time since the writing of that post, the scripting layer of Zeus changed and that broke that scriptwsh.dll module. To fix this you'll need to download the latest Zeus 3.99bm version which includes some minor changes to make that module work once again.
2. The second issue was the instructions were outdated and a little confusing. These instructions have been updated and tested as described here: viewtopic.php?p=744
Cheers Jussi
Re: Need help with rebuild all command line
Find attached the C++ code used in the Zeus bridging layer.Which of these does Zeus need me to implement? Presumably IActiveScript.
It is not complete so it will not compile, but it does show how this layer works.
Inside that file there is code that reads from a profile. That profile represents the INI file mentioned in the setup process.
Also, as per that code, these are the two interfaces needed by this layer:
Code: Select all
IActiveScript *m_pIActiveScript;
IActiveScriptParse *m_pIActiveScriptParse;
Overview of the Code
The xScriptInfo represents the information read from the INI file.
The xScript represents a macro script used in the Zeus scripting engine.
The xMacroWSH represents a scripting module used in the Zeus scripting engine.
The xScriptExecutor is the bridge between the ActiveScript layer and the Zeus scripting engine and it uses the IActiveScript interfaces to run the script.
I would guess, all that is needed is the implementation of those handful of IActiveScript interfaces used by that xScriptExecutor code.
I would also suggest looking at the DMDScript code to see how these interfaces where implemented.
Cheers Jussi
- Attachments
-
- ScriptWSH.zip
- (5.53 KiB) Downloaded 692 times
Re: Need help with rebuild all command line
Fantastic! I will enjoy getting to both of these tomorrow. Many thanks.