Add register and bus device helpers along with neopixel. Also support libraries with a full package in it.
This commit is contained in:
parent
602c318554
commit
19182afdfe
5 changed files with 41 additions and 1 deletions
9
.gitmodules
vendored
9
.gitmodules
vendored
|
|
@ -28,3 +28,12 @@
|
|||
[submodule "libraries/drivers/tcs34725"]
|
||||
path = libraries/drivers/tcs34725
|
||||
url = git@github.com:adafruit/micropython-adafruit-tcs34725.git
|
||||
[submodule "libraries/register"]
|
||||
path = libraries/helpers/register
|
||||
url = git@github.com:adafruit/Adafruit_MicroPython_Register.git
|
||||
[submodule "libraries/bus_device"]
|
||||
path = libraries/helpers/bus_device
|
||||
url = git@github.com:adafruit/Adafruit_MicroPython_BusDevice.git
|
||||
[submodule "libraries/drivers/neopixel"]
|
||||
path = libraries/drivers/neopixel
|
||||
url = git@github.com:adafruit/Adafruit_MicroPython_NeoPixel.git
|
||||
|
|
|
|||
|
|
@ -52,8 +52,15 @@ for subdirectory in os.listdir("libraries"):
|
|||
library_path = os.path.join("libraries", subdirectory, library)
|
||||
|
||||
py_files = []
|
||||
package_files = []
|
||||
for filename in os.listdir(library_path):
|
||||
if filename.endswith(".py") and filename != "setup.py":
|
||||
full_path = os.path.join(library_path, filename)
|
||||
if os.path.isdir(full_path) and os.path.isfile(os.path.join(full_path, "__init__.py")):
|
||||
files = os.listdir(full_path)
|
||||
files = filter(lambda x: x.endswith(".py"), files)
|
||||
files = map(lambda x: os.path.join(filename, x), files)
|
||||
package_files.extend(files)
|
||||
if filename.endswith(".py") and filename != "setup.py" and filename != "conf.py":
|
||||
py_files.append(filename)
|
||||
|
||||
output_directory = os.path.join("build", "lib")
|
||||
|
|
@ -66,6 +73,14 @@ for subdirectory in os.listdir("libraries"):
|
|||
print(output_directory, 512)
|
||||
total_size += 512
|
||||
|
||||
if len(package_files) > 1:
|
||||
for fn in package_files:
|
||||
base_dir = os.path.join(output_directory, os.path.dirname(fn))
|
||||
if not os.path.isdir(base_dir):
|
||||
os.makedirs(base_dir)
|
||||
print(base_dir, 512)
|
||||
total_size += 512
|
||||
|
||||
for filename in py_files:
|
||||
full_path = os.path.join(library_path, filename)
|
||||
output_file = os.path.join(output_directory, filename.replace(".py", ".mpy"))
|
||||
|
|
@ -75,6 +90,19 @@ for subdirectory in os.listdir("libraries"):
|
|||
success = False
|
||||
continue
|
||||
|
||||
for filename in package_files:
|
||||
full_path = os.path.join(library_path, filename)
|
||||
if os.stat(full_path).st_size == 0 or filename.endswith("__init__.py"):
|
||||
output_file = os.path.join(output_directory, filename)
|
||||
shutil.copyfile(full_path, output_file)
|
||||
else:
|
||||
output_file = os.path.join(output_directory, filename.replace(".py", ".mpy"))
|
||||
mpy_success = subprocess.call([mpy_cross, "-o", output_file, full_path])
|
||||
if mpy_success != 0:
|
||||
print("mpy-cross failed on", full_path)
|
||||
success = False
|
||||
continue
|
||||
|
||||
version = None
|
||||
tag = subprocess.run(shlex.split("git describe --tags --exact-match"), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
if tag.returncode == 0:
|
||||
|
|
|
|||
1
libraries/drivers/neopixel
Submodule
1
libraries/drivers/neopixel
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 93c2a89e5b39497038903dddf722f5ae95f9a2ac
|
||||
1
libraries/helpers/bus_device
Submodule
1
libraries/helpers/bus_device
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit dfca8ebdf83ad098815c52c9b6379a42ce19da37
|
||||
1
libraries/helpers/register
Submodule
1
libraries/helpers/register
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit ec1afdff2eeffceb5fca0a9aceb7e3b2bd44d7ea
|
||||
Loading…
Reference in a new issue