Skip to main content

eons Basic Build System

Project description

eons Basic Build System

build

This project derives from eons to improve ease-of-hacking ;)

Design

Ebbs builds packages or whatever with Builders, which extend the self-registering eons.UserFunctor. This means you can write your own build scripts and place them in a "workspace" that can then be shared with colleagues, etc. For example, you could create "my_language.py", containing something like:

from ebbs import Builder

class my_language(Builder):
    def __init__(self, name="My Language"):
        super().__init__(name)
        
        self.supportedProjectTypes = [] #all
        #or
        # self.supportedProjectTypes.append("lib")
        # self.supportedProjectTypes.append("bin")
        # self.supportedProjectTypes.append("test")
        
        #-- is used for consistency and highly recommended.
        #self.requiredKWArgs will cause an error to be thrown prior to execution (i.e. .*Build methods)
        self.requiredKWArgs.append("--my-cli-option")
        
    #Use --my-cli-option
    def PreBuild(self, **kwargs):
        self.my_option = kwargs.get("--my-cli-option")
        
    #Required Builder method. See that class for details.
    def Build(self):
        #DO STUFF!

That file can then go in a "./ebbs/inc/language" directory, perhaps within your project repository.
ebbs can then be invoked with something like: ebbs -l my_language ./generated --my-cli-option my-value, which will run your Build method from "./generated".

The Builder class will split the folder containing the buildPath (e.g. "./generated) on underscores ("_"), storing the first value as self.projectType and the second as self.projectName. The projectType is checked against the used language's supportedProjectTypes. If no match if found, the build is aborted prior to executing the language.

Builder also provides the following path variables by default:

        self.buildPath = path #The one specified on the cli
        self.rootPath = os.path.abspath(os.path.join(self.buildPath, "../"))
        self.srcPath = os.path.abspath(os.path.join(self.buildPath, "../src"))
        self.incPath = os.path.abspath(os.path.join(self.buildPath, "../inc"))
        self.depPath = os.path.abspath(os.path.join(self.buildPath, "../dep"))
        self.libPath = os.path.abspath(os.path.join(self.buildPath, "../lib"))

As well as the following methods:
(See Builder.py for more details)

def CreateFile(self, file, mode="w+")
def RunCommand(self, command)

When a Builder is executed, the following are called in order:
(kwargs is the same for all)

self.ValidateArgs(**kwargs) # <- not recommended to override.
self.PreCall(**kwargs) # <- virtual
#Builder sets the above mentioned variables here
self.PreBuild(**kwargs) # <- virtual
#Supported project types are checked here
self.Build() # <- abstract method for you 
self.PostBuild(**kwargs) # <- virtual
self.PostCall(**kwargs) # <- virtual

Supported Languages

Out of the box, you can build:

  • C++
  • Python (yes, this repository is circularly dependent on itself. That's how you know it's stable!)

You can also "publish" packages to an online repository with -l publish. This is just another Builder and can be extended or substituted as with any other "language".

Ebbs will try to download a language package if the one specified is not found in your workspace. You may add credentials and even provide your own repo url for searching. If credentials are supplied, private packages will be searched instead of public ones. The same credentials (or those with write access) are required for publishing.

By default, ebbs will use the infrastructure.tech package repository. See the Infrastructure API docs for more info.

IMPORTANT CAVEAT FOR ONLINE PACKAGES: the package name must be preceded by "build_" to be found by ebbs.
For example, if you want to use -l my_language from the repository, ebbs will attempt to download "build_my_language". The package zip is then downloaded, extracted, registered, and instantiated.
All packages are .zip files.

Prerequisites

  • python >= 3.6.3
  • eons >= 1.1.5
  • requests>=2.26.0 (for package downloading and publishing)

Installation

pip install ebbs

Usage

ebbs assumes that your project is named in accordance with eons naming conventions as well as eons directory conventions

This usually means your project has the name of bin_my-project, lib_my-project, test_my-project, etc.

Specific usage is language specific but will generally be ebbs -l LANGUAGE BUILD_PATH.
Use ebbs --help for help ;)

Unfortunately, python class names cannot have dashes ("-") in them. Instead, a series of underscores ("_") is often used instead. While this deviates from the eons naming schema, it should still be intelligible for short names. You are, of course, welcome to use whatever naming schemes you would like instead!

Repository

Online repository credentials can be specified with:

--repo-store
--repo-url
--repo-username
--repo-password

These credentials, when used, are passed to the language Builder. This is done primarily for publishing. Because these creds are not pulled from environment variables and are visible on the command line, it is advisable to use app tokens with short expirations. This will be addressed in a future release.

Publishing requires the following additional arguments:


C++

Instead of writing and managing cmake files throughout your directory tree, you can use ebbs -l cpp from a build folder and all .h and .cpp files in your source tree will be discovered and added to a CMakeLists.txt, which is then built with cmake and make, so you get the compiled product you want.

Supported project types:

  • lib
  • bin
  • test (alias for bin)

Prerequisites:

  • cmake >= 3.1.1
  • make >= whatever
  • g++ or equivalent

Currently lacking support for auto-discovered tool chains and build targets - only compiles for the system it is run on.

Python

Do you hate having empty __init__.py files and other nonsense strewn about your project? This fixes that. Somehow.
To build a python library or binary, go to the root of your project and run ebbs -l py generated.
This will copy all *.py files out of src and compile them into a single PROJECT_NAME.py in a dependency-aware fashion.
It will also copy all files and directories from inc and add them to the build folder.
Then, it creates python project files, like __main__.py and __init__.pys.
Lastly, it invokes python's build package and pip to build and install your code. This will fail if the necessary dependencies are not installed.

IMPORTANT: DO NOT USE THIS IN A build FOLDER!
Building packages from a folder named "build" with python -m build (and setuptools?) will result in an empty package as all *.py files in that directory are ignored. Someone please fix this...

Supported project types:

  • bin
  • lib

Prerequisites:

  • build python package
  • valid setup and pyproject.toml files

See how to package python projects for information on required files.
NOTE: Setup files are not created for you, since there is some variability in what you might want.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ebbs-1.2.0.tar.gz (14.6 kB view hashes)

Uploaded Source

Built Distribution

ebbs-1.2.0-py3-none-any.whl (13.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page