Skip to content

Commit

Permalink
Merge pull request #6 from buildroot-meshtastic/buildroot_pr
Browse files Browse the repository at this point in the history
Add buildroot "board"
  • Loading branch information
thebentern authored Dec 10, 2024
2 parents 7fcee25 + c8f218a commit 73bd1a2
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 18 deletions.
15 changes: 15 additions & 0 deletions boards/buildroot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"build": {
"core": "FIXMECORE",
"extra_flags": "-DPORTDUINO_BUILDROOT",
"variant": "buildroot"
},
"upload": {
"maximum_ram_size": 99999999,
"maximum_size": 99999999
},
"frameworks": ["arduino"],
"name": "Portduino",
"url": "https://github.com/meshtastic/framework-portduino",
"vendor": "Meshtastic, LLC"
}
63 changes: 45 additions & 18 deletions builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,56 @@
Builder for native platform
"""

import os
from SCons.Script import COMMAND_LINE_TARGETS, AlwaysBuild, Default, DefaultEnvironment

env = DefaultEnvironment()

# Remove generic C/C++ tools
for k in ("CC", "CXX"):
if k in env:
del env[k]

# Preserve C and C++ build flags
backup_cflags = env.get("CFLAGS", [])
backup_cxxflags = env.get("CXXFLAGS", [])

# Scan for GCC compiler
env.Tool("gcc")
env.Tool("g++")

# Reload "compilation_db" tool
if "compiledb" in COMMAND_LINE_TARGETS:
env.Tool("compilation_db")
#
# Setup tools dependent on 'board'
#

# Restore C/C++ build flags as they were overridden by env.Tool
env.Append(CFLAGS=backup_cflags, CXXFLAGS=backup_cxxflags)
# Buildroot environment
if env.get("BOARD") == "buildroot":
# Use toolchain from buildroot
env.Replace(
AR=os.getenv("TARGET_AR"),
AS=os.getenv("TARGET_AS"),
CC=os.getenv("TARGET_CC"),
CXX=os.getenv("TARGET_CXX"),
LD=os.getenv("TARGET_LD"),
OBJCOPY=os.getenv("TARGET_OBJCOPY"),
RANLIB=os.getenv("TARGET_RANLIB")
)

# Append flags from buildroot
env.Append(
CFLAGS=os.getenv("TARGET_CFLAGS"),
LDFLAGS=os.getenv("TARGET_LDFLAGS"),
CXXFLAGS=os.getenv("TARGET_CXXFLAGS")
)

# Native environment (toolchain from the host)
else:
# Remove generic C/C++ tools
for k in ("CC", "CXX"):
if k in env:
del env[k]

# Preserve C and C++ build flags
backup_cflags = env.get("CFLAGS", [])
backup_cxxflags = env.get("CXXFLAGS", [])

# Scan for GCC compiler
env.Tool("gcc")
env.Tool("g++")

# Reload "compilation_db" tool
if "compiledb" in COMMAND_LINE_TARGETS:
env.Tool("compilation_db")

# Restore C/C++ build flags as they were overridden by env.Tool
env.Append(CFLAGS=backup_cflags, CXXFLAGS=backup_cxxflags)

#
# Target: Build executable program
Expand Down

0 comments on commit 73bd1a2

Please sign in to comment.