Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
3926c72d
Commit
3926c72d
authored
Jan 11, 2015
by
Damien George
Browse files
unix: Add target to build "minimal" uPy interpreter.
parent
963a5a3e
Changes
8
Show whitespace changes
Inline
Side-by-side
unix/Makefile
View file @
3926c72d
...
...
@@ -69,6 +69,10 @@ ifeq ($(MICROPY_PY_TERMIOS),1)
CFLAGS_MOD
+=
-DMICROPY_PY_TERMIOS
=
1
SRC_MOD
+=
modtermios.c
endif
ifeq
($(MICROPY_PY_SOCKET),1)
CFLAGS_MOD
+=
-DMICROPY_PY_SOCKET
=
1
SRC_MOD
+=
modsocket.c
endif
ifeq
($(MICROPY_PY_FFI),1)
LIBFFI_LDFLAGS_MOD
:=
$(
shell
pkg-config
--libs
libffi
)
LIBFFI_CFLAGS_MOD
:=
$(
shell
pkg-config
--cflags
libffi
)
...
...
@@ -87,7 +91,6 @@ SRC_C = \
gccollect.c
\
input.c
\
file.c
\
modsocket.c
\
modos.c
\
alloc.c
\
$(SRC_MOD)
...
...
@@ -122,4 +125,9 @@ uninstall:
# build synthetically fast interpreter for benchmarking
fast
:
@
echo
Make sure to run make
-B
$(MAKE)
COPT
=
"-O2 -DNDEBUG -fno-crossjumping"
CFLAGS_EXTRA
=
'-DMP_CONFIGFILE="<mpconfigport_fast.h>"'
BUILD
=
build-fast
$(MAKE)
COPT
=
"-O2 -DNDEBUG -fno-crossjumping"
CFLAGS_EXTRA
=
'-DMP_CONFIGFILE="<mpconfigport_fast.h>"'
BUILD
=
build-fast
PROG
=
micropython_fast
# build a minimal interpreter
minimal
:
@
echo
Make sure to run make
-B
$(MAKE)
COPT
=
"-Os -DNDEBUG"
CFLAGS_EXTRA
=
'-DMP_CONFIGFILE="<mpconfigport_minimal.h>"'
BUILD
=
build-minimal
PROG
=
micropython_minimal
MICROPY_PY_TIME
=
0
MICROPY_PY_TERMIOS
=
0
MICROPY_PY_SOCKET
=
0
MICROPY_PY_FFI
=
0
unix/alloc.c
View file @
3926c72d
...
...
@@ -33,6 +33,8 @@
#include
"py/mpstate.h"
#include
"py/gc.h"
#if MICROPY_EMIT_NATIVE
#if defined(__OpenBSD__) || defined(__MACH__)
#define MAP_ANONYMOUS MAP_ANON
#endif
...
...
@@ -82,3 +84,5 @@ void mp_unix_mark_exec(void) {
gc_collect_root
(
rg
->
ptr
,
rg
->
len
/
sizeof
(
mp_uint_t
));
}
}
#endif // MICROPY_EMIT_NATIVE
unix/file.c
View file @
3926c72d
...
...
@@ -36,6 +36,8 @@
#include
"py/stream.h"
#include
"py/builtin.h"
#if MICROPY_PY_IO
#ifdef _WIN32
#define fsync _commit
#endif
...
...
@@ -264,3 +266,5 @@ MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_open_obj, 1, mp_builtin_open);
const
mp_obj_fdfile_t
mp_sys_stdin_obj
=
{
.
base
=
{
&
mp_type_textio
},
.
fd
=
STDIN_FILENO
};
const
mp_obj_fdfile_t
mp_sys_stdout_obj
=
{
.
base
=
{
&
mp_type_textio
},
.
fd
=
STDOUT_FILENO
};
const
mp_obj_fdfile_t
mp_sys_stderr_obj
=
{
.
base
=
{
&
mp_type_textio
},
.
fd
=
STDERR_FILENO
};
#endif // MICROPY_PY_IO
unix/gccollect.c
View file @
3926c72d
...
...
@@ -131,7 +131,7 @@ void gc_collect(void) {
// GC stack (and regs because we captured them)
void
**
regs_ptr
=
(
void
**
)(
void
*
)
&
regs
;
gc_collect_root
(
regs_ptr
,
((
mp_uint_t
)
MP_STATE_VM
(
stack_top
)
-
(
mp_uint_t
)
&
regs
)
/
sizeof
(
mp_uint_t
));
#if
ndef _WIN32
#if
MICROPY_EMIT_NATIVE
mp_unix_mark_exec
();
#endif
gc_collect_end
();
...
...
unix/main.c
View file @
3926c72d
...
...
@@ -481,9 +481,11 @@ int main(int argc, char **argv) {
ret
=
do_repl
();
}
#if MICROPY_PY_MICROPYTHON_MEM_INFO
if
(
mp_verbose_flag
)
{
mp_micropython_mem_info
(
0
,
NULL
);
}
#endif
mp_deinit
();
...
...
unix/mpconfigport.h
View file @
3926c72d
...
...
@@ -114,11 +114,16 @@ extern const struct _mp_obj_module_t mp_module_ffi;
#else
#define MICROPY_PY_TERMIOS_DEF
#endif
#if MICROPY_PY_SOCKET
#define MICROPY_PY_SOCKET_DEF { MP_OBJ_NEW_QSTR(MP_QSTR_usocket), (mp_obj_t)&mp_module_socket },
#else
#define MICROPY_PY_SOCKET_DEF
#endif
#define MICROPY_PORT_BUILTIN_MODULES \
MICROPY_PY_FFI_DEF \
MICROPY_PY_TIME_DEF \
{ MP_OBJ_NEW_QSTR(MP_QSTR_usocket), (mp_obj_t)&mp_module_socket },
\
MICROPY_PY_SOCKET_DEF
\
{ MP_OBJ_NEW_QSTR(MP_QSTR__os), (mp_obj_t)&mp_module_os }, \
MICROPY_PY_TERMIOS_DEF \
...
...
unix/mpconfigport.mk
View file @
3926c72d
...
...
@@ -12,5 +12,8 @@ MICROPY_PY_TIME = 1
# Subset of CPython termios module
MICROPY_PY_TERMIOS
=
1
# Subset of CPython socket module
MICROPY_PY_SOCKET
=
1
# ffi module requires libffi (libffi-dev Debian package)
MICROPY_PY_FFI
=
1
unix/mpconfigport_minimal.h
0 → 100644
View file @
3926c72d
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2015 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
// options to control how Micro Python is built
#define MICROPY_ALLOC_PATH_MAX (PATH_MAX)
#define MICROPY_ENABLE_GC (1)
#define MICROPY_ENABLE_FINALISER (0)
#define MICROPY_STACK_CHECK (0)
#define MICROPY_COMP_CONST (0)
#define MICROPY_MEM_STATS (0)
#define MICROPY_DEBUG_PRINTERS (0)
#define MICROPY_HELPER_REPL (1)
#define MICROPY_HELPER_LEXER_UNIX (1)
#define MICROPY_ENABLE_SOURCE_LINE (0)
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE)
#define MICROPY_WARNINGS (0)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
#define MICROPY_STREAMS_NON_BLOCK (0)
#define MICROPY_OPT_COMPUTED_GOTO (0)
#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0)
#define MICROPY_CAN_OVERRIDE_BUILTINS (0)
#define MICROPY_CPYTHON_COMPAT (0)
#define MICROPY_PY_BUILTINS_BYTEARRAY (0)
#define MICROPY_PY_BUILTINS_MEMORYVIEW (0)
#define MICROPY_PY_BUILTINS_COMPILE (0)
#define MICROPY_PY_BUILTINS_FROZENSET (0)
#define MICROPY_PY_BUILTINS_SET (0)
#define MICROPY_PY_BUILTINS_SLICE (0)
#define MICROPY_PY_BUILTINS_STR_UNICODE (0)
#define MICROPY_PY_BUILTINS_PROPERTY (0)
#define MICROPY_PY___FILE__ (0)
#define MICROPY_PY_MICROPYTHON_MEM_INFO (0)
#define MICROPY_PY_GC (0)
#define MICROPY_PY_GC_COLLECT_RETVAL (0)
#define MICROPY_PY_ARRAY (0)
#define MICROPY_PY_COLLECTIONS (0)
#define MICROPY_PY_MATH (0)
#define MICROPY_PY_CMATH (0)
#define MICROPY_PY_IO (0)
#define MICROPY_PY_IO_FILEIO (0)
#define MICROPY_PY_STRUCT (0)
#define MICROPY_PY_SYS (1)
#define MICROPY_PY_SYS_EXIT (0)
#define MICROPY_PY_SYS_PLATFORM "linux"
#define MICROPY_PY_SYS_MAXSIZE (0)
#define MICROPY_PY_SYS_STDFILES (0)
#define MICROPY_PY_CMATH (0)
#define MICROPY_PY_UCTYPES (0)
#define MICROPY_PY_UZLIB (0)
#define MICROPY_PY_UJSON (0)
#define MICROPY_PY_URE (0)
#define MICROPY_PY_UHEAPQ (0)
#define MICROPY_PY_UHASHLIB (0)
#define MICROPY_PY_UBINASCII (0)
// Define to 1 to use undertested inefficient GC helper implementation
// (if more efficient arch-specific one is not available).
#ifndef MICROPY_GCREGS_SETJMP
#ifdef __mips__
#define MICROPY_GCREGS_SETJMP (1)
#else
#define MICROPY_GCREGS_SETJMP (0)
#endif
#endif
#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (0)
extern
const
struct
_mp_obj_module_t
mp_module_os
;
#define MICROPY_PORT_BUILTIN_MODULES \
{ MP_OBJ_NEW_QSTR(MP_QSTR__os), (mp_obj_t)&mp_module_os }, \
// type definitions for the specific machine
#ifdef __LP64__
typedef
long
mp_int_t
;
// must be pointer size
typedef
unsigned
long
mp_uint_t
;
// must be pointer size
#else
// These are definitions for machines where sizeof(int) == sizeof(void*),
// regardless for actual size.
typedef
int
mp_int_t
;
// must be pointer size
typedef
unsigned
int
mp_uint_t
;
// must be pointer size
#endif
#define BYTES_PER_WORD sizeof(mp_int_t)
// Cannot include <sys/types.h>, as it may lead to symbol name clashes
#if _FILE_OFFSET_BITS == 64 && !defined(__LP64__)
typedef
long
long
mp_off_t
;
#else
typedef
long
mp_off_t
;
#endif
typedef
void
*
machine_ptr_t
;
// must be of pointer size
typedef
const
void
*
machine_const_ptr_t
;
// must be of pointer size
#define MICROPY_PORT_ROOT_POINTERS \
mp_obj_t keyboard_interrupt_obj;
// We need to provide a declaration/definition of alloca()
#ifdef __FreeBSD__
#include
<stdlib.h>
#else
#include
<alloca.h>
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment