{"id":23154785,"url":"https://github.com/barrynolte/pybld","last_synced_at":"2025-10-08T13:24:41.562Z","repository":{"id":179554368,"uuid":"191457839","full_name":"BarryNolte/PyBld","owner":"BarryNolte","description":"Python based make tool","archived":false,"fork":false,"pushed_at":"2019-06-23T18:54:14.000Z","size":61,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-04T16:48:48.238Z","etag":null,"topics":["build","build-tool","make","makefile-template","python-library"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BarryNolte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-11T22:14:18.000Z","updated_at":"2021-08-14T15:53:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"b9696efd-709e-4bd2-a101-c1062ba25dd0","html_url":"https://github.com/BarryNolte/PyBld","commit_stats":null,"previous_names":["barrynolte/pybld"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BarryNolte/PyBld","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BarryNolte%2FPyBld","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BarryNolte%2FPyBld/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BarryNolte%2FPyBld/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BarryNolte%2FPyBld/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BarryNolte","download_url":"https://codeload.github.com/BarryNolte/PyBld/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BarryNolte%2FPyBld/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268500608,"owners_count":24260163,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["build","build-tool","make","makefile-template","python-library"],"created_at":"2024-12-17T20:14:46.799Z","updated_at":"2025-10-08T13:24:36.493Z","avatar_url":"https://github.com/BarryNolte.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[TOC]\n# PyBld - A Python based Makefile System\n-----\n## Defaults\nBy default, PyBld will look for the file 'makefile.py'.  If for some reason you have a makefile of a different name, it can be changed with the ```'-f'``` option:\n\n```shell\n$\u003e pybld -f better_named_makefile.py\n```\n\nWithout specifying a target on the command line, it will run the ```'all'``` target (if it exists) and any targets that ```'all'``` depends on.\n\n```shell\n$\u003e pybld        # This builds the 'all' target\n```\n\n```python\nconfig['defaultTargets'] = ['myFavoriteTarget']\n\n    or\n\nconfig['defaultTargets'] = ['myFavoriteTarget', 'mySecondFavoriteTarget']\n```\nThis value must be in the form of a list.\n\n## Bare Bones Makefile.py\nThis is the shortest valid makefile:\n\n```python\nfrom PyBld import *\n\n@buildTarget\ndef all():\n    return True\n```\n\n## What Makes a PyBld Target?\nA PyBld target is simply python function. However, it must be decorated with the```@buildTarget``` decorator.  This allows the function to be depended on by other targets (e.g. the link step depends on the compile step being completed successfully).  If the function returns true, any target that depends on it will be called, if the function returns false, then it will not be called.\n\n## Specifying Dependent Targets Files\nThrough the```TargetFileList``` function, a search can be done for source files for automatic population of the list.  The list object can then be used as a dependency of a target\n\n```python\nbinary = 'system.bin'\nBUILDdir = './build/'\n\ntfList = TargetFileList(binFile=f'{BUILDdir}{binary}', \n                        targetExt='.o', \n                        builddir=BUILDdir, \n                        filters=['*.cpp', '*.s'])\n                        \n```\n![alt text](./process.svg) Figure 1\n\n## Puting it all together\nThis is an example of a simple```makefile.py``` that will take all the *.cpp and *.c files in the current directory, compile then link them into```MyApp.exe.```\n\n```python\nfrom PyBld import *\nconfig['debug'] = False # \u003c-- set to True to enable debugging messages\n\nCC = 'gcc'\nCFLAGS = '-g'\nLINKFLAGS = ''\n\nexecutable = 'MyApp.exe'\nBUILDdir = './Build/'\n\ntfList = TargetFileList(binFile=f'{BUILDdir}{executable}', \n                        targetExt='.o', \n                        builddir=BUILDdir, \n                        filters=['*.cpp', '*.c'])\n\n@buildTarget\ndef all(link): # depends on Link Target\n    print('Build Succeeded')\n    return True\n\n@buildTarget\ndef link(compile): # depends on Compile Target\n    if not tfList.IsBinaryTargetBuildComplete():\n        strObjFiles = ''\n        for target in tfList:\n            strObjFiles += target.Target + ' '\n      \n        _ret, _retCode, _out = Shell(f'{LINK} {LINKFLAGS} {strObjFiles} -o {BUILDdir}{binary}', show_cmd=True, show_output=True)\n      \n    return tfList.IsBinaryTargetBuildComplete()\n\n@buildTarget\ndef compile(tfList): # depends on list of source files\n    for target in list(filter(lambda tf: tf.MakeStatus == MakeStatus.NEEDTOBUILD, tfList)):\n        _ret, _retCode, _out = Shell(f'{CC} {CFLAGS} {target.Target} {target.Source}', show_cmd=True, show_output=True)\n    return tfList.IsTargetListBuildComplete()\n\n@buildTarget\ndef clean():\n    RemoveDirectory(BUILDdir)\n    return True\n\"\"\"\n\n```\n## Pre/Post functions\nSetting one or both of these configuration values will allow for a function to be called before any actions are taken by PyBld and after all actions have been taken by PyBld.  This is useful when a global environment must be created, then destroyed while a build is happening.\n\n```python\nconfig['PreMakeFunction'] = lambda : print('====\\nBefore any make file stuff is executed\\n====')\nconfig['PostMakeFunction'] = lambda : print('====\\nAfter all make file stuff is executed\\n====')\n\n```\n\n## Built In Helper Functions\n### Files\n\n```python\nCurrentWorkingDirectory()   # Return the current working directory\nCreateDirectory(name)       # Create directory called 'name'\nRemoveDirectory(name)       # Delete directory 'name' and subdirectories\nRemoveFile(name)            # Delete the given file name.\nRenameFile(old, new)        # Rename file 'old' to 'new'\nTouch(name)                 # Touch file 'name', change modified date to now\nGetDirectoryFiles(path)     # Return a list of files from 'path'\nChangeDirectory(path)       # Change current directory to 'path'\nGetModifyTime(name)         # Get the modified time of file 'name'\n```\n\n### Environment\nThese two functions can get and set environment variables for sub-processes that are launched by PyBld.  This can be used for variables passed to tools like compilers and linkers.\n\n```python\nGetEnvVariable(name)           # Get environment variables value\nSetEnvVariable(name, value)    # Set environment variable for sub-processes\n```\n### Debug Setting\nSetting the config value 'debug' to 'True' will cause more information to be printed out during the running of PyBld.  This is useful when you need to know how and why PyBld makes some of the decisions it makes with Targets and Dependencies.\n\n```python\nconfig['debug'] = True\n```\n\n\n\n \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarrynolte%2Fpybld","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbarrynolte%2Fpybld","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarrynolte%2Fpybld/lists"}