This commit is contained in:
Brad Nelson
2023-12-23 10:03:41 -08:00
parent dc80ca74c5
commit 4ee3646b73
2 changed files with 31 additions and 8 deletions

View File

@ -12,12 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
Mkdir('esp32/ESP32forth')
Importation('esp32/ESP32forth/README.txt',
'$src/esp32/README.txt')
Importation('gen/esp32_boot.h', '$src/esp32/esp32_boot.fs', name='boot')
Importation('esp32/ESP32forth/ESP32forth.ino',
'$src/esp32/ESP32forth.ino',
implicit=['gen/esp32_boot.h'], keep=True)
Importation('gen/esp32_boot.h', '$src/esp32/esp32_boot.fs', name='boot')
Importation('esp32/ESP32forth/README.txt',
'$src/esp32/README.txt')
Mkdir('esp32/ESP32forth/optional')
Importation('esp32/ESP32forth/optional/README-optional.txt',
'$src/esp32/optional/README-optional.txt')
Esp32Optional('rmt', '$src/esp32/optional/rmt.h', [])
@ -35,3 +38,9 @@ Esp32Optional('spi-flash', '$src/esp32/optional/spi-flash/spi-flash.h',
[('spi-flash', '$src/esp32/optional/spi-flash/spi-flash.fs')])
Esp32Optional('serial-bluetooth', '$src/esp32/optional/serial-bluetooth/serial-bluetooth.h',
[('serial-bluetooth', '$src/esp32/optional/serial-bluetooth/serial-bluetooth.fs')])
Mkdir('esp32-sim')
Compile('gen/print-esp32-builtins', '$src/esp32/print-builtins.cpp')
Run('gen/esp32_sim_opcodes.h', 'gen/print-esp32-builtins')
Compile('esp32-sim/esp32-sim', '$src/esp32/sim_main.cpp',
implicit=['gen/esp32_boot.h', 'gen/esp32_sim_opcodes.h'])

View File

@ -109,12 +109,11 @@ rule compile
depfile = $out.dd
command = $cxx $cflags $in -o $out $libs -MD -MF $depfile && strip $strip_args $out
rule run
description = RUN
command = $in >$out
build gen: mkdir
build posix: mkdir
build windows: mkdir
build esp32: mkdir
build esp32/ESP32forth: mkdir
build esp32/ESP32forth/optional: mkdir
""" % {
'version': VERSION,
@ -124,6 +123,12 @@ build esp32/ESP32forth/optional: mkdir
'libs': ' '.join(LIBS),
}
def Mkdir(path):
global output
output += 'build ' + path + ': mkdir\n'
def Importation(target, source, header_mode='cpp', name=None, keep=False, deps=None, implicit=[]):
global output
options = ''
@ -139,6 +144,7 @@ def Importation(target, source, header_mode='cpp', name=None, keep=False, deps=N
if deps:
output += f' depfile = {deps}\n'
def Esp32Optional(main_name, main_source, parts):
for name, source in parts:
Importation('gen/esp32_' + name + '.h',
@ -151,6 +157,7 @@ def Esp32Optional(main_name, main_source, parts):
deps='gen/esp32_optional_' + main_name + '.h.dd',
implicit=['gen/esp32_' + i + '.h' for i, _ in parts])
def Compile(target, source, implicit=[]):
global output
outdir = os.path.dirname(target)
@ -158,10 +165,17 @@ def Compile(target, source, implicit=[]):
output += f'build {target}: compile {source} | {outdir} {implicit}\n'
def Run(target, source):
global output
output += f'build {target}: run {source}\n'
def Include(path):
Mkdir(path)
path = os.path.join(ROOT_DIR, path, 'BUILD')
data = open(path).read()
exec(data)
Include('.')
print(output)