-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_svelte.py
More file actions
38 lines (28 loc) · 1.09 KB
/
Copy pathbuild_svelte.py
File metadata and controls
38 lines (28 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Copyright (c) 2026 Chris Lee and contributors.
# Licensed under the MIT license. See LICENSE file in the project root for details.
# ruff: noqa: F821, E402
import os
import subprocess
from SCons.Script import Import
# Import the build environment from PlatformIO/SCons
Import("env")
def build_svelte():
print("Building Svelte interface...")
# Get the project root directory
project_dir = env.subst("$PROJECT_DIR")
script_path = os.path.join(project_dir, "build-svelte.sh")
# Ensure the script is executable
# This enables the OS to run it directly via the shebang (#!/bin/sh)
os.chmod(script_path, 0o755)
# Execute the shell script directly (shell=False)
# We pass the full path as the executable.
try:
subprocess.run([script_path], cwd=project_dir, check=True)
except subprocess.CalledProcessError:
print("Error: Svelte build script returned non-zero exit code!")
env.Exit(1)
except OSError as e:
print(f"Error: Could not execute build script at {script_path}")
print(f"Details: {e}")
env.Exit(1)
build_svelte()