MCPcopy Create free account
hub / github.com/FastLED/FastLED / demo_build_system_workflow

Function demo_build_system_workflow

ci/examples/fingerprint_cache_demo.py:74–144  ·  view source on GitHub ↗

Demonstrate build system integration workflow.

()

Source from the content-addressed store, hash-verified

72
73
74def demo_build_system_workflow() -> None:
75 """Demonstrate build system integration workflow."""
76 print("\n=== Build System Workflow Demo ===")
77
78 with tempfile.TemporaryDirectory() as temp_dir:
79 temp_path = Path(temp_dir)
80 cache_file = temp_path / "build_cache.json"
81 cache = FingerprintCache(cache_file)
82
83 # Simulate multiple source files
84 source_files = [
85 temp_path / "main.cpp",
86 temp_path / "utils.cpp",
87 temp_path / "config.h",
88 ]
89
90 # Create source files
91 contents = [
92 '#include "config.h"\n#include "utils.h"\nint main() { return 0; }',
93 '#include "utils.h"\nvoid utility_function() {}',
94 '#pragma once\n#define VERSION "1.0"',
95 ]
96
97 for src_file, content in zip(source_files, contents):
98 with open(src_file, "w") as f:
99 f.write(content)
100
101 print(f"Created {len(source_files)} source files")
102
103 # Simulate first build
104 print("\n--- First Build (all files new) ---")
105 last_build_time = time.time() - 3600 # 1 hour ago
106 changed_files: list[str] = []
107
108 for src_file in source_files:
109 if cache.has_changed(src_file, last_build_time):
110 changed_files.append(src_file.name)
111
112 print(
113 f"Files to rebuild: {changed_files} ({len(changed_files)}/{len(source_files)})"
114 )
115
116 # Update last build time
117 current_modtimes = [os.path.getmtime(f) for f in source_files]
118
119 # Simulate second build (no changes)
120 print("\n--- Second Build (no changes) ---")
121 changed_files: list[str] = []
122
123 for src_file, modtime in zip(source_files, current_modtimes):
124 if cache.has_changed(src_file, modtime):
125 changed_files.append(src_file.name)
126
127 print(
128 f"Files to rebuild: {changed_files} ({len(changed_files)}/{len(source_files)})"
129 )
130
131 # Modify one file

Callers 1

Calls 6

has_changedMethod · 0.95
FingerprintCacheClass · 0.90
timeMethod · 0.80
printFunction · 0.50
writeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected