diff --git a/.gitignore b/.gitignore index c35f46609f554c570046eeb130eb6a1e196df2fd..7b52b79b3f6d9efc9f41d3548065256ebfd42554 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,6 @@ tags .history CMakeLists.txt cmake-build-debug +*.ninja +compile_commands.json +run_ninja_env.bat diff --git a/bsp/allwinner_tina/SConstruct b/bsp/allwinner_tina/SConstruct index c4d1dc4a87c0c9611d9cf8fc027aa9a3012d496a..007d0ce3c1354b3c9897f6f21e872435c2a013bd 100644 --- a/bsp/allwinner_tina/SConstruct +++ b/bsp/allwinner_tina/SConstruct @@ -9,6 +9,7 @@ from building import * TARGET = 'rtthread.' + rtconfig.TARGET_EXT +SetOption('experimental','ninja') DefaultEnvironment(tools=[]) env = Environment(tools = ['mingw'], AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, @@ -17,6 +18,7 @@ env = Environment(tools = ['mingw'], AR = rtconfig.AR, ARFLAGS = '-rc', LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) env.PrependENVPath('PATH', rtconfig.EXEC_PATH) +env.Tool('ninja') Export('RTT_ROOT') Export('rtconfig') diff --git a/bsp/allwinner_tina/rtconfig.py b/bsp/allwinner_tina/rtconfig.py index 4c145244421da07868583a7925a21f62aef4094b..1f23ef7cb8cf1dc7c13ce2fac2626f24326c7d43 100644 --- a/bsp/allwinner_tina/rtconfig.py +++ b/bsp/allwinner_tina/rtconfig.py @@ -1,4 +1,5 @@ -import os +import os +import SCons # toolchains options ARCH ='arm' @@ -55,4 +56,4 @@ if PLATFORM == 'gcc': CXXFLAGS = CFLAGS DUMP_ACTION = OBJDUMP + ' -D -S $TARGET > rtt.asm\n' -POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n' +POST_ACTION = [SCons.Action.Action(OBJCPY + ' -O binary $SOURCE $TARGET'), SCons.Action.Action(SIZE + ' $SOURCE')] diff --git a/bsp/beaglebone/SConscript b/bsp/beaglebone/SConscript index fe0ae941ae9a759ae478de901caec1c961e56af8..6b22e0ab8a369758434376a1956dc31ce8f4c654 100644 --- a/bsp/beaglebone/SConscript +++ b/bsp/beaglebone/SConscript @@ -1,14 +1,35 @@ # for module compiling import os +import SCons +from building import * + Import('RTT_ROOT') cwd = str(Dir('#')) objs = [] -list = os.listdir(cwd) -for d in list: - path = os.path.join(cwd, d) +for item in os.listdir(cwd): + path = os.path.join(cwd, item) if os.path.isfile(os.path.join(path, 'SConscript')): - objs = objs + SConscript(os.path.join(d, 'SConscript')) + objs = objs + SConscript(os.path.join(item, 'SConscript')) + #elif item.endswith("_Ts.py"): + # target = File("%s.autogen.cpp" % item[:-6]).srcnode() + # source = File(item).srcnode() + # Env.Command( + # target, + # source, + # "cd ${SOURCE.abspath} && python $SOURCE --output=${TARGET.abspath}", + # Env = {"PATH": os.environ['PATH']} + # ) + # objs += [target] + elif item.endswith("_Ts.py"): + target = "%s.autogen.cpp" % item[:-6] + print("target=", target) + Env.Command( + os.path.join(cwd, target), + os.path.join(cwd, item), + "cd ${SOURCE.srcpath.dir.abspath} && python $SOURCE --output=$TARGET" + ) + objs += [target] -Return('objs') +Return('objs') \ No newline at end of file diff --git a/bsp/beaglebone/SConstruct b/bsp/beaglebone/SConstruct index ef5574dd6002aa1cf571f01f9320891c267825e3..786896550607d76fee637d066f2a3ba5cc06f6b1 100644 --- a/bsp/beaglebone/SConstruct +++ b/bsp/beaglebone/SConstruct @@ -12,6 +12,7 @@ from building import * TARGET = 'rtthread-beaglebone.' + rtconfig.TARGET_EXT +#SetOption('experimental','ninja') DefaultEnvironment(tools=[]) env = Environment(tools = ['mingw'], AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, @@ -20,6 +21,7 @@ env = Environment(tools = ['mingw'], AR = rtconfig.AR, ARFLAGS = '-rc', LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) env.PrependENVPath('PATH', rtconfig.EXEC_PATH) +env.Tool('ninja') Export('RTT_ROOT') Export('rtconfig') diff --git a/bsp/beaglebone/Test_Ts.py b/bsp/beaglebone/Test_Ts.py new file mode 100644 index 0000000000000000000000000000000000000000..56e51dfea840eac6fc22864859d8bcad361d7cb2 --- /dev/null +++ b/bsp/beaglebone/Test_Ts.py @@ -0,0 +1,16 @@ +# coding: utf-8 +import click + +@click.command(help="") +@click.option("--output", "-o", required=True, type=click.Path(dir_okay=False, writable=True), help="output file path") +def cli(output): + fo = open(output, "w") + fo.write( +''' + void Test() {} +''' + ) + fo.close() + +if __name__ == "__main__": + cli() diff --git a/bsp/beaglebone/rtconfig.py b/bsp/beaglebone/rtconfig.py index 1897099422f474f0ff4ff1de18cced460a63dd2d..d6252d5bb01f2f290dda091f4f3517665884bbf8 100644 --- a/bsp/beaglebone/rtconfig.py +++ b/bsp/beaglebone/rtconfig.py @@ -1,4 +1,5 @@ -import os +import os +import SCons # toolchains options ARCH='arm' @@ -46,5 +47,4 @@ if PLATFORM == 'gcc': else: CFLAGS += ' -O2 -Wall' - POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' +\ - SIZE + ' $TARGET \n' + POST_ACTION = [SCons.Action.Action(OBJCPY + ' -O binary $SOURCE $TARGET'), SCons.Action.Action(SIZE + ' $SOURCE')] diff --git a/tools/building.py b/tools/building.py index 23fe64e2f641878c7c3e8a1dcc03297c14e99c6a..830eae9017788a27e4873874c7cbd1bd5c3028f9 100644 --- a/tools/building.py +++ b/tools/building.py @@ -965,7 +965,7 @@ def EndBuilding(target, program = None): if hasattr(rtconfig, 'dist_handle'): Env['dist_handle'] = rtconfig.dist_handle - Env.AddPostAction(target, rtconfig.POST_ACTION) + Env.Command("rtthread.bin", target, rtconfig.POST_ACTION) # Add addition clean files Clean(target, 'cconfig.h') Clean(target, 'rtua.py') diff --git a/tools/gcc.py b/tools/gcc.py index 8c9685d52b9a9811c367ca26e95331a012f0deca..1b31d5d549d7da83c85730bc7536dfbc3a7db797 100644 --- a/tools/gcc.py +++ b/tools/gcc.py @@ -113,7 +113,7 @@ def GCCResult(rtconfig, str): stdout, stderr = child.communicate() # print(stdout) - if stderr != '': + if stderr != '' and stderr != b'': print(stderr) have_fdset = 0