Commit Graph

43 Commits

Author SHA1 Message Date
Damien George
69661f3343 all: Reformat C and Python source code with tools/codeformat.py.
This is run with uncrustify 0.70.1, and black 19.10b0.
2020-02-28 10:33:03 +11:00
Jim Mussared
193bc3702f mpy-cross/README.md: Add notes about -march and -O. 2019-12-09 14:23:04 +11:00
Damien George
82a19cb39f mpy-cross: Support armv7em, armv7emsp, armv7emdp architectures. 2019-12-03 12:32:29 +11:00
Damien George
1d21b4e7d1 mpy-cross: Enable Xtensa-Windowed native emitter.
Selectable via the command line: -march=xtensawin.
2019-10-05 13:45:32 +10:00
Damien George
b596638b9b mpy-cross: Set number of registers in nlr_buf_t based on native arch.
Fixes #5059.  Done in collaboration with Jim Mussared.
2019-09-26 15:53:05 +10:00
stijn
d96391aca3 mpy-cross,windows: Add msvc build of mpy-cross.
Add the project file to the mpy-cross directory, which is also where the
executable ends up, and change the Appveyor settings to build mpy-cross
with both msvc and mingw-w64 and verify this all works by running tests
with --via-mpy.
2019-09-18 22:16:36 +10:00
stijn
5501092776 mpy-cross: Make mpconfigport.h compatible with msvc compiler.
Add a copy of the required options from windows/mpconfigport.h.
2019-09-18 22:16:19 +10:00
Damien George
af20c2ead3 py: Add global default_emit_opt variable to make emit kind persistent.
mp_compile no longer takes an emit_opt argument, rather this setting is now
provided by the global default_emit_opt variable.

Now, when -X emit=native is passed as a command-line option, the emitter
will be set for all compiled modules (included imports), not just the
top-level script.

In the future there could be a way to also set this variable from a script.

Fixes issue #4267.
2019-08-28 12:47:58 +10:00
Damien George
8e3e05761e mpy-cross/main: Only accept full emit cmdline options if native enabled. 2019-08-28 12:47:58 +10:00
Damien George
4173950658 mpy-cross: Do not automatically build mpy-cross, rather do it manually.
Building mpy-cross automatically leads to some issues with the build
process and slows it down.  Instead, require it to be built manually.
2019-06-03 14:44:44 +10:00
Damien George
c066dadc5b mpy-cross/mpconfigport.h: Remove defn of MP_NOINLINE to use global one.
A global definition of MP_NOINLINE was added to py/mpconfig.h long ago in
0f5bf1aafe
2019-05-24 14:51:48 +10:00
Damien George
7e90e22ea5 mpy-cross: Add --version command line option to print version info.
Prints something like:

MicroPython v1.10-304-g8031b7a25 on 2019-05-02; mpy-cross emitting mpy v4
2019-05-07 13:54:20 +10:00
Damien George
e70c438c71 mpy-cross: Automatically select ARMV6 arch when running on such a host. 2019-05-01 15:31:00 +10:00
Damien George
1556af19bf mpy-cross: Support compiling with MICROPY_PY___FILE__ enabled. 2019-03-26 18:19:21 +11:00
Damien George
9c9bc65e74 mpy-cross: Add "-march=<arch>" option to select native emitter. 2019-03-14 12:22:25 +11:00
Andrew Leech
89ff506513 py: Update and rework build system for including external C modules.
How to use this feature is documented in docs/develop/cmodules.rst.
2019-03-08 22:58:42 +11:00
Damien George
31d2d83e79 mpy-cross: Enable building of x64 native .mpy files. 2019-03-08 16:51:04 +11:00
Paul Sokolovsky
ab78fe0eb9 mpy-cross/Makefile: Also undefine MICROPY_FORCE_32BIT and CROSS_COMPILE.
mpy-cross is a host, not target binary. It should not be build with the
target compiler, compiler options and other settings. For example,

If someone currently tries to build from pristine checkout the unix port
with the following command:

    make CROSS_COMPILE=arm-linux-gnueabihf-

then mpy-cross will be built with arm-linux-gnueabihf-gcc and of course
won't run on the host, leading to overall build failure.

This situation was worked around for some options in 1d8c3f4cff, so add
MICROPY_FORCE_32BIT and CROSS_COMPILE to that set too.
2018-08-14 17:20:18 +10:00
Damien George
ee40d1704f mpy-cross: Make build independent of extmod directory.
mpy-cross doesn't depend on any code in the extmod directory so completely
exclude it from the build (extmod may still be scanned for qstrs but that
is controlled by py/py.mk).  This speeds up the build a little, and
improves abstraction of this component.

Also, make -I$(BUILD) take precedence over -I$(TOP) in case there are stray
files in the root directory that would be picked up.
2018-07-10 14:11:28 +10:00
Damien George
a3dc1b1957 all: Remove inclusion of internal py header files.
Header files that are considered internal to the py core and should not
normally be included directly are:
    py/nlr.h - internal nlr configuration and declarations
    py/bc0.h - contains bytecode macro definitions
    py/runtime0.h - contains basic runtime enums

Instead, the top-level header files to include are one of:
    py/obj.h - includes runtime0.h and defines everything to use the
        mp_obj_t type
    py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h,
        and defines everything to use the general runtime support functions

Additional, specific headers (eg py/objlist.h) can be included if needed.
2017-10-04 12:37:50 +11:00
Damien George
4a93801c12 all: Update Makefiles and others to build with new ports/ dir layout.
Also renames "stmhal" to "stm32" in documentation and everywhere else.
2017-09-06 14:09:13 +10:00
Damien George
7d4a2f773c all: Make use of $(TOP) variable in Makefiles, instead of "..".
$(TOP) is defined in py/mkenv.mk and should be used to refer to the top
level of this repository.
2017-08-11 12:22:19 +10:00
Alexander Steffen
55f33240f3 all: Use the name MicroPython consistently in comments
There were several different spellings of MicroPython present in comments,
when there should be only one.
2017-07-31 18:35:40 +10:00
Damien George
aa7be82a4d all: Don't include system errno.h when it's not needed. 2017-07-24 18:43:14 +10:00
Damien George
761e4c7ff6 all: Remove trailing spaces, per coding conventions. 2017-07-19 13:12:10 +10:00
Damien George
ed6d2547df mpy-cross/Makefile: Guard "override undefine" by test for make feature.
make v3.81 doesn't have "undefine" so we can't use it with that version.
2017-05-26 13:16:55 +10:00
Damien George
1d8c3f4cff mpy-cross/Makefile: Override undefine any inherited variables.
This is a temporary hack to allow othe Makefiles to build mpy-cross
recursively.
2017-05-11 23:40:16 +10:00
stijn
5b57ae985f mpy-cross: Fix compiler detection for including windows/fmode.c
fmode.c should only be included for builds targetting 'pure' windows, i.e.
msvc or mingw builds but not when using msys or cygwin's gcc (see #2298).
Just checking if the OS is windows and UNAME doesn't have msys stil leaves
the gate open for builds with cygwin's gcc since UNAME there is e.g.
CYGWIN_NT-6.1-WOW.
Fix this by checking for 'mingw' explicitly in the compiler version; both
gcc and clang have the -dumpmachine flag so the check should be ok for
all platforms.
2017-05-03 10:37:51 +10:00
Damien George
03053f82db mpy-cross, unix, windows, stmhal: Enable return-if-else optimisation.
Prior to making this a config option it was previously available on these
(and all other) ports, and it makes sense to keep it enabled for mpy-cross
as well as ports that have a decent amount of space for the code.
2017-04-22 15:12:48 +10:00
Damien George
4c307bfba1 all: Move BYTES_PER_WORD definition from ports to py/mpconfig.h
It can still be overwritten by a port in mpconfigport.h but for almost
all cases one can use the provided default.
2017-04-01 11:39:38 +11:00
Krzysztof Blazewicz
75589272ef all/Makefile: Remove -ansi from GCC flags, its ignored anyway.
The -ansi flag is used for C dialect selection and it is equivalent to -std=c90.
Because it goes right before -std=gnu99 it is ignored as for conflicting flags
GCC always uses the last one.
2017-03-23 15:32:12 +11:00
Damien George
97142000f7 mpy-cross/main: Move lexer constructor to within NLR handler block. 2017-03-14 11:52:05 +11:00
Damien George
85ae17c993 mpy-cross: Get compiling after recent persistent code refactors. 2016-11-16 20:25:36 +11:00
Damien George
2b882e9aca mpy-cross: Don't use the internal printf functions.
They require mp_hal_stdout_tx_strn_cooked, which requires extra work to
add to mpy-cross.
2016-09-05 17:30:24 +10:00
Damien George
675d1c9c60 ports: Remove typedef of machine_ptr_t, it's no longer needed.
This type was used only for the typedef of mp_obj_t, which is now defined
by the object representation.  So we can now remove this unused typedef,
to simplify the mpconfigport.h file.
2016-08-15 11:02:59 +10:00
stijn
37b143ce9e mpy-cross: Fix mingw and msys2 compilation
When compiling with msys2's gcc there's no need to apply the binary fmode
so adjust the Makefile to reflect that.
When compiling with mingw we need to include malloc.h since there is no
alloca.h, and the 64bit detection in mpconfigport.h needs some adjustment.
2016-07-30 21:15:45 +03:00
stijn
9bdb82ef6b mpy-cross: Use binary file translation mode for creating mpy files on windows
This is a fix for https://github.com/micropython/micropython/issues/2209:
by default a file created using open() uses text translation mode so writing
\n to it will result in the file having \r\n. This is obviously problematic
for binary .mpy files, so provide functions for setting the open mode
and use binary mode in mpy-cross' main().
2016-07-22 21:21:54 +03:00
Anton Sokolchenko
e9f3fb7662 mpy-cross: Fix Makefile to handle gc-sections linker flags on OS X. 2016-07-11 12:12:07 +01:00
Damien George
330165a2cc py: Add MP_STATE_THREAD to hold state specific to a given thread. 2016-06-28 11:09:31 +01:00
Damien George
74fb4e795b mpy-cross: Add -s option to specify the embedded source filename.
.mpy files contain the name of the source file that they were compiled
from.  This patch adds a way to change this name to an arbitrary string,
specified on the command line with the -s option.  The default is to use
the full name of the input filename.

This new -s option is useful to strip off a leading directory name so
that mpy-tool.py can freeze packages.
2016-05-23 13:25:54 +01:00
Damien George
853fb08d0d mpy-cross: Remove setting of MICROPY_FORCE_32BIT=1 from Makefile.
Building in 32-bit mode was only to reduce binary size on 64-bit machines
and is otherwise not needed.  Having it forced to 32-bit meant an
unnecessary dependency on 32-bit libraries that is now removed.
2016-03-09 15:56:11 +00:00
Damien George
3d1d92acfc mpy-cross: Give a more sensible error message when file doesn't exist. 2016-03-02 16:12:00 +00:00
Damien George
56f76b873a mpy-cross: Add new component, a cross compiler for MicroPython bytecode.
This component allows to generate .mpy files (pre compiled bytecode)
which can be executed within any MicroPython runtime/VM.
2016-02-25 10:12:21 +00:00