pogmake! - Peterino’s Python Pog as heck make tool

Executive summary

I got really tired of writing makefiles and having it all work in a cross platform manner.

So I’m writing a python tool that abuses the crap out of python meta-attributes and importlib to basically let me write deterministic build scripts in python that would work in all the CI systems I have to support at my day job.

Quickstart

To get started with the walkthrough, run pog --init in the root directory of your choice to create a pogfile.py.

Pmake files are python files with access to a specific environment.

# pogfile.py
@job(desc="Configure and build with cmake")
def my_jobname():
    os.makedirs("build", exist_ok=True)
    subprocess.run(["cmake", orig_dir, "-GNinja"], cwd="build")

Becomes.

======================================================================
There is 1 job registered: (* means part of the default)
   * my_jobname - Configure and build with cmake
======================================================================

Even the automation and CI for this repo is done with pogmake. To get a glimpse of that, run python . to see all the jobs are available in pogmake itself.

Usage

usage: pog [-h] [-v] [--explain-depth EXPLAIN_DEPTH] [-e EXPLAIN]

           [-s START_FILE] [--log-level {DEBUG,INFO,WARNING}] [-l]

           [jobs [jobs ...]]



Registers and executes jobs



positional arguments:

  jobs                  Jobs to run, defaults to all



optional arguments:

  -h, --help            show this help message and exit

  -v, --verbose         Overrides logging level to DEBUG

  --explain-depth EXPLAIN_DEPTH

                        Show detailed debug information regarding a specific

                        job

  -e EXPLAIN, --explain EXPLAIN

                        Show detailed debug information regarding a specific

                        job

  -s START_FILE, --start-file START_FILE

                        Starting file location

  --log-level {DEBUG,INFO,WARNING}

                        Sets the logging level for the program's run. (gets

                        overriden by --verbose)

  -l, --list-jobs       List all jobs available

Btw the usage file seen above is auto-generated based on whatever the output of pogmake –help is here’s an example of the code to do that.

@job(desc="Prints the 'usage' to the temporary directory under ")
def usage_print():
    os.makedirs("docs_src/_spec", exist_ok=True)
    output = subprocess.check_output([sys.executable, "pog", "--help"], cwd=orig_dir)
    with open(usage_print_file, "w") as f:
        f.write(output.decode())

@job("usage_print", desc="Builds the documentation for pogmake")
def docs():
    os.makedirs("build-html", exist_ok=True)
    subprocess.run(['sphinx-build', 'docs_src', 'build-html'], check=True, cwd=orig_dir)