Kaynağa Gözat

【优化】MicroPython 在 IAR、MDK、GCC 构建工具下的编译错误及警告。

Signed-off-by: armink <armink.ztl@gmail.com>
armink 8 yıl önce
ebeveyn
işleme
5d70272e78
5 değiştirilmiş dosya ile 23 ekleme ve 15 silme
  1. 1 1
      SConscript
  2. 3 10
      extmod/re1.5/compilecode.c
  3. 3 0
      port/moduos_file.c
  4. 13 3
      port/mpconfigport.h
  5. 3 1
      port/mpy_main.c

+ 1 - 1
SConscript

@@ -20,7 +20,7 @@ LOCAL_CCFLAGS = ''
 if rtconfig.CROSS_TOOL == 'gcc':
     LOCAL_CCFLAGS += ' -std=c99'
 elif rtconfig.CROSS_TOOL == 'keil':
-    LOCAL_CCFLAGS += ' --c99'
+    LOCAL_CCFLAGS += ' --c99 --gnu'
 
 group = DefineGroup('MicroPython', src, depend = ['PKG_USING_MICROPYTHON'], CPPPATH = path, LOCAL_CCFLAGS = LOCAL_CCFLAGS)
 

+ 3 - 10
extmod/re1.5/compilecode.c

@@ -4,18 +4,11 @@
 
 #include "re1.5.h"
 
-#define REL(at, to) (to - at - 2)
-#define PC (prog->bytelen)
-
-#if defined(__ICCARM__)
-#define EMIT(at, byte) (code ? (code[at] = byte) : (at))
 #define INSERT_CODE(at, num, pc) \
     ((code ? memmove(code + at + num, code + at, pc - at) : 0), pc += num)
-#else
-#define INSERT_CODE(at, num, pc) \
-    ((code ? memmove(code + at + num, code + at, pc - at) : (void)0), pc += num)
-#define EMIT(at, byte) (code ? (code[at] = byte) : (void)(at))
-#endif /* defined(__ICCARM__) */
+#define REL(at, to) (to - at - 2)
+#define EMIT(at, byte) (code ? (code[at] = byte) : (at))
+#define PC (prog->bytelen)
 
 static const char *_compilecode(const char *re, ByteProg *prog, int sizecode)
 {

+ 3 - 0
port/moduos_file.c

@@ -26,6 +26,7 @@
 
 #include <stdint.h>
 #include <string.h>
+#include <dfs_posix.h>
 
 #include "py/runtime.h"
 #include "py/objstr.h"
@@ -157,6 +158,8 @@ mp_obj_t mp_posix_mkdir(mp_obj_t path_in) {
 MP_DEFINE_CONST_FUN_OBJ_1(mp_posix_mkdir_obj, mp_posix_mkdir);
 
 mp_obj_t mp_posix_remove(uint n_args, const mp_obj_t *arg) {
+    extern void rm(const char *filename);
+
     int index;
     if (n_args == 0) {
         rt_kprintf("Usage: rm FILE...\n");

+ 13 - 3
port/mpconfigport.h

@@ -27,7 +27,6 @@
 #include <rtthread.h>
 #include <stdint.h>
 #include <stdio.h>
-#include <libc/libc_errno.h>
 
 // options to control how MicroPython is built
 
@@ -172,12 +171,23 @@
 #endif
 
 #if defined(__CC_ARM)
-//TODO
+#include <sys/types.h>
+#define __LITTLE_ENDIAN__
+#define MICROPY_NO_ALLOCA           1
+#define MP_WEAK                     RT_WEAK
+#define MP_NOINLINE
+#define MP_ALWAYSINLINE
+#define MP_LIKELY(x)               x
+#define MP_UNLIKELY(x)             x
+#undef __arm__
+#undef __thumb__
+#undef __thumb2__
 #elif defined(__ICCARM__)
+#include <libc/libc_errno.h>
 #include <sys/types.h>
 #define MICROPY_NO_ALLOCA           1
 #define NORETURN                    __noreturn
-#define MP_WEAK                     __weak
+#define MP_WEAK                     RT_WEAK
 #define MP_NOINLINE
 #define MP_ALWAYSINLINE
 #define MP_LIKELY(x)               x

+ 3 - 1
port/mpy_main.c

@@ -141,7 +141,7 @@ NORETURN void nlr_jump_fail(void *val) {
 #ifndef NDEBUG
 void MP_WEAK __assert_func(const char *file, int line, const char *func, const char *expr) {
     printf("Assertion '%s' failed, at file %s:%d\n", expr, file, line);
-    __fatal_error("Assertion failed");
+    RT_ASSERT(0);
 }
 #endif
 
@@ -158,6 +158,8 @@ int DEBUG_printf(const char *format, ...)
     rt_vsprintf(log_buf, format, args);
     rt_kprintf("%s", log_buf);
     va_end(args);
+
+    return 0;
 }
 
 #if defined(RT_USING_FINSH) && defined(FINSH_USING_MSH)