Update .gitea/workflows/kibot.yml
This commit is contained in:
@@ -95,20 +95,53 @@ jobs:
|
||||
pcb_file = sys.argv[1]
|
||||
with open(pcb_file, 'r') as f:
|
||||
content = f.read()
|
||||
# Find all copper layers
|
||||
copper_layers = re.findall(r'\(layer\s+"([^"]+)".*?\(type\s+"?copper"?\)', content, re.DOTALL)
|
||||
# Count inner layers (In1.Cu, In2.Cu, etc)
|
||||
inner_layers = [l for l in copper_layers if 'In' in l and '.Cu' in l]
|
||||
total = 2 + len(inner_layers) # F.Cu + B.Cu + inner layers
|
||||
|
||||
# Look for the layers section in the KiCad PCB file
|
||||
# Format: (layers (0 "F.Cu" signal) (4 "In1.Cu" signal) ...)
|
||||
layers_match = re.search(r'\(layers[^)]*\)', content, re.DOTALL)
|
||||
|
||||
if layers_match:
|
||||
layers_text = layers_match.group(0)
|
||||
# Find all layer definitions
|
||||
layer_matches = re.findall(r'\(\d+\s+"([^"]+)"\s+\w+\)', layers_text)
|
||||
|
||||
# Count copper layers
|
||||
copper_count = 0
|
||||
for layer in layer_matches:
|
||||
if '.Cu' in layer:
|
||||
copper_count += 1
|
||||
print(f"Found copper layer: {layer}", file=sys.stderr)
|
||||
|
||||
if copper_count > 0:
|
||||
print(copper_count)
|
||||
else:
|
||||
# Fallback: count F.Cu, B.Cu, and In*.Cu layers
|
||||
copper_layers = [l for l in layer_matches if l in ['F.Cu', 'B.Cu'] or (l.startswith('In') and l.endswith('.Cu'))]
|
||||
print(len(copper_layers) if copper_layers else 2)
|
||||
else:
|
||||
# Old format fallback
|
||||
copper_layers = re.findall(r'layer\s+"([^"]+)".*?type\s+"?copper"?', content, re.DOTALL)
|
||||
if not copper_layers:
|
||||
copper_layers = re.findall(r'\(layer\s+([FB]\.Cu|In\d+\.Cu)\)', content)
|
||||
|
||||
total = len(set(copper_layers)) if copper_layers else 2
|
||||
print(total)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error detecting layers: {e}", file=sys.stderr)
|
||||
print(2) # Default to 2 layers
|
||||
PYTHON_SCRIPT
|
||||
|
||||
chmod +x /tmp/detect_layers.py
|
||||
LAYERS=$(python3 /tmp/detect_layers.py "$PCB_FILE")
|
||||
LAYERS=$(python3 /tmp/detect_layers.py "$PCB_FILE" 2>/dev/null)
|
||||
if [ -z "$LAYERS" ]; then
|
||||
LAYERS=2
|
||||
fi
|
||||
echo "layers=$LAYERS" >> $GITHUB_OUTPUT
|
||||
echo "Auto-detected $LAYERS layer board"
|
||||
|
||||
# Debug: show what was detected
|
||||
python3 /tmp/detect_layers.py "$PCB_FILE" 2>&1 | grep "Found copper layer" || true
|
||||
fi
|
||||
|
||||
- name: Check for KiBot config
|
||||
|
||||
Reference in New Issue
Block a user