PacktPublishing /
Web-Development-with-Django
Learn to build modern web applications with a Python-based framework
Loading repository data…
OussamaEl-Asri / repository
A modern, Python-based reimplementation of the classic make utility, designed to provide efficient build automation through dependency graph analysis and incremental compilation.
A modern, Python-based reimplementation of the classic make utility, designed to provide efficient build automation through dependency graph analysis and incremental compilation.
BLD is a sophisticated build automation tool that uses Bldfile configuration files to manage complex build processes. Built with a modular architecture featuring separate parsing, dependency resolution, and execution engines, BLD offers advanced features like incremental builds, parallel execution, and comprehensive error handling while maintaining the familiar make-like syntax.
Bldfile syntax with advanced features# Clone the repository
git clone https://github.com/Worcrow/Build.git
cd bld
# Install dependencies
pip install -r requirements.txt
# Install in development mode
pip install -e .
# Or install system-wide
python setup.py install
# Make executable available globally
chmod +x bld
sudo ln -s $(pwd)/bld /usr/local/bin/bld
# Install development dependencies
pip install -r requirements-dev.txt
# Run tests
python -m pytest tests/
# Run linting
flake8 src/
black src/
# Generate documentation
sphinx-build docs/ docs/_build/
bld [command]
| Command | Description |
|---|---|
all (default) | Build the entire project |
clean | Remove intermediate build files |
re | Rebuild (clean + all) |
fclean | Full clean (remove all generated files) |
# Build with parallel execution (4 jobs)
bld -j4
# Build specific target with dependencies
bld target_name
# Dry run (show what would be built)
bld --dry-run
# Verbose output with timing
bld --verbose --time
# Force rebuild (ignore timestamps)
bld --force
# Build with custom Bldfile
bld -f custom.bld
# Show dependency graph
bld --show-deps target_name
# Debug mode with detailed logging
bld --debug clean all
BLD automatically determines which targets need rebuilding based on:
# Automatic parallelism detection
bld -j auto
# Manual job control
bld -j8 # Use 8 parallel jobs
# Fine-grained control
bld --max-load 4.0 # Respect system load
# Enable build cache
export BLD_CACHE_DIR=~/.bld_cache
bld --cache
# Clear cache
bld --clear-cache
# Variables with different scoping
GLOBAL_VAR = value
export ENV_VAR = exported_value
# Target with dependencies and commands
target: dependency1 dependency2
@echo "Building target..."
$(CC) $(CFLAGS) -o $@ $^
# Pattern rules
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
# Conditional variables
ifeq ($(DEBUG), 1)
CFLAGS += -g -DDEBUG
else
CFLAGS += -O2 -DNDEBUG
endif
# Functions and built-ins
SOURCES = $(wildcard src/*.c)
OBJECTS = $(SOURCES:.c=.o)
DEPS = $(OBJECTS:.o=.d)
# Multi-line commands with proper escaping
complex_target:
@if [ ! -d build ]; then \
mkdir -p build; \
fi
$(CC) $(CFLAGS) $(SOURCES) -o build/$(NAME)
bld/
├── src/
│ ├── parser/
│ │ ├── __init__.py
│ │ ├── lexer.py # Tokenize Bldfile syntax
│ │ ├── parser.py # Parse tokens into Abstract Syntax Tree
│ │ └── validator.py # Validate syntax and semantic rules
│ ├── core/
│ │ ├── __init__.py
│ │ ├── target.py # Target class with dependency tracking
│ │ ├── variable.py # Variable expansion and scoping
│ │ ├── dag.py # DAG construction and algorithms
│ │ └── exceptions.py # Custom exception classes
│ ├── builder/
│ │ ├── __init__.py
│ │ ├── executor.py # Command execution engine
│ │ ├── dependency_resolver.py # Topological sorting algorithms
│ │ ├── incremental.py # Timestamp-based build logic
│ │ └── parallel.py # Multi-threaded execution
│ ├── cli/
│ │ ├── __init__.py
│ │ └── runner.py # Command-line interface
│ └── utils/
│ ├── __init__.py
│ ├── file_utils.py # File system operations
│ └── logging.py # Build process logging
├── tests/
│ ├── unit/
│ ├── integration/
│ └── fixtures/
├── examples/
│ ├── simple_c_project/
│ ├── complex_cpp_project/
│ └── multi_language_project/
├── docs/
├── requirements.txt
├── setup.py
├── bld # Main executable script
└── README.md
src/parser/)lexer.py: Tokenizes Bldfile content, handling comments, variables, targets, and commands with proper error location trackingparser.py: Builds an Abstract Syntax Tree (AST) from tokens, implementing a recursive descent parser for Bldfile grammarvalidator.py: Validates AST for semantic correctness, checks for undefined variables, circular dependencies, and syntax violationssrc/core/)target.py: Defines Target class with dependency relationships, command lists, and timestamp tracking for incremental buildsvariable.py: Implements variable expansion engine with support for nested variables, conditional expansion, and scoping rulesdag.py: Constructs and manipulates Directed Acyclic Graphs, implements topological sorting and cycle detection algorithmsexceptions.py: Custom exception hierarchy for different error types (parsing, dependency, execution errors)src/builder/)executor.py: Executes build commands with proper environment handling, output capture, and error reportingdependency_resolver.py: Implements advanced dependency resolution algorithms including Kahn's algorithm for topological sortingincremental.py: Manages timestamp-based incremental builds, file modification tracking, and rebuild necessity determinationparallel.py: Provides multi-threaded execution capabilities with proper synchronization and resource managementsrc/cli/)runner.py: Command-line interface with argument parsing, help system, and integration with all core componentsclass VariableExpander:
"""
Handles nested variable expansion with cycle detection
Example: $(CC_$(ARCH)) → $(CC_x86_64) → gcc
"""
def expand(self, expression, context, visited=None):
# Recursive expansion with circular reference detection
# Supports conditional expansion and built-in functions
pass
class DependencyGraph:
"""
Directed Acyclic Graph for build dependency management
Structure:
- Nodes: Build targets with metadata
- Edges: Dependency relationships
- Algorithms: Topological sort, cycle detection, incremental analysis
"""
def __init__(self):
self.nodes = {} # target_name -> TargetNode
self.edges = {} # target_name -> [dependencies]
def add_target(self, target):
# Add target to graph with dependency validation
pass
def topological_sort(self, start_target="all"):
# Kahn's algorithm for build order determination
# Returns ordered list of targets to build
pass
def detect_cycles(self):
# DFS-based cycle detection with path reporting
pass
class IncrementalBuilder:
"""
Timestamp-based incremental build logic
Determines rebuild necessity based on:
- File modification times
- Dependency freshness
- Command line changes
- Environment variable changes
"""
def needs_rebuild(self, target):
# Multi-factor rebuild necessity analysis
return (
self._check_timestamps(target) or
self._check_dependencies(target) or
self._check_command_changes(target)
)
Variables are stored with hierarchical scoping:
Global Scope: {
"CC": "gcc",
"CFLAGS": "-Wall -O2",
"NAME": "myprogram"
}
Target Scope: {
"main.o": {
"CFLAGS": "-Wall -O2 -g" # Target-specific override
}
}
Bldfile:
NAME = myprogram
$(NAME): main.o utils.o
main.o: main.c utils.h
utils.o: utils.c utils.h
Generated DAG:
[myprogram] ──→ [main.o] ──→ [main.c]
│ └──→ [utils.h]
└─────→ [utils.o] ──→ [utils.c]
└──→ [utils.h]
Build Order (Topological Sort):
1. main.c, utils.c, utils.h (source files)
2. main.o, utils.o (object files)
3. myprogram (final executable)
For more information about build automation concepts, visit the GNU Make Documentation.
[Add your license information here]
[Add contact information or issue reporting guidelines here]
Selected from shared topics, language and repository description—not editorial ratings.
PacktPublishing /
Learn to build modern web applications with a Python-based framework
intel /
Intel Paillier Cryptosystem Library is an open-source library which provides accelerated performance of a partial homomorphic encryption (HE), named Paillier cryptosystem, by utilizing Intel® IPP-Crypto technologies on Intel CPUs supporting the AVX512IFMA instructions. The library is written in modern standard C++ and provides the essential API for the Paillier cryptosystem scheme. Intel Paillier Cryptosystem Library - Python is a Python extension package intended for Python based privacy preserving machine learning solutions which utilizes the partial HE scheme for increased data and model protection.
1997mahadi /
A step-by-step learning journey with dltHub: building modern, Python-based data ingestion pipelines from beginner to advanced.
Solrikk /
✨ PicTrace is an advanced Python-based web application that allows users to find visually similar images from a comprehensive photo archive. Leveraging the power of deep learning and modern image processing techniques, PicTrace delivers fast and accurate search functionality that is ideal for tasks such as cataloging...
eugenyh /
**VoxShare** is a simple Python-based push-to-talk multicast voice chat application with a sleek modern GUI built using CustomTkinter.
otakukazzee /
PySec Auditor is an open-source, Python-based tool designed to perform automated, fast, and informative web security audits. It was developed with the primary goal of helping developers, sysadmins, and pentesters examine the basic security configurations of modern websites.