forked from Open-Smartwatch/open-smartwatch-os
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prebuild_lua.py
42 lines (34 loc) · 1.28 KB
/
prebuild_lua.py
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
39
40
41
42
Import("env")
import subprocess
import sys
import os
import platform
print("Building osw_wrap.cxx with swig..")
# Find the framework Core includes so we can use Print.h
def getPlatformCore(env):
packagesDir = env['PROJECT_PACKAGES_DIR']
framework = env['PIOFRAMEWORK'][0]
platform = env['PIOPLATFORM']
board = env['BOARD_MCU']
return os.path.join(os.path.join(os.path.join(packagesDir, f"framework-{framework}{platform}"), "cores"), board)
def getSwigPath():
path = "swig"
#Attempt to use swig.exe from install.py
windowsPath = os.path.join("bin", "swig")
exe = "swig.exe"
if (platform.system() == "Windows"):
if (os.path.exists(windowsPath)):
#Search for swig.exe
for root, subdirs, files in os.walk(windowsPath):
if (exe in files):
return os.path.join(root, exe)
return path
process = subprocess.Popen([getSwigPath(), '-c++', '-lua', '-I../../include', '-I../../lib/Arduino_GFX', f'-I{getPlatformCore(env)}', "-v", 'osw.i'], cwd=r'./src/swig')
process.wait()
return_code = process.poll()
if return_code != 0:
print("Building osw_wrap.cxx with swig failed with return code:")
print(return_code)
sys.exit(99)
else:
print("Building osw_wrap.cxx with swig success")