Return to

[Devember 2021] C++ as a script. seabang :D

Linux app that will build a c++ source file and run the results as if the c++ was executable. Only builds if the source file has changed. Will have dependency checking too. Just add “#!/bin/seabang” as the first line, like the cool kids do with python.

And in the usual Linux naming convention I’ve picked a name that will be hard to find in apt. :smiley: Play on words for C and shebang The #! magic thing that scripts have. You get the idea. :wink:

Main reason for the project is that I want a simple app that I can use as a way to learn getting an app added to the debian apt repositories. Or what ever they are called.



Neat, “interpreting C++” always reminds me of ROOT CLING from CERN.

What do you think of using for dependencies? A package manager like conan, vcpkg, spack, or do you want to integrate with a linux distros package manager, like looking for which *.deb package includes a header file with apt and then install that?

Will not be interpreting C++, will do just in time compiling and run the result. I’ve done some tests. And even with doing the compile, that will only need to be done if the code changes, the c++ code is much faster than a Python version of the same code. This was tested on a RPi with it’s slowish sdcard based filesystem. The compiled binary will be stored in the tmp folder.

The dependencies I talked about are the includes that the source file pulls in. If any of these change then the file will be recompiled.

First working version is up. I have some work to add some more features such as being able to pass in extra libs that you want to be linked in. Also I want to do a dependency check on the source file. IF any files it includes have changed then rebuild. This will allow you to include more source files into the one being turned into an executable. If it’s a big project could take some time for first build. But if nothing changes it’ll do some date checks then run existing built executable. I also need to change some code that has hard coded paths for the temp folder and read it’s location from an environment variable. I wish to also add an option so that the ram disk is used instead, this would be handy for file systems that are read only.

The repo is on github @ /HamAndEggs/seabang.git

Seems I’ve added my build folder to the repo, so I better go update my ignore.git file. :smiley:

To use just add (if you’ve built the app in installed it)
To the start of your c++ file and make the c++ file executable. And you’re good to go. No more make files. Just run your source files like the python people have done for years. :slight_smile:

Updated so now does dependency checking for any file that is included by the source file you’re running.

you can post the GH url, and it will show up as a pretty box with some info (like this):

NOTE: with “/tmp/seabang”, check and use “$HOME/tmp” first

This is a cool project, and I totally get why you made it. FWIW I had a similar idea but different approach (maybe even complimentary):

Hi, when I first made the post it seemed the forum would not let me. I’ll try again. I need to work on the params a bit so one can pass params into the compiler if they need to. Like adding defines or libraries to link against. Thanks for the tip on the path. Will add that.

I’m not allowed to post links… :frowning:

h t t p s : / / github . com / HamAndEggs / seabang

1 Like

You are right, I forgot that the forum requires a build up of trust based on your user interaction over time. NP I’ll post the GH repo link:

1 Like

Just done an update to add a new option to allow you to build a debug version of the code. Also fixed a bug where if it failed to compile but there was an exec from a previous build it would run the previous version of the code.