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.
At this time pogmake is not intended to be a compiler driver. Though it is entirely possible to use it as such (much in the same way you’d run a makefile).
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 pog in a directory to see all the jobs are available in pogmake itself.
Usage
usage: pog [-h] [-v] [--explain-depth EXPLAIN_DEPTH] [-e EXPLAIN] [--init]
[-s START_DIR] [--log-level {DEBUG,INFO,WARNING}] [-l]
[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
--init Creates a default pogfile in the starting location.
-s START_DIR, --start_dir START_DIR
This flag will cause pogmake to run in an alternate
start location. As if that directory was the root
directory.
--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 ", default=False)
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([sys.executable, "-m", "sphinx", "docs_src", "build-html"], check=True, cwd=orig_dir)