From ed712069ef06093c33a256bef0a483d853e55bc7 Mon Sep 17 00:00:00 2001 From: liruncong Date: Wed, 23 Feb 2022 20:45:27 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=88=87=E6=8D=A2scons?= =?UTF-8?q?=E7=89=88=E6=9C=AC(=E6=AF=94=E5=A6=82=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=9A=844.3.0)=E5=90=8E=EF=BC=8C=E7=BC=96=E8=AF=91=E6=97=B6?= =?UTF-8?q?=E5=9C=A8"scons:=20Reading=20SConscript=20files=20..."=E5=90=8E?= =?UTF-8?q?=E6=89=93=E5=8D=B0=E5=87=BA"b''"=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/gcc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/gcc.py b/tools/gcc.py index 8c9685d52b..1b31d5d549 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 -- Gitee From 2a611ca3ba43a27fc2238a02ab4944925fb4fa7a Mon Sep 17 00:00:00 2001 From: liruncong Date: Fri, 25 Feb 2022 23:38:58 +0800 Subject: [PATCH 2/3] =?UTF-8?q?ninja=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +++ bsp/allwinner_tina/SConstruct | 2 ++ bsp/allwinner_tina/rtconfig.py | 5 +++-- bsp/beaglebone/SConstruct | 2 ++ bsp/beaglebone/rtconfig.py | 6 +++--- tools/building.py | 2 +- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index c35f46609f..7b52b79b3f 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 c4d1dc4a87..007d0ce3c1 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 4c14524442..1f23ef7cb8 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/SConstruct b/bsp/beaglebone/SConstruct index ef5574dd60..825d34e0aa 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/rtconfig.py b/bsp/beaglebone/rtconfig.py index 1897099422..d6252d5bb0 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 23fe64e2f6..830eae9017 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') -- Gitee From 29cf3103a22948df83e2b47fa8ba3b37d7c82e0f Mon Sep 17 00:00:00 2001 From: liruncong Date: Sun, 27 Feb 2022 20:58:43 +0800 Subject: [PATCH 3/3] Test_Ts.py --- bsp/beaglebone/SConscript | 31 ++++++++++++++++++++++++++----- bsp/beaglebone/SConstruct | 2 +- bsp/beaglebone/Test_Ts.py | 16 ++++++++++++++++ 3 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 bsp/beaglebone/Test_Ts.py diff --git a/bsp/beaglebone/SConscript b/bsp/beaglebone/SConscript index fe0ae941ae..6b22e0ab8a 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 825d34e0aa..7868965506 100644 --- a/bsp/beaglebone/SConstruct +++ b/bsp/beaglebone/SConstruct @@ -12,7 +12,7 @@ from building import * TARGET = 'rtthread-beaglebone.' + rtconfig.TARGET_EXT -SetOption('experimental','ninja') +#SetOption('experimental','ninja') DefaultEnvironment(tools=[]) env = Environment(tools = ['mingw'], AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, diff --git a/bsp/beaglebone/Test_Ts.py b/bsp/beaglebone/Test_Ts.py new file mode 100644 index 0000000000..56e51dfea8 --- /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() -- Gitee