• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

IDE for CX

bosh77

Member
Joined
Oct 26, 2019
Messages
44
Hi, I'm trying to create an IDE for CX written with CX itself, then available for all desktop versions.
I added the window on the left that contains variables, functions, etc ...
I think I also add Intellisense and other functions.

I would have two problems:
1 - How can I "capture" the text that appears in the console at the time of compilation and execution of the .CXS files?
2 - Is it possible to exclude the Openal library when compilation, so as not to have to distribute the openal32.dll file?


screenshot2.png
 
Regarding the openal files, it should be fine to leave them out.

Regarding getting STDOUT and STDERR, imho there is no module that ships with CX that does that atm.
Will have a look if I can find one online.
 
You can look into the process module. I didn't try it but maybe you can use the Process class there and run transcc as a subprocess with STDOUT
 
Last edited:
Regarding the openal files, it should be fine to leave them out.
If this application is base on any target that needs any Mojo module, then openal is a requirement due to how the main native sources are written and how CX generates native sources. It's why CServer needs it even though it doesn't use it.

You can look into the pocess module. I didn't try it but maybe you can use the Process class there and run transcc as a subprocess with STDOUT
Yeah it should be possible to use, or extend the Process class. Though the documentation states that Process.Start returns void, even though the description returns a boolean if the a process was successfully started.
 
I am trying to exclude Openal but I don't know how to do it.

Regarding STDOUT I had managed with Visual Basic.net to get the flow of text in real time during the Runtime but in C++ I don't know how to do it, sorry for my ignorance but I don't know the language well.
With VB.NET I used CommandExecutor and an event that occurred every time there was new text to view.
 
get the flow of text in real time during the Runtime but in C++ I don't know how to do it
You don't need C++ for that. It is a Cerberus module I was talking about. The simplest way to get the output of a process is this.
Code:
Strict

Import brl.process

Function Main:Int()
    Local stdOutString:String
    stdOutString = Process.Execute("help")
    Print "StdOut: " + stdOutString
    Return 0
End
 
ok but I only get it when the application is finished.
I would like to get the flow of text like when I compile and run a CX app.
 
For that I would try to start the process with Process.Start() and then check in OnUpdate() with StdoutAvail if there is something to read using ReadStdout().

Docs might help ;-)
 
I tried Process.Start() but I get Memory access violation

Cerberus Runtime Error : Memory access violation
D:/appdesktop/CXIDE/cxide.cxs<23>
C:/Cerberus_v2021-07-25/modules/mojo/app.cxs<96>
 
You have to create an object using:
Local process:=New Process()
process.Start("the_full_path_of_the_app")

You then have to check if the process is still running, then query the standard streams.
 
Here's a working example.
Cerberus:
Strict

Import brl.process
Import brl.databuffer

Enumerate
    ERROR_OK=0,
    ERROR_FAIL=-1,
    ERROR_TERMINATE=-2
 
Function Main:Int()
    Local err:=Run("C:\cerberus\bin\transcc_winnt.exe -target=Desktop_Game -config=release -run C:\cerberus\examples\mojo\charlie\blobmonster\blobmonster.cxs")

    Select err
        Case ERROR_OK
            Print "Successfully executed: "+err
        Case ERROR_FAIL
            Print "Failed to execute: "+err
        Case ERROR_TERMINATE
            Print "Terminated execution: "+err
        Default
            Print "Unknown exit condition: "+err
    End Select
 
    Return 0
End

Function Run:Int(cmd:String)
    If cmd = "" Return ERROR_FAIL
 
    Local process:= New Process(), buffer:DataBuffer=Null
 
    Print "~nExecuting: ~n"+cmd
    If Not process.Start(cmd) Return ERROR_FAIL
 
    Local bytesRead:=0, bytesAvail:=0
    While process.IsRunning()
        ' At this point, check if the user has terminate the process manually.
        ' You should call process.Kill(ERROR_TERMINATE) and return from the function will ERROR_TERMINATE as the value.

        Try
            If buffer buffer.Discard()
            If process.StderrAvail()>0 Throw New Throwable()
    
            bytesAvail = process.StdoutAvail()
            If bytesAvail>0
                buffer = New DataBuffer(bytesAvail)
                bytesRead = process.ReadStdout(buffer, 0, bytesAvail)
                If bytesRead>0 Print buffer.PeekString(0).Trim()
            Endif
        
        Catch e:Throwable
            bytesRead = 0
            bytesAvail = process.StderrAvail()
            If bytesAvail>0
                buffer = New DataBuffer(bytesAvail)
                bytesRead = process.ReadStderr(buffer, 0, bytesAvail)
            Endif
            If bytesRead>0 Print "ERROR: "+ buffer.PeekString(0).Trim() Else Print "ERROR UNKNOWN"
            Exit
        End
    Wend

    Return process.Wait()

End
 
Last edited:
Really thank you very much, just what I needed
Thanks also to Phil7
 
Note that the working example hasn't been test with StderrAvail being thrown. So the exit code could end up being wrong.
 
Last edited:
Is this possible on mac to?
 
Yes, this should work on all desktop targets (glfw and stdcpp).
 
Well i get this.

Of course there is a linw that contains window specifica code. I suspect it needs to be changed.

Code:
TRANS cerberus compiler V2021-12-27
Parsing...
Semanting...
Translating...
Building...
main.cpp:1527:5: warning: 'TARGET_OS_IPHONE' is not defined, evaluates to 0 [-Wundef-prefix=TARGET_OS_]
#if TARGET_OS_IPHONE
    ^
main.cpp:1588:5: warning: 'TARGET_OS_IPHONE' is not defined, evaluates to 0 [-Wundef-prefix=TARGET_OS_]
#if TARGET_OS_IPHONE
    ^
main.cpp:2666:11: warning: 'vfork' is deprecated: Use posix_spawn or fork [-Wdeprecated-declarations]
    _proc=vfork();
          ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/unistd.h:604:1: note: 'vfork' has been explicitly marked deprecated here
__deprecated_msg("Use posix_spawn or fork")
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:208:48: note: expanded from macro '__deprecated_msg'
        #d3 warnings generated.
efine __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
                                                      ^
Program Exit Code: 65280
Done.
 
I suspect it needs to be changed.
warning: 'TARGET_OS_IPHONE' is not defined, evaluates to 0
If your code uses 'TARGET_OS_IPHONE', then the issue is with how you have implemented it. But if your code doesn't use 'TARGET_OS_IPHONE', then it should be raised as a bug.

With your own code. Stick to the official.
Code:
#If TARGET="ios"
    ' iOS specific code here
#Else
    ' Other non specific iOS code here
#Endif
warning: 'vfork' is deprecated: Use posix_spawn or fork
This is a Unix process function to start a child process. The warning is stating that vfork is not a good idea to keep using, due to the fact that vfork will use the same address space as the parent process, thus meaning that if the child process misbehaves; then the parent process is at risk of crashing.

@bosh77
The example I posted in post 12 has been updated a bit. At some point I'll put another example on how to do this in a glfw desktop target.
 
I use the latest of everything and still the same but I don't have my certificate to compile for ios added yet to xcode so that's part of the error of course.

I tried to compile for C++ not iphone though so it might be a bug.
 
Back
Top Bottom