aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas "Cakeisalie5" Touhey <thomas@touhey.fr>2018-03-22 22:18:33 +0100
committerThomas "Cakeisalie5" Touhey <thomas@touhey.fr>2018-03-22 22:18:33 +0100
commitc018b58150b67300e1f281568675beda2dc6ea9b (patch)
tree19764169f5669eb58e719fd448fe0c70967993a1
parent62f2650da25a08ef47c7bd2a4dcc9863fbc5406a (diff)
Many many things.
-rw-r--r--.editorconfig21
-rw-r--r--.gitignore25
-rw-r--r--LICENSE.md13
-rwxr-xr-xMakefile14
-rw-r--r--README.md19
-rw-r--r--copyright.yml1
-rw-r--r--docs/authors.en.md3
-rw-r--r--docs/building.en.md4
-rw-r--r--docs/coding.en.md2
-rw-r--r--docs/config.en.md50
-rw-r--r--docs/contributing.en.md73
-rw-r--r--docs/docs.en.md8
-rw-r--r--docs/flags/fr.pngbin0 -> 159 bytes
-rw-r--r--docs/flags/gb.pngbin0 -> 807 bytes
-rw-r--r--docs/index.en.md28
-rw-r--r--docs/preprocessor.en.md46
-rw-r--r--docs/tools/build-tools.en.md51
-rwxr-xr-xmake8
-rw-r--r--modules/all/core-sh/bits/byteswap.h4
-rw-r--r--modules/all/core-sh/docs/intrinsics.en.md2
-rw-r--r--modules/all/core-sh/info.yml2
-rw-r--r--modules/all/core/include/locale.h2
-rw-r--r--modules/all/core/src/locales.c9
-rw-r--r--modules/all/helloworld/docs/index.en.md4
-rw-r--r--modules/all/helloworld/roles.yml4
-rw-r--r--modules/all/helloworld/src/helloworld.c2
-rw-r--r--modules/all/info.yml12
-rw-r--r--modules/all/mem/docs/index.en.md12
-rw-r--r--modules/all/mem/docs/tweaking.en.md8
-rw-r--r--modules/all/string-sh/info.yml2
-rw-r--r--modules/all/string/docs/memory.en.md20
-rw-r--r--modules/all/string/docs/strings.en.md32
-rw-r--r--modules/casiowin/core/src/assert/assert.c5
-rw-r--r--modules/casiowin/easy-input/info.yml2
-rw-r--r--modules/casiowin/fxlib/docs/comm.en.md16
-rw-r--r--modules/casiowin/fxlib/docs/draw.en.md88
-rw-r--r--modules/casiowin/fxlib/docs/file.en.md64
-rw-r--r--modules/casiowin/fxlib/docs/index.en.md4
-rw-r--r--modules/casiowin/fxlib/docs/keys.en.md16
-rw-r--r--modules/casiowin/fxlib/docs/timer.en.md8
-rw-r--r--modules/casiowin/info.yml18
-rw-r--r--modules/casiowin/monochromelib/docs/screen.en.md12
-rw-r--r--modules/casiowin/monochromelib/docs/vram.en.md16
-rw-r--r--modules/compiler/host-gcc-sh/bits/smachine.h (renamed from modules/compiler/target-gcc-sh/bits/smachine.h)4
-rw-r--r--modules/compiler/host-gcc-sh/bits/umachine.h (renamed from modules/compiler/target-gcc-sh/bits/umachine.h)2
-rw-r--r--modules/compiler/host-gcc-sh/info.yml6
-rw-r--r--modules/compiler/host-gcc/info.yml4
-rw-r--r--modules/compiler/host-renesas/bits/stdarg.h15
-rw-r--r--modules/compiler/host-renesas/info.yml6
-rw-r--r--modules/compiler/info.yml12
-rw-r--r--modules/compiler/target-gcc-sh/copyright.yml5
-rw-r--r--modules/compiler/target-gcc-sh/info.yml9
-rw-r--r--modules/compiler/target-gcc-sh/roles.yml3
-rw-r--r--modules/compiler/target-renesas/info.yml6
-rw-r--r--project.yml (renamed from modules/info.yml)7
-rwxr-xr-xtools/Internals/__init__.py2
-rwxr-xr-xtools/Internals/build/__init__.py100
-rwxr-xr-xtools/Internals/build/gnu_as.py15
-rwxr-xr-xtools/Internals/build/gnu_gcc.py22
-rwxr-xr-xtools/Internals/build/renesas_asmsh.py21
-rwxr-xr-xtools/Internals/build/renesas_shc.py24
-rwxr-xr-xtools/Internals/build/utils/bfd.py22
-rwxr-xr-xtools/Internals/build/utils/formats.py6
-rwxr-xr-xtools/Internals/cache.py9
-rwxr-xr-x[-rw-r--r--]tools/Internals/config.py52
-rwxr-xr-xtools/Internals/module.py196
-rwxr-xr-xtools/Internals/project.py320
-rwxr-xr-xtools/configure.py312
-rwxr-xr-xtools/getcopyright.py78
-rwxr-xr-xtools/make.py223
70 files changed, 1276 insertions, 935 deletions
diff --git a/.editorconfig b/.editorconfig
index 003bb2e..60cc623 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,11 +1,26 @@
-# Editor Configuration for libcarrot - see http://editorconfig.org
+# Cross-editor configuration for libcarrot.
+# See <http://editorconfig.org/> for more information about how to
+# use and edit this file.
+#
+# This file only makes using the libcarrot coding style easier.
+# For more information about how to contribute to libcarrot,
+# see <docs/contributing.en.md>.
+
root = true
-# Unix-style newlines with a newline ending every file.
-# Also, tabulations for all source files.
+# The libcarrot contributing guide recommends using Unix-style newlines
+# with ending newlines, and tabulations for indenting.
+
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab
indent_size = 4
+
+# YAML files don't support tabulations as indenting styles, so we'll
+# use two spaces as the indent unit.
+
+[*.yml]
+indent_style = space
+indent_size = 2
diff --git a/.gitignore b/.gitignore
index d6e91b1..e74001d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,28 +1,25 @@
-/build
+# Current top-level generated things.
+/config*
+/.config*
+/build*
+/.build*
+/cache*
+/.cache*
+.*.chg
-# Old top-level generated things
+# Old generated things.
/Makefile.cfg
/obj
/include
/html
-
*.a
*.dll
*.o
-# cache
-/build.yml
-/.config.yml
-/.*cache*
-.*.chg
-
-# that was for modules
-arch/**/obj
-
-# that's for python3 things
+# Python things.
__pycache__
-# and that's temporary files nobody wants
+# Temporary files that nobody want pushed.
.DS_Store
.*.swp
.\#*
diff --git a/LICENSE.md b/LICENSE.md
index 6bd7799..973a5d3 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -1,4 +1,11 @@
# libcarrot license
-All of the files do not necessarily belong to the same people/organizations,
-and are not always placed under the same licenses, see `docs/licensing.en.md`
-for more details.
+![][flg-en] All of the files do not necessarily belong to the same
+people/organizations, and are not always placed under the same licenses,
+see <docs/licensing.en.md> for more details.
+
+![][flg-fr] Tous les fichiers ne sont pas nécessairement détenus par les
+mêmes personnes/organisations, et ne sont pas toujours placés sous les
+mêmes licences, voyez <docs/licensing.fr.md> pour plus d'informations.
+
+[flg-en]: docs/flags/gb.png
+[flg-fr]: docs/flags/fr.png
diff --git a/Makefile b/Makefile
index d3af5bb..dd69b61 100755
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,14 @@
#!/usr/bin/make -f
MK := @PROGNAME='make' tools/python3.sh tools/make.py
+ CMDS := $(shell tools/python3.sh tools/make.py listcmds)
-all: -always-make
- $(MK) all
-%: -always-make
- $(MK) $@
+define make-rule
+ $1:
+ $(MK) $1
--always-make:
+.PHONY: $1
+endef
+$(foreach cmd,$(CMDS),\
+$(eval $(call make-rule,$(cmd))))
-.PHONY: -always-make
# End of file.
diff --git a/README.md b/README.md
index bb74902..a3ed616 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,17 @@
# libcarrot - an experimental and modular libc for learning
-The description and documentation of this project has moved to
-the `docs/` folder, with the other documentation files (except module-specific
-ones). You can also check out [the official website][web]!
+![][flg-en] The description and documentation of this project have moved to
+the <docs/> folder, with the other documentation files (except module-specific
+ones); check the files ending with `.en.md`. You can also check out
+[the official website][web-en]!
-[web]: https://libcarrot.touhey.fr/
+![][flg-fr] La description et la documentation de ce projet ont été déplacées
+dans le dossier <docs/>, avec les autres pages de documentation (excepté
+les pages spécifiques à un module) ; cherchez les fichiers dont le nom
+se termine par `.fr.md`. Vous pouvez également jeter un œil
+[au site officiel][web-fr] !
+
+[flg-en]: /assets/flags/gb-3e37637a7e86a060c93293e062a5529ba164b5b9ce9b8e2a27eb9a7f5865142f.png
+[web-en]: https://libcarrot.touhey.fr/index.en.html
+
+[flg-fr]: /assets/flags/fr-1b06ee231b699f404732068f52a5686870aa35b9c3261b4ce4e7dbf576804beb.png
+[web-fr]: https://libcarrot.touhey.fr/index.fr.html
diff --git a/copyright.yml b/copyright.yml
index f1ca2ae..857b607 100644
--- a/copyright.yml
+++ b/copyright.yml
@@ -12,6 +12,7 @@ files:
- 'configure'
- 'configure.bat'
- 'Makefile'
+- 'make'
- 'make.bat'
- 'requirements.txt'
copyright:
diff --git a/docs/authors.en.md b/docs/authors.en.md
index d6bfcf2..5a081ae 100644
--- a/docs/authors.en.md
+++ b/docs/authors.en.md
@@ -5,5 +5,4 @@ This version, commonly called "the upstream", of libcarrot is maintained by
its original author, Thomas "Cakeisalie5" Touhey <<thomas@touhey.fr>>.
If not stated otherwise, each file belongs to its author(s), which are
-determined through the `copyright.yml` files (see
-[licensing.en.md](licensing.en.md)).
+determined through the `copyright.yml` files (see <licensing.en.md>).
diff --git a/docs/building.en.md b/docs/building.en.md
index 7867638..37164f2 100644
--- a/docs/building.en.md
+++ b/docs/building.en.md
@@ -62,14 +62,14 @@ installation directories and options! (TODO: document these once they're ready)
Here are some examples:
-{% highlight bash linenos %}
+```bash
# shared libraries for linux, with some more modules
./configure --target=x86_64-linux --shared \
--add all/stdcocorico --add all/helloworld
# static libraries for casiowin for use by the Renesas toolchain
./configure --target=sh3eb-casiowin --flavour=renesas
-{% endhighlight %}
+```
# Building and installing
Once the project is configured, you can `make` under UNIX-like OSes,
diff --git a/docs/coding.en.md b/docs/coding.en.md
index 7513612..6a965c8 100644
--- a/docs/coding.en.md
+++ b/docs/coding.en.md
@@ -2,7 +2,7 @@
title: The libcarrot coding style
---
This coding style is the one the libcarrot project uses — see
-[Contributing](contributing.en.md) for a more general guide about how
+<contributing.en.md> for a more general guide about how
to contribute, or the rest of this guide for how to code in this project.
A good place to start is
diff --git a/docs/config.en.md b/docs/config.en.md
index 929a805..33e0c6d 100644
--- a/docs/config.en.md
+++ b/docs/config.en.md
@@ -10,10 +10,25 @@ The configuration is usually stored in `.config` in the project root.
It is YAML-encoded, and should have the following properties:
- `magic`: should be equal to `potatosdk-1.0`;
+- `locations`: the locations configuration described further;
- `modules`: the list of selected modules to build and install together;
-- `tools`: the tools configuration described further.
+- `tools`: the tools configuration described further;
+- `orig`: the original command line of the configure script.
-# Tools structure
+# Locations configuration structure
+The configuration contains the locations of the key files and directories
+used by the other tools. It contains at least the `main` location, which is
+the location of the project-related data, normally `project.yml` — the
+root directory of the project is deduced from this path, as the folder the
+project-related data file is stored in.
+
+The following properties, if present, override the values in the
+project-related data:
+
+- `modules`: the modules root directory;
+- `build`: the build directory.
+
+# Tools configuration structure
The configuration contains the tools that have been selected for building by
the configure script, and their configuration, in the `tools` property.
This property is splitted into two different properties:
@@ -29,7 +44,7 @@ tool-dependant configuration in `params` (could be a dictionary or anything).
# Full configuration example
An full example configuration is the following:
-{% highlight yaml linenos %}
+```yaml
%YAML 1.2
---
magic: potatosdk-1.0
@@ -42,17 +57,18 @@ modules:
- casiowin/fxlib-core
- casiowin/fxlib-crt
tools:
- ids:
- cc: [GNU, GCC]
- asm: [GNU, as]
- pack: [GNU, ar]
- params:
- cc:
- path: /opt/sh3eb-elf/bin/sh3eb-elf-gcc
- flags: [-Wall, -Wextra, -Wno-attributes, -O2, -nostartfiles, -mhitachi]
- asm:
- path: /opt/sh3eb-elf/bin/sh3eb-elf-as
- flags: [--isa=sh3, --big]
- pack:
- path: /opt/sh3eb-elf/bin/sh3eb-elf-ar
-{% endhighlight %}
+ ids:
+ cc: [GNU, GCC]
+ asm: [GNU, as]
+ pack: [GNU, ar]
+ params:
+ cc:
+ path: /opt/sh3eb-elf/bin/sh3eb-elf-gcc
+ flags: [-Wall, -Wextra, -Wno-attributes, -O2, -nostartfiles, -mhitachi]
+ asm:
+ path: /opt/sh3eb-elf/bin/sh3eb-elf-as
+ flags: [--isa=sh3, --big]
+ pack:
+ path: /opt/sh3eb-elf/bin/sh3eb-elf-ar
+orig: "--target=sh3eb-casiowin"
+```
diff --git a/docs/contributing.en.md b/docs/contributing.en.md
index af1aae0..70d7dc2 100644
--- a/docs/contributing.en.md
+++ b/docs/contributing.en.md
@@ -2,11 +2,11 @@
title: Contributing to libcarrot
---
First of all, thanks for reading this! It probably means you think libcarrot
-is worth the effort you are going to put in it, and that rocks! :D
+might be worth the effort you are going to put in it, and that rocks! :D
As I want to keep things clean and organized for anyone using this library,
-I'm defining this set of rules (from my own coding style, as it is how I
-started this project). Some are justified from a technical point of view,
+I'm defining this set of rules (from my own personal coding style, as it is
+how I started this project). Some are justified from a technical point of view,
and some are not. Don't think it's against you or anything: I just don't
want this project to be a coding style mess, where you have to learn a new
coding style before contributing to any new header/source file.
@@ -55,11 +55,10 @@ Modules have the following organization ("opt." means "optional", "req." means
- `roles.yml` (rec.): machine-readable roles for your source files.
In order not to make a coding style patchwork out of this project, you really
-should follow the project's coding style; see [Coding style](coding.en.md).
+should follow the project's coding style — see <coding.en.md>.
-`copyright.yml` defines the license of each file (see
-[Licensing](licensing.en.md)). The other files' roles and structures are
-defined below.
+`copyright.yml` defines the license of each file (see <licensing.en.md>).
+The other files' roles and structures are defined below.
## Global information file
The global information file gives information about libcarrot. It is located
@@ -76,7 +75,7 @@ following properties:
An example configuration is the following:
-{% highlight yaml linenos %}
+```yaml
%YAML 1.2
---
magic: potatosdk-1.0
@@ -84,7 +83,7 @@ version:
major: 5
minor: 11
indev: true
-{% endhighlight %}
+```
## System and meta-system information file
Every system has a few properties, regrouped in a system information file and
@@ -112,26 +111,26 @@ If the list of ABIs is empty (or the ABI property is simply not defined), the
system is considered to be a meta-system. An example configuration is the
following:
-{% highlight yaml linenos %}
+```yaml
%YAML 1.2
---
magic: potatosdk-1.0
description: >-
- That incredible system we should all switch to.
+ That incredible system we should all switch to.
default:
- c:
- - mysys/somepackage
- - mysys/someotherpackage
- c++:
- - mysys/thatpackage
- - another/thatotherpackage
+ c:
+ - mysys/somepackage
+ - mysys/someotherpackage
+ c++:
+ - mysys/thatpackage
+ - another/thatotherpackage
import:
- all
requires:
- arch:
- - sh3
- - sh4a
-{% endhighlight %}
+ arch:
+ - sh3
+ - sh4a
+```
Notice that C dependencies will be considered C++ dependencies too.
@@ -146,7 +145,7 @@ configuration, with the following properties:
- `deps`: the module dependencies (preferably excluding language-related
dependencies);
- `license`: the license for the module (either `free` or `proprietary`,
- default is `free`). See [Licensing](licensing.en.md) for more details;
+ default is `free`). See <licensing.en.md> for more details;
- `conflicts`: the module(s) this module shouldn't be selected with;
- `requires`: the requirements for this module to be selected to be selected,
with the following properties:
@@ -157,7 +156,7 @@ configuration, with the following properties:
An example configuration is the following:
-{% highlight yaml linenos %}
+```yaml
%YAML 1.2
---
magic: potatosdk-1.0
@@ -168,13 +167,13 @@ conflicts:
- mysystem/some_anonymous_hater
- all/some_general_module_that_defines_the_same_thing_as_me
requires:
- arch:
- - sh3
- - sh4a
- compiler:
- - [GNU, GCC]
- - [Renesas, SHC]
-{% endhighlight %}
+ arch:
+ - sh3
+ - sh4a
+ compiler:
+ - [GNU, GCC]
+ - [Renesas, SHC]
+```
## Roles file (top comments)
**The top comment of each source/include file is NOT hand-written**,
@@ -186,17 +185,17 @@ from the roles files `roles.yml` present in every module root.
A roles file is YAML-encoded, and simply represents an arborescence with
dictionaries, leading to the description. Here's an example roles file:
-{% highlight yaml linenos %}
+```yaml
%YAML 1.2
---
bits:
- stdio.h: description for the `bits/stdio.h` file
- stdlib.h: description for the `bits/stdlib.h` file
+ stdio.h: description for the `bits/stdio.h` file
+ stdlib.h: description for the `bits/stdlib.h` file
include:
- subfolder:
- something.h: description for the `include/subfolder/something.h` file
- other.h: description for the `include/other.h` file
-{% endhighlight %}
+ subfolder:
+ something.h: description for the `include/subfolder/something.h` file
+ other.h: description for the `include/other.h` file
+```
## C/C++ headers and header bits
libcarrot uses a C superpreprocessor, which role is to:
diff --git a/docs/docs.en.md b/docs/docs.en.md
index b2b8b17..3e5184e 100644
--- a/docs/docs.en.md
+++ b/docs/docs.en.md
@@ -31,13 +31,17 @@ which contains something like this:
---
title: The hello world module Thomas is so excited about.
+ chapters:
+ - history
+ - cultural_impact
+ - copyrights
---
Some text about how great this module and the `helloworld()` function it
contains are.
- {% highlight c linenos %}
+ ```c
void helloworld(const char *string);
- {% endhighlight %}
+ ```
Some more remarks about how awesome this function is.
diff --git a/docs/flags/fr.png b/docs/flags/fr.png
new file mode 100644
index 0000000..968ff24
--- /dev/null
+++ b/docs/flags/fr.png
Binary files differ
diff --git a/docs/flags/gb.png b/docs/flags/gb.png
new file mode 100644
index 0000000..e4fa695
--- /dev/null
+++ b/docs/flags/gb.png
Binary files differ
diff --git a/docs/index.en.md b/docs/index.en.md
index 81ea5dd..32d4bac 100644
--- a/docs/index.en.md
+++ b/docs/index.en.md
@@ -7,16 +7,21 @@ chapters:
libcarrot is a modular C/C++ library.
Although originally made to replace CASIO's fxlib under Linux (see
-`casiowin/fxlib` for information about that), libcarrot has now become a more
-global standard library for C and C++, originally targetting the
+`casiowin/fxlib` for more information about that), libcarrot has now become
+a more global standard library for C and C++, originally targetting the
SuperH/J-Core system with extensions for the CASIO fx-9860G, but now
aiming to have extensions for more systems and languages.
The library aims at being compatible with the ISO C and C++ standards,
-POSIX/Single Unix Specification, other standards the GNU C Library supports,
-and at being usable with several compilers such as Renesas' C/C++ Compiler
-(SHC), the GNU Compiler Collection (GCC), Clang, the Small Device C Compiler
-(SDCC), IBM's XL C/C++ Compiler (XLC), and many more!
+POSIX/Single Unix Specification (for compliant systems), other standards
+the GNU C Library supports, and at being usable with several compilers such as:
+
+- Renesas' C/C++ Compiler (SHC);
+- the GNU Compiler Collection (GCC);
+- Clang (LLVM);
+- the Small Device C Compiler (SDCC);
+- IBM's XL C/C++ Compiler (XLC);
+- many more!
# Modules
The library is thought around modules. Modules in libcarrot are a logicial
@@ -28,6 +33,10 @@ function printing "hello world" and what is required to run with it
A module, like any package, has dependencies, conflicts, and requirements.
Among the requirements are the architecture, the compiler, etc.
+Modules only exist at compilation time: once the libcarrot distributed,
+modules will be transparent, only the set of features they bring will be
+available to the user (unless the module defines some preprocessor macro
+for the user to use).
# Systems
Modules are grouped by system, for which they are suitable.
@@ -38,6 +47,7 @@ that are suitable for Linux.
Systems have various _default modules_ depending on the languages and binary
executable formats you ought to prepare it for.
-There are various system-agnostic meta-systems such as `all`, which contain
-modules for several other systems, such as standard-compliant modules, in
-order to reduce the system-specific code (and thereby, the error rate).
+Among the available systems are meta-systems such as `all`. These systems
+are untargettable as their only purpose is to bring modules to several other
+systems, such as standard-compliant modules, in order to reduce the
+system-specific code (and thereby, the error rate).
diff --git a/docs/preprocessor.en.md b/docs/preprocessor.en.md
index 19fd9e3..35c72c5 100644
--- a/docs/preprocessor.en.md
+++ b/docs/preprocessor.en.md
@@ -20,33 +20,67 @@ to the libcarrot's needs (plus little touches for tolerance).
This page describes the libcarrot preprocessor and best practices.
# Defining macros
+As in standard C, to manage the macros definition, the two basic instructions
+are `#define` and `#undef`. They shall be used like this:
#define NAME content
+ #define NAME(arg0) content
#define NAME(arg0, arg1) content
#undef NAME
-These define the basic things.
+As the libcarrot preprocessor will try to optimize preprocessor instructions,
+these in libcarrot have two properties:
+
+- **internal macros**: these instructions are to use by modules within
+ libcarrot itself at compilation time. As libcarrot optimizes expressions
+ and conditions when possible, you can sort of use these macros in “runtime”;
+- **raw macros**: normally, macros allow other macros to be used in their
+ content. Raw macros disallow this, which means that the content of the
+ macro will not be interpreted by the preprocessor. Raw macros will
+ also be set as internal macros.
+
+These properties are important to have in mind while naming your macros:
+
+- macros starting with two underscores, e.g. `__SOMETHING`, will automatically
+ be defined as an internal macro;
+- other macros will not, but for private use at runtime, according to the
+ C standards, your macro's name shall start with a `_` followed by an
+ uppercase letter (with exceptions).
+
+If your macro doesn't start with two underscores but you want your macro to
+be defined as an internal macro, you can use one of the two instructions:
#defint NAME content
#define_int NAME content
+ #define_int NAME(arg0, arg1) content
-Internal macros.
+If you want to define your macro as a raw macro, you can define of the
+following two instructions:
#defraw NAME content
#define_raw NAME content
-Raw macros.
+Obviously, you cannot define raw macros with arguments as the arguments
+cannot be interpreted within the content of the macro.
# Conditional code
+You can produce conditional content (including preprocessor instructions) by
+using the basic instructions given below:
#if expr
+ #elif expr
+ #else
+ #endif
+
+Where `expr` represents an expression to evaluate. Expressions evaluated to
+0 or equivalent will be interpreted as false, others will be interpreted as
+true. If the expression depends on unknown objects or objects of unknown
+values at superprocessing time, the libcarrot preprocessor will not optimize
+
#ifdef name
#ifndef name
- #elif expr
#elifdef name
#elifndef name
- #else
- #endif
# File inclusion
diff --git a/docs/tools/build-tools.en.md b/docs/tools/build-tools.en.md
index 979b85d..90ca1d6 100644
--- a/docs/tools/build-tools.en.md
+++ b/docs/tools/build-tools.en.md
@@ -32,7 +32,7 @@ architecture-specific flags, etc.
For example, the definition of a C/C++ compiler (with non-exported functions,
all that is exported is the dictionary) is:
-{% highlight python linenos %}
+```python
Carrot_Compiler = {
'conf_cc': _configure_cc,
'cc': _cc,
@@ -40,7 +40,7 @@ Carrot_Compiler = {
'conf_cxx': _configure_cxx,
'cxx': _cxx
}
-{% endhighlight %}
+```
Once your tool is done, you shall import it in `Internals/build/__init__.py`
and add its correspondance table to the `__tools` dictionary.
@@ -66,9 +66,9 @@ ones (C99, C89).
The `conf_cc` method will be called to configure the C compiler. It should
be defined this way:
-{% highlight python linenos %}
+```python
def <conf_cc>(arch, endian, system, flavour, standard)
-{% endhighlight %}
+```
Where the standard parameter is a string, usually one of `"c89"`, `"c95"`,
`"c99"`, `"c11"`.
@@ -77,9 +77,9 @@ As for the other functions, the configuration function will generate a set
of options that the main compiling function will take as a first argument.
This main function is defined as is:
-{% highlight python linenos %}
+```python
def <cc>(params, object_path, source_path, include_dirs)
-{% endhighlight %}
+```
Where the include directories parameter is a list of paths.
@@ -92,9 +92,9 @@ for a given C++ standard. As for C, higher and retrocompatible standards
The `conf_cxx` method will be called to configure the C++ compiler. It should
be defined this way:
-{% highlight python linenos %}
+```python
def <conf_cxx>(arch, endian, system, flavour, standard)
-{% endhighlight %}
+```
Where the standard parameter is a string, usually one of `"c++98"`, `"c++03"`,
`"c++11"`, `"c++17"`.
@@ -103,9 +103,9 @@ As for the other functions, the configuration function will generate a set
of options that the main compiling function will take as a first argument.
This main function is defined as is:
-{% highlight python linenos %}
+```python
def <cxx>(params, object_path, source_path, include_dirs)
-{% endhighlight %}
+```
Where the include directories parameter is a list of paths.
@@ -122,9 +122,9 @@ all files to simplify this).
The `conf_asm` method will be called to configure the assembler. It should
be defined this way:
-{% highlight python linenos %}
+```python
def <conf_asm>(arch, endian, system, flavour, syntax)
-{% endhighlight %}
+```
Where the syntax is a string representing the syntax name, including (but not
limited to) `gnu`, `nasm`, `asmsh`, etc.
@@ -133,9 +133,9 @@ As for the other functions, the configuration function will generate a set
of options that the main compiling function will take as a first argument.
This main function is defined as is:
-{% highlight python linenos %}
+```python
def <asm>(params, object_path, source_path)
-{% endhighlight %}
+```
## Archiver (packer)
libcarrot was primarily made to build static libraries. Static libraries are
@@ -146,17 +146,17 @@ The `conf_pack` method will be called to configure the static library
generator (also called “packer” or “archiver”). It should be defined
this way:
-{% highlight python linenos %}
+```python
def <conf_pack>(arch, endian, system, flavour)
-{% endhighlight %}
+```
As for the other functions, the configuration function will generate a set
of options that the main function will take as a first argument.
This main function is defined as is:
-{% highlight python linenos %}
+```python
def <pack>(params, library_path, objects_path)
-{% endhighlight %}
+```
Where the objects path is a list of paths leading to the objects.
@@ -168,17 +168,17 @@ their format defined by the ABI.
The `conf_link` method will be called to configure the shared/dynamic
library. It should be defined this way:
-{% highlight python linenos %}
+```python
def <conf_link>(arch, endian, system, flavour, abi)
-{% endhighlight %}
+```
As for the other functions, the configuration function will generate a set
of options that the main function will take as a first argument.
This main function is defined as is:
-{% highlight python linenos %}
+```python
def <link>(params, library_path, object_paths)
-{% endhighlight %}
+```
Where, as for the packer, the objects path is a list of paths leading to
the objects (flavour format).
@@ -191,14 +191,13 @@ A binary executable is executed by the kernel, and uses a native format
The `conf_bin` method will be called to configure the binary executable
maker. It should be defined this way:
-{% highlight python linenos %}
+```python
def <conf_bin>(arch, endian, system, flavour, abi)
-{% endhighlight %}
+```
As for the other functions, the configuration function will generate a set
of options that the main function will take as a first argument.
This main function is defined as is:
-{% highlight python linenos %}
+```python
def <bin>(params, binary_path, object_paths)
-{% endhighlight %}
diff --git a/make b/make
new file mode 100755
index 0000000..d8d5181
--- /dev/null
+++ b/make
@@ -0,0 +1,8 @@
+#!/bin/sh
+curdir="${0/*}"
+if ! [ x"$curdir" = "$0" ]; then
+ cd "$curdir"
+fi
+
+PROGNAME='./make' tools/python3.sh tools/make.py "$@"
+exit $?
diff --git a/modules/all/core-sh/bits/byteswap.h b/modules/all/core-sh/bits/byteswap.h
index 148f2ed..dcfa988 100644
--- a/modules/all/core-sh/bits/byteswap.h
+++ b/modules/all/core-sh/bits/byteswap.h
@@ -37,10 +37,10 @@
#elif __GNUC_ASM
static __asm_inline __uint16_t __byteswap_swapb(__uint16_t __data) {
- uint16_t __res; asm("swap.b %1, %0":"=r"(__res):"r"(__data));
+ __uint16_t __res; asm("swap.b %1, %0":"=r"(__res):"r"(__data));
return (__res); }
static __asm_inline __uint32_t __byteswap_swapw(__uint32_t __data) {
- uint32_t __res; asm("swap.w %1, %0":"=r"(__res):"r"(__data));
+ __uint32_t __res; asm("swap.w %1, %0":"=r"(__res):"r"(__data));
return (__res); }
# define __bswap_16(_X) __byteswap_swapb(_X)
diff --git a/modules/all/core-sh/docs/intrinsics.en.md b/modules/all/core-sh/docs/intrinsics.en.md
index 2144eb0..7c9756d 100644
--- a/modules/all/core-sh/docs/intrinsics.en.md
+++ b/modules/all/core-sh/docs/intrinsics.en.md
@@ -214,7 +214,7 @@ uint16_t swapb(uint16_t data);
uint32_t swapw(uint32_t data);
```
-There are also equivalents I can't seem to understand...?
+There are also equivalents I can't seem to understand…?
```c
uint16_t end_cnvw(uint16_t rm);
diff --git a/modules/all/core-sh/info.yml b/modules/all/core-sh/info.yml
index 3069dff..11f1e4e 100644
--- a/modules/all/core-sh/info.yml
+++ b/modules/all/core-sh/info.yml
@@ -4,4 +4,4 @@ magic: potatosdk-1.0
description: The core libc, SuperH-specific parts.
license: free
requires:
- arch: [sh]
+ arch: [sh]
diff --git a/modules/all/core/include/locale.h b/modules/all/core/include/locale.h
index 407f19f..64e76a5 100644
--- a/modules/all/core/include/locale.h
+++ b/modules/all/core/include/locale.h
@@ -40,6 +40,8 @@
#define LC_NUMERIC 4
#define LC_TIME 5
+#define __LC_MAX 6
+
/* Set the locale. */
_EXTERN char* setlocale
diff --git a/modules/all/core/src/locales.c b/modules/all/core/src/locales.c
index 926d161..a3d8dac 100644
--- a/modules/all/core/src/locales.c
+++ b/modules/all/core/src/locales.c
@@ -70,19 +70,20 @@ char *setlocale(int category, const char *locale_name)
const struct lconv *locale;
/* select the locale */
- if (!locale_name[0] || !memcmp(locale_name, "C", 2)) {
+ if (locale_name[0] == '\0' || memcmp(locale_name, "C", 2) == NULL) {
memcpy(opaque, "C", 2);
locale = &c_locale;
- } else return (NULL);
+ } else
+ return (NULL);
/* set the locale */
- if (!category) {
+ if (category == LC_ALL) {
current_locales[0] = locale;
current_locales[1] = locale;
current_locales[2] = locale;
current_locales[3] = locale;
current_locales[4] = locale;
- } else if (category <= 5)
+ } else if (category < __LC_MAX)
current_locales[category - 1] = locale;
/* return the opaque string */
diff --git a/modules/all/helloworld/docs/index.en.md b/modules/all/helloworld/docs/index.en.md
index 728d943..5c7293d 100644
--- a/modules/all/helloworld/docs/index.en.md
+++ b/modules/all/helloworld/docs/index.en.md
@@ -5,9 +5,9 @@ This module is a demonstration module for new contributors. It implements
a demonstration function, `helloworld()`, that puts _a sample string_ to
standard output. It is defined this way:
-{% highlight c linenos %}
+```c
void helloworld(const char *string);
-{% endhighlight %}
+```
A newline is printed after the string. If the given string is `NULL`,
`"hello, world"` is printed, followed by a newline.
diff --git a/modules/all/helloworld/roles.yml b/modules/all/helloworld/roles.yml
index 4a94caa..2a7be6a 100644
--- a/modules/all/helloworld/roles.yml
+++ b/modules/all/helloworld/roles.yml
@@ -1,6 +1,6 @@
%YAML 1.2
---
src:
- helloworld.c: hello world function.
+ helloworld.c: hello world function.
include:
- helloworld.h: hello world features.
+ helloworld.h: hello world features.
diff --git a/modules/all/helloworld/src/helloworld.c b/modules/all/helloworld/src/helloworld.c
index 22cd61e..9265ab7 100644
--- a/modules/all/helloworld/src/helloworld.c
+++ b/modules/all/helloworld/src/helloworld.c
@@ -36,7 +36,7 @@
void hello_world(const char *string)
{
- if (!string)
+ if (string == NULL)
string = "hello, world";
puts(string);
}
diff --git a/modules/all/info.yml b/modules/all/info.yml
index d34f938..aa67d2c 100644
--- a/modules/all/info.yml
+++ b/modules/all/info.yml
@@ -4,11 +4,11 @@ magic: potatosdk-1.0
description: >-
Meta-system for modules that are suitable for all systems.
default:
- c:
- - all/core
- - all/core-sh
- - all/iconv
- c++:
- - all/cpp
+ c:
+ - all/core
+ - all/core-sh
+ - all/iconv
+ c++:
+ - all/cpp
import:
- compiler
diff --git a/modules/all/mem/docs/index.en.md b/modules/all/mem/docs/index.en.md
index 9b190b8..1744ec7 100644
--- a/modules/all/mem/docs/index.en.md
+++ b/modules/all/mem/docs/index.en.md
@@ -19,10 +19,10 @@ for parent functions.
This module provides the standard memory allocation interface. To allocate
memory, any of the following functions can be used:
-{% highlight c linenos %}
+```c
void *malloc(size_t size);
void *calloc(size_t nmemb, size_t size);
-{% endhighlight %}
+```
`malloc()` is the generic function for allocating memory, and
`calloc()` takes the number of elements, `nmemb`, and the size of each
@@ -35,9 +35,9 @@ and as the lower address of the memory area for further usage.
Once the allocated memory area is no longer used, you shall free the memory
area by using the following function:
-{% highlight c linenos %}
+```c
void free(void *ptr);
-{% endhighlight %}
+```
You are supposed to pass the memory area identifier, i.e. the lowest memory
address, to `free()`, and **not** “any pointer in the area”.
@@ -45,9 +45,9 @@ address, to `free()`, and **not** “any pointer in the area”.
To re-allocate memory, i.e. extending or reducing an existing memory area,
use the `realloc()` function defined below:
-{% highlight c linenos %}
+```c
void *realloc(void *ptr, size_t size);
-{% endhighlight %}
+```
Notice that the pointer will very likely change, so please update your
pointer using the return value from `realloc()`.
diff --git a/modules/all/mem/docs/tweaking.en.md b/modules/all/mem/docs/tweaking.en.md
index 10aff32..66307d6 100644
--- a/modules/all/mem/docs/tweaking.en.md
+++ b/modules/all/mem/docs/tweaking.en.md
@@ -8,15 +8,15 @@ and this document is a description of them.
# malloc() related hooks
To initialize
-{% highlight c linenos %}
+```c
typedef void __malloc_initialize_hook_t(void);
__malloc_initialize_hook_t __malloc_initialize_hook;
-{% endhighlight %}
+```
Once the malloc implementation is initialized, these callbacks
-{% highlight c linenos %}
+```c
typedef void *__malloc_hook_t(size_t size, const void *caller);
typedef void *__realloc_hook_t(void *ptr, size_t size, const void *caller);
typedef void *__memalign_hook_t(size_t alignment, size_t size,
@@ -27,6 +27,6 @@ __malloc_hook_t __malloc_hook;
__realloc_hook_t __realloc_hook;
__memalign_hook_t __memalign_hook;
__free_hook_t __free_hook;
-{% endhighlight %}
+```
diff --git a/modules/all/string-sh/info.yml b/modules/all/string-sh/info.yml
index 28b21d2..30f7240 100644
--- a/modules/all/string-sh/info.yml
+++ b/modules/all/string-sh/info.yml
@@ -6,4 +6,4 @@ license: free
depends:
- all/string
requires:
- arch: [sh]
+ arch: [sh]
diff --git a/modules/all/string/docs/memory.en.md b/modules/all/string/docs/memory.en.md
index 11e23ce..23339e5 100644
--- a/modules/all/string/docs/memory.en.md
+++ b/modules/all/string/docs/memory.en.md
@@ -11,9 +11,9 @@ The size of the memory areas is usually required using a `size_t` parameter.
To initialize the content of a memory area with the value of a character,
use the following standard function:
-{% highlight c linenos %}
+```c
void *memset(void *s, int c, size_t n);
-{% endhighlight %}
+```
Where `c` is the value to set to each byte in the area, and therefore should
fit in a byte (usually 0 to 255).
@@ -21,10 +21,10 @@ fit in a byte (usually 0 to 255).
# Copy memory
There are two standard functions for copying raw memory:
-{% highlight c linenos %}
+```c
void *memcpy(void *dst, const void *src, size_t n);
void *memmove(void *dst, const void *src, size_t n);
-{% endhighlight %}
+```
`memcpy()` will always copy from the lower address (`src`) to the higher
one (`src + n`), whereas `memmove()` will adapt the way it is copying,
@@ -33,9 +33,9 @@ in case the memory areas are overlapping.
If you ought to copy until a certain character is encountered, you can
use the following function:
-{% highlight c linenos %}
+```c
void *memccpy(void *dst, const void *src, int c, size_t n);
-{% endhighlight %}
+```
Where `c` is the ending byte value, which can be stored in a byte.
@@ -43,9 +43,9 @@ Where `c` is the ending byte value, which can be stored in a byte.
You may want to compare the content of two memory areas, usually to check
if they are the same. The following function does this:
-{% highlight c linenos %}
+```c
int memcmp(const void *s, const void *t, size_t n);
-{% endhighlight %}
+```
The returned value is either zero if no difference has been found between
the two memory areas, or the difference between the values (first minus second)
@@ -55,9 +55,9 @@ of the bytes in the first position where the areas differ.
To find the first position of a character in a memory area, use the
following function:
-{% highlight c linenos %}
+```c
void *memchr(const void *s, int c, size_t n);
-{% endhighlight %}
+```
This function returns the pointer to the first occurrence of this value in
the memory area, or `NULL` if the character has not been found.
diff --git a/modules/all/string/docs/strings.en.md b/modules/all/string/docs/strings.en.md
index 7ebcf35..93c6342 100644
--- a/modules/all/string/docs/strings.en.md
+++ b/modules/all/string/docs/strings.en.md
@@ -8,17 +8,17 @@ character (code zero), usually represented as `\0`.
As the length is not given aside the string, you have to calculate it by
finding the NUL character, by using this function:
-{% highlight c linenos %}
+```c
size_t strlen(const char *s);
-{% endhighlight %}
+```
# Copy a string into another
To copy the content of a string into another, including the NUL byte, you
can use the following function:
-{% highlight c linenos %}
+```c
char *strcpy(char *dst, const char *src);
-{% endhighlight %}
+```
The destination buffer has to be big enough.
@@ -26,10 +26,10 @@ The destination buffer has to be big enough.
To copy a string at the end of another, you can use the following two
functions:
-{% highlight c linenos %}
+```c
char *strcat(char *dst, const char *src);
char *strncat(char *dst, const char *src, size_t n);
-{% endhighlight %}
+```
The NUL byte at the end of the initial string is overwritten, and a NUL
byte is always added at the end of the destination with the additional string
@@ -43,10 +43,10 @@ copied.
# Compare strings
To check if strings are equivalent, use one of the following functions:
-{% highlight c linenos %}
+```c
int strcmp(const char *s, const char *t);
int strncmp(const char *s, const char *t, size_t n);
-{% endhighlight %}
+```
This function returns zero if the strings are equal, or the difference between
the first and second character at the first position where the strings differ.
@@ -55,10 +55,10 @@ the first and second character at the first position where the strings differ.
To look for a character in a string, you can use one of the following
functions:
-{% highlight c linenos %}
+```c
char *strchr(const char *s, int c);
char *strrchr(const char *s, int c);
-{% endhighlight %}
+```
`strchr()` searches the string from lower to upper, and `strrchr()` searches
the string from upper to lower. It returns the address if it finds the
@@ -66,9 +66,9 @@ character, or `NULL` if it doesn't.
To look for more than one character, you can use this function instead:
-{% highlight c linenos %}
+```c
char *strpbrk(const char *s, const char *accept);
-{% endhighlight %}
+```
This function searches the string from lower to upper, returns the address
if it finds one of the characters in `accept` (excluding the NUL character),
@@ -77,9 +77,9 @@ or `NULL` if none of the characters were found.
# Search a string for another string
To look for a string in another string, you can use the following function:
-{% highlight c linenos %}
+```c
char *strstr(const char *haystack, const char *needle);
-{% endhighlight %}
+```
This function returns `NULL` if `needle` has not been found in `haystack`, or
a pointer to the first found occurrence of `needle` in `haystack`.
@@ -88,7 +88,7 @@ a pointer to the first found occurrence of `needle` in `haystack`.
To calculate the length of a prefix, made of a set of characters (or everything
but a set of characters), in a string, you can use the following functions:
-{% highlight c linenos %}
+```c
size_t strspn(const char *s, const char *accept);
size_t strcspn(const char *s, const char *reject);
-{% endhighlight %}
+```
diff --git a/modules/casiowin/core/src/assert/assert.c b/modules/casiowin/core/src/assert/assert.c
index 197b35d..0e452ca 100644
--- a/modules/casiowin/core/src/assert/assert.c
+++ b/modules/casiowin/core/src/assert/assert.c
@@ -45,7 +45,7 @@ extern void __assert_putdisp _OF((void)) __THROW;
* @arg expr the expression that failed.
* @arg file the name/path to the source file.
* @arg line the line number.
- * @arg func the function name.
+ * @arg func the function name (possibly NULL).
*/
void __assert_fail(const char *expr, const char *file,
@@ -57,7 +57,8 @@ void __assert_fail(const char *expr, const char *file,
/* prepare the top line */
sprintf(f, "%d", line);
n = strlen(f); fn = strlen(file);
- if (fn <= 21 - 1 - n) sprintf(f, "%s:%d", file, line);
+ if (fn <= 21 - 1 - n)
+ sprintf(f, "%s:%d", file, line);
else {
size_t newfn = 21 - 3 - 1 - n;
file = &file[fn - newfn];
diff --git a/modules/casiowin/easy-input/info.yml b/modules/casiowin/easy-input/info.yml
index 52c4a6a..7860cb0 100644
--- a/modules/casiowin/easy-input/info.yml
+++ b/modules/casiowin/easy-input/info.yml
@@ -4,4 +4,4 @@ magic: potatosdk-1.0
description: Easy input dialogs.
license: free
requires:
- deps: ['casiowin/fxlib']
+ deps: ['casiowin/fxlib']
diff --git a/modules/casiowin/fxlib/docs/comm.en.md b/modules/casiowin/fxlib/docs/comm.en.md
index af4f5a7..5f35a76 100644
--- a/modules/casiowin/fxlib/docs/comm.en.md
+++ b/modules/casiowin/fxlib/docs/comm.en.md
@@ -20,10 +20,10 @@ There can only be **zero or one communications opened simultaneously**.
# Opening and closing
To open and close the communication, you can use the following functions:
-{% highlight c %}
+```c
int Comm_Open(unsigned short flags);
int Comm_Close(int imm);
-{% endhighlight %}
+```
The communication opening flags contain all of the information about the
connexion:
@@ -56,19 +56,19 @@ should be ended directly (1) or when the buffered data is sent (0).
When up, you can test if the current communication is on USB or not using:
-{% highlight c %}
+```c
int Comm_IsUSB(void);
-{% endhighlight %}
+```
# Reading from the communication port
There are three different functions for reading data from the communication
port:
-{% highlight c %}
+```c
int Comm_SpyByte(unsigned char *result);
int Comm_ReadByte(unsigned char *result);
int Comm_ReadBytes(char *buffer, int count);
-{% endhighlight %}
+```
`Comm_ReadByte()` and `Comm_ReadBytes()` read one or more bytes in the
incoming buffer while popping them out of it.
@@ -79,7 +79,7 @@ buffer.
# Writing to the communication port
There are two functions for transmitting data to the communication port:
-{% highlight c %}
+```c
int Comm_SendByte(unsigned char byte);
int Comm_SendBytes(unsigned char *buf, int count);
-{% endhighlight %}
+```
diff --git a/modules/casiowin/fxlib/docs/draw.en.md b/modules/casiowin/fxlib/docs/draw.en.md
index 07df963..00b4dba 100644
--- a/modules/casiowin/fxlib/docs/draw.en.md
+++ b/modules/casiowin/fxlib/docs/draw.en.md
@@ -20,10 +20,10 @@ If you want to get the current content of the VRAM (which you can't access
directly), or want to get the content of the screen, you can use these
functions:
-{% highlight c %}
+```c
void Bdisp_GetDisp_DD(unsigned char *data);
void Bdisp_GetDisp_VRAM(unsigned char *data);
-{% endhighlight %}
+```
In the two cases, the `data` parameter should be pointing to a memory area
containing at least `IM_VRAM_SIZE` (1024) bytes.
@@ -35,38 +35,38 @@ per line and from left to right, where a '0' is white and a '1' is black.
When the VRAM is ready, you can update the screen with its content using
the following function:
-{% highlight c %}
+```c
void Bdisp_PutDisp_DD(void);
-{% endhighlight %}
+```
If you only want to update an area of the screen, even though it is not
recommended, you can use the following function:
-{% highlight c %}
+```c
void Bdisp_PutDispArea_DD(const DISPBOX *area);
-{% endhighlight %}
+```
The `DISPBOX` structure defines a rectangle using the upper-left and the
lower-right corners, defined by their coordinates.
It has the following properties, in that order:
-{% highlight c %}
+```c
typedef struct {
int left; /* upper-left x, 0 to 127 */
int top; /* upper-left y, 0 to 63 */
int right; /* lower-right x, 0 to 127 */
int bottom; /* lower-right y, 0 to 63 */
} DISPBOX;
-{% endhighlight %}
+```
# Read the display
Although it is _not recommended_, you can read data from the VRAM or the
screen, using one of these functions:
-{% highlight c %}
+```c
void Bdisp_ReadArea_DD(const DISPBOX *area, unsigned char *data);
void Bdisp_ReadArea_VRAM(const DISPBOX *area, unsigned char *data);
-{% endhighlight %}
+```
`area` is the rectangle coordinates, and has the previously described
structure. `data` is the buffer.
@@ -77,20 +77,20 @@ This is not given by the manual...
# Clear some pixels
These functions turn all pixels on the VRAM/screen to white.
-{% highlight c %}
+```c
void Bdisp_AllClr_DD(void);
void Bdisp_AllClr_VRAM(void);
void Bdisp_AllClr_DDVRAM(void);
-{% endhighlight %}
+```
If you only want to clear an area, you can use the following functions
instead:
-{% highlight c %}
+```c
void Bdisp_AreaClr_DD(const DISPBOX *area);
void Bdisp_AreaClr_VRAM(const DISPBOX *area);
void Bdisp_AreaClr_DDVRAM(const DISPBOX *area);
-{% endhighlight %}
+```
The `DISPBOX` was described previously.
@@ -98,9 +98,9 @@ The `DISPBOX` was described previously.
This function turn all black pixels to white and white pixels to black in
an area in the VRAM:
-{% highlight c %}
+```c
void Bdisp_AreaReverseVRAM(int x1, int y1, int x2, int y2);
-{% endhighlight %}
+```
Notice that the name and the arguments follow a different logic to
`Bdisp_AreaClr_VRAM` for example, but that the current prototype is maintained
@@ -110,11 +110,11 @@ for compatibility.
If you simply want to set the color of a pixel on the screen, you can
use one of the following functions:
-{% highlight c %}
+```c
void Bdisp_SetPoint_DD(int x, int y, unsigned char point);
void Bdisp_SetPoint_VRAM(int x, int y, unsigned char point);
void Bdisp_SetPoint_DDVRAM(int x, int y, unsigned char point);
-{% endhighlight %}
+```
`point` should be either 0 if the dot should be set to white, or 1 if it
should be set to black.
@@ -122,9 +122,9 @@ should be set to black.
If you want to get the status of a pixel on the screen, you can use
the following function:
-{% highlight c %}
+```c
int Bdisp_GetPoint_VRAM(int x, int y);
-{% endhighlight %}
+```
This function returns 0 if the dot is white, or 1 if the dot is black.
@@ -132,16 +132,16 @@ This function returns 0 if the dot is white, or 1 if the dot is black.
If you want to display a bitmap on the screen, you can use one of the
following functions:
-{% highlight c %}
+```c
void Bdisp_WriteGraph_DD(const DISPGRAPH *graph);
void Bdisp_WriteGraph_VRAM(const DISPGRAPH *graph);
void Bdisp_WriteGraph_DDVRAM(const DISPGRAPH *graph);
-{% endhighlight %}
+```
The `DISPGRAPH` is the set of coordinates, display style, and bitmap data.
It has the following properties:
-{% highlight c %}
+```c
typedef struct {
int x; /* 0 to 127 */
int y; /* 0 to 63 */
@@ -149,17 +149,17 @@ typedef struct {
WRITEMODIFY WriteModify;
WRITEKIND WriteKind;
} DISPGRAPH;
-{% endhighlight %}
+```
`GRAPHDATA` represents bitmap data. It has the following properties:
-{% highlight c %}
+```c
typedef struct {
int width;
int height;
unsigned char *pBitmap;
} GRAPHDATA;
-{% endhighlight %}
+```
`WRITEMODIFY` represents the write modification graphic. Any element of this
type can have one of these values:
@@ -179,9 +179,9 @@ have one of these values:
# Draw and clear a line on the screen
To draw a line, the following function is provided:
-{% highlight c %}
+```c
void Bdisp_DrawLineVRAM(int x1, int y1, int x2, int y2);
-{% endhighlight %}
+```
`x1` and `y1` being the coordinates of the line's starting point, and
`x2` and `y2` being the coordinates of the line's ending point.
@@ -189,9 +189,9 @@ void Bdisp_DrawLineVRAM(int x1, int y1, int x2, int y2);
If you want to draw a white line instead of a black line, use the following
function:
-{% highlight c %}
+```c
void Bdisp_ClearLineVRAM(int x1, int y1, int x2, int y2);
-{% endhighlight %}
+```
# Drawing text on the screen
The character interface from fxlib uses a 21x8 character matrix (which is
@@ -208,9 +208,9 @@ starting point, and move accordingly. There is no 'default' value for the
cursor, so update the cursor before using it for the first time.
To update the position of this cursor, you can use the following function:
-{% highlight c %}
+```c
void locate(int col, int row);
-{% endhighlight %}
+```
Notice that the grid coordinates don't start from 0, but 1. So it goes from
1 to 21 for the column, and from 1 to 8 for the row.
@@ -218,12 +218,12 @@ Notice that the grid coordinates don't start from 0, but 1. So it goes from
Once the cursor is located where you want the string to start, use one of the
following functions to print a multi-byte FONTCHARACTER string:
-{% highlight c %}
+```c
void Print(const unsigned char *str);
void PrintRev(const unsigned char *str);
void PrintC(const unsigned char *c);
void PrintRevC(const unsigned char *c);
-{% endhighlight %}
+```
The `Print`/`PrintRev` functions take strings, print them and move the cursor
to the character directly at the right of the string. It the end of line is
@@ -237,10 +237,10 @@ what the difference is exactly with `Print`).
If you want to print a line, you can use one of the following functions:
-{% highlight c %}
+```c
void PrintLine(const unsigned char *str, int max);
void PrintRLine(const unsigned char *str, int max);
-{% endhighlight %}
+```
It displays a character string (the 'R' version prints it in reversed color)
from the current cursor position to the specified ending x position.
@@ -250,9 +250,9 @@ the specified position is padded with blanks.
If you don't want to use the cursor, or want to print characters out of the
matrix positions, you can use this function directly:
-{% highlight c %}
+```c
void PrintXY(int x, int y, const unsigned char *str, int type);
-{% endhighlight %}
+```
Where the `x` and `y` parameters are the screen coordinates (x going from
0 to 127, y going from 0 to 63), `str` being the multi-byte FONTCHARACTER
@@ -261,9 +261,9 @@ color.
There is an equivalent of this for the 'mini' font (smaller):
-{% highlight c %}
+```c
void PrintMini(int x, int y, const unsigned char *str, int type);
-{% endhighlight %}
+```
But the `type` field doesn't have the same value, as it must be one of these:
@@ -279,10 +279,10 @@ equivalent in the 'mini' font!
It is possible to save and recall screen images using the system, with the
following functions:
-{% highlight c %}
+```c
void SaveDisp(unsigned char num);
void RestoreDisp(unsigned char num);
-{% endhighlight %}
+```
The display number can be one of `SAVEDISP_PAGE1`, `SAVEDISP_PAGE2` or
`SAVEDISP_PAGE3`. These functions only interact with the VRAM, so once
@@ -293,9 +293,9 @@ the screen with the restored image.
This function makes a pop-up window, appropriate for the use of the character
matrix (see "Drawing text on the screen"). It has the following prototype:
-{% highlight c %}
+```c
void PopUpWin(int number_of_lines);
-{% endhighlight %}
+```
The parameter is the number of lines you want to have in the pop-up,
between 1 and 5.
diff --git a/modules/casiowin/fxlib/docs/file.en.md b/modules/casiowin/fxlib/docs/file.en.md
index 8ffacd9..eb2c067 100644
--- a/modules/casiowin/fxlib/docs/file.en.md
+++ b/modules/casiowin/fxlib/docs/file.en.md
@@ -24,9 +24,9 @@ data files or applications, only small data files).
# Getting the amount of free space on a device
To get the amount of free bytes on a device, use the following function:
-{% highlight c %}
+```c
int Bfile_GetMediaFree(enum DEVICE_TYPE device, int *freebytes);
-{% endhighlight %}
+```
The device value can be one of:
@@ -41,10 +41,10 @@ requested amount, and 0 is returned.
# Creating and deleting directories
To create and delete directories, you can use the following functions:
-{% highlight c %}
+```c
int Bfile_CreateDirectory(const FONTCHARACTER *path);
int Bfile_DeleteDirectory(const FONTCHARACTER *path);
-{% endhighlight %}
+```
TODO: if there are files in a directory, does the deletion fail or deletes
the files as well? (... or does something else?)
@@ -54,9 +54,9 @@ If you only want to create a file without setting its content, or at least
for reserving space (and check if there is enough) to write to it afterwards,
you can use the following function:
-{% highlight c %}
+```c
int Bfile_CreateFile(const FONTCHARACTER *path, int size);
-{% endhighlight %}
+```
It returns a negative value if an error has occured (being one of the
`IML_FILEERR_*` error codes), or 0 if everything went well.
@@ -64,9 +64,9 @@ It returns a negative value if an error has occured (being one of the
On the other side, if you want to delete files, you shall use the following
function:
-{% highlight c %}
+```c
int Bfile_DeleteFile(const FONTCHARACTER *path);
-{% endhighlight %}
+```
This function has the same return code logic as for the creating function.
Of course, it is not recommended to delete a currently opened file.
@@ -74,9 +74,9 @@ Of course, it is not recommended to delete a currently opened file.
# Getting the size of a file
In order to gather the size of a file, use the following function:
-{% highlight c %}
+```c
int Bfile_GetFileSize(int handle);
-{% endhighlight %}
+```
If an error occurs, a negative value is returned, which is one of the
`IML_FILEERR_*` error codes. Otherwise, the requested size is returned.
@@ -84,11 +84,11 @@ If an error occurs, a negative value is returned, which is one of the
# Creating, renaming and deleting main memory files
To manage main memory files, you can use the following functions:
-{% highlight c %}
+```c
int Bfile_CreateMainMemory(const unsigned char *name);
int Bfile_RenameMainMemory(const unsigned char *old, const unsigned char *new);
int Bfile_DeleteMainMemory(const unsigned char *name);
-{% endhighlight %}
+```
Each of these functions will return a negative value if an error occurs,
which is one of the `IML_FILEERR_*` error codes, or 0 if everything went well.
@@ -97,9 +97,9 @@ which is one of the `IML_FILEERR_*` error codes, or 0 if everything went well.
File descriptors are actually integers. To open a file descriptor, use
the following function:
-{% highlight c %}
+```c
int Bfile_OpenFile(const FONTCHARACTER *path, int mode);
-{% endhighlight %}
+```
Where the open mode is among these ones:
@@ -116,13 +116,13 @@ otherwise, the file descriptor.
Once you are done with the file descriptor, you **must** close it using
the following function:
-{% highlight c %}
+```c
int Bfile_CloseFile(int handle);
-{% endhighlight %}
+```
Here's an example for reading and writing a save:
-{% highlight c %}
+```c
static const FONTCHARACTER save_path = {
'\\', '\\', 'f', 'l', 's', '0', '\\',
'g', 'a', 'm', 'e', 's', 'a', 'v', 'e', '.', 's', 'a', 'v', 0};
@@ -181,15 +181,15 @@ int write_save(const struct save *save)
Bfile_CloseFile(handle);
return (ret);
}
-{% endhighlight %}
+```
# Opening a file in the main memory
Opening a Bfile handle for the main memory is different than for
"normal files", so it requires a special function, which is the following:
-{% highlight c %}
+```c
int Bfile_OpenMainMemory(const unsigned char *name);
-{% endhighlight %}
+```
Where the name is multi-byte FONTCHARACTER encoded, and limited to eight bytes.
The return code is the same than for `Bfile_OpenFile()`.
@@ -201,9 +201,9 @@ close it using the same functions as for 'normal' files.
# Read data from a file
To read from a file descriptor, you shall use the following function:
-{% highlight c %}
+```c
int Bfile_ReadFile(int handle, void *buf, int size, int readpos);
-{% endhighlight %}
+```
The read position is the point from where to read the file. To read from
the current position, set this value to -1. The cursor will be set to right
@@ -216,9 +216,9 @@ read. An EOF (End Of File) is indicated by the `IML_FILEERR_ENDOFFILE` error.
# Write data to a file
To write data to a file descriptor, use the following function:
-{% highlight c %}
+```c
int Bfile_WriteFile(int handle, const void *buf, int size);
-{% endhighlight %}
+```
Same as before, except you can only write from the current position.
If an error has occured, returns a negative value which is the
@@ -228,9 +228,9 @@ by the file pointer (and **NOT** the number of written bytes, for some reason).
# Move the file cursor
To move the file cursor, use the following function:
-{% highlight c %}
+```c
int Bfile_SeekFile(int handle, int pos);
-{% endhighlight %}
+```
If an error has occured, returns a negative value which is the
`IML_FILEERR_*` error code, otherwise, it returns the number of bytes that
@@ -239,12 +239,12 @@ can continuously be read (TODO: check this).
# Listing files in directories
Finding file information in a directory is accomplished using these functions:
-{% highlight c %}
+```c
int Bfile_FindFirst(const FONTCHARACTER *path, int *handle,
FONTCHARACTER *found, FILE_INFO *file);
int Bfile_FindNext(int handle, FONTCHARACTER *found, FILE_INFO *info);
int Bfile_FindClose(int handle);
-{% endhighlight %}
+```
You first open a find handle by looking for the first entry in a directory,
then look for all the others until there is none left, then
@@ -255,7 +255,7 @@ As for the file descriptors, find handles are represented as integers.
The `found` fixed-width FONTCHARACTER buffer should be at least 13 elements.
The `FILE_INFO` structure contains the following elements:
-{% highlight c %}
+```c
typedef struct {
unsigned short id; /* file index */
unsigned short type; /* file type (see below) */
@@ -264,7 +264,7 @@ typedef struct {
unsigned int property; /* the file is still opened (0 if not) */
unsigned long address; /* top address of the data (don't use this) */
} FILE_INFO;
-{% endhighlight %}
+```
As you have probably guessed by now, the CASIOWIN filesystem preprocesses the
files when they are saved, to check if the built-in applications will be
@@ -291,7 +291,7 @@ Here's a function that lists the files in an unknown format of the
root directory in the storage memory, using a callback that only
takes the path:
-{% highlight c %}
+```c
static FONTCHARACTER flash_root = {'\\', '\\', 'f', 'l', 's', '0', '\\'};
void list_files(void (*callback)(const FONTCHARACTER *name))
@@ -319,4 +319,4 @@ end:
/* Call the callback to tell we're done. */
(*callback)(NULL);
}
-{% endhighlight %}
+```
diff --git a/modules/casiowin/fxlib/docs/index.en.md b/modules/casiowin/fxlib/docs/index.en.md
index 8853592..1e217e4 100644
--- a/modules/casiowin/fxlib/docs/index.en.md
+++ b/modules/casiowin/fxlib/docs/index.en.md
@@ -33,7 +33,7 @@ CASIOWIN block at the beginning of the OS (at <flash> + 0x10070).
Here's a syscall example using the GNU assembler syntax:
-{% highlight gnu-asm %}
+```gnu-asm
.section .text
.global _sys_call
.type _sys_call, @function
@@ -45,4 +45,4 @@ _sys_call:
nop ; delayed branch
1: .long 0x80010070
2: .long <syscall no.>
-{% endhighlight %}
+```
diff --git a/modules/casiowin/fxlib/docs/keys.en.md b/modules/casiowin/fxlib/docs/keys.en.md
index 88f88d4..9b53f70 100644
--- a/modules/casiowin/fxlib/docs/keys.en.md
+++ b/modules/casiowin/fxlib/docs/keys.en.md
@@ -17,11 +17,11 @@ There is a first count (how long before the first repetition occurs),
and a next count (how long between repetitions).
Here are the function to manage these intervals:
-{% highlight c %}
+```c
void Bkey_Set_RepeatTime_Default(void);
void Bkey_Set_RepeatTime(long first_count, long next_count);
void Bkey_Get_RepeatTime(long *first_count, long *next_count);
-{% endhighlight %}
+```
The delays are in milliseconds divided by 25 (basically, the count of
40 milliseconds spans). Notice that this will **only** work with
@@ -33,9 +33,9 @@ are 500 milliseconds for the first count and 125 between repetitions.
# Get pressed keys
The main function to get a key is the following:
-{% highlight c %}
+```c
int GetKey(unsigned int *keycode);
-{% endhighlight %}
+```
This function is blocking (waits for a key press event to happen). The 'menu'
key is processed by the system (to return to the menu), as the power off
@@ -49,9 +49,9 @@ still the proper way of doing it.
For a greater control over gathering keyboard events, you should use the
following function:
-{% highlight c %}
+```c
int GetKeyWait(int sel, int time, int menu, unsigned int *keycode);
-{% endhighlight %}
+```
The `sel` parameter is the type of waiting. Their behaviour change when
there is no new event in the key event buffer:
@@ -78,10 +78,10 @@ The function returns one of these three event codes:
If you simply want to check if a key is pressed/released, you can use one
of these two functions:
-{% highlight c %}
+```c
int IsKeyDown(int keycode);
int IsKeyUp(int keycode);
-{% endhighlight %}
+```
`IsKeyDown()` returns 1 if the key is pressed, and 0 if it is not the case.
`IsKeyUp()` returns 1 if the key is released, and 0 if it is not the case.
diff --git a/modules/casiowin/fxlib/docs/timer.en.md b/modules/casiowin/fxlib/docs/timer.en.md
index 781398c..01805a7 100644
--- a/modules/casiowin/fxlib/docs/timer.en.md
+++ b/modules/casiowin/fxlib/docs/timer.en.md
@@ -7,9 +7,9 @@ timers, which allow you to run tasks in a parallel fashion to the main thread.
# Setting up a timer
In order to set up a timer, you will need to use the following function:
-{% highlight c %}
+```c
int SetTimer(int id, int elapse, void (*handler)(void));
-{% endhighlight %}
+```
The ID is the timer identifier. You have access to five user timers:
`ID_USER_TIMER1`, `ID_USER_TIMER2`, `ID_USER_TIMER3`, `ID_USER_TIMER4` and
@@ -25,6 +25,6 @@ use or the parameter is illegal. Otherwise, the timer identifier is returned.
You've had enough of your auxiliar threads? Then just kill your timer
using the following function:
-{% highlight c %}
+```c
int KillTimer(int id);
-{% endhighlight %}
+```
diff --git a/modules/casiowin/info.yml b/modules/casiowin/info.yml
index 5971fab..52cc914 100644
--- a/modules/casiowin/info.yml
+++ b/modules/casiowin/info.yml
@@ -2,18 +2,18 @@
---
magic: potatosdk-1.0
description: >-
- The OS on CASIO's fx-9860G series calculators, from 2005 to nowadays'
- monochrome calculators.
+ The OS on CASIO's fx-9860G series calculators, from 2005 to nowadays'
+ monochrome calculators.
abi:
- g1a
default:
- c:
- - casiowin/core
- - casiowin/core-crt
- - all/errno-renesas
+ c:
+ - casiowin/core
+ - casiowin/core-crt
+ - all/errno-renesas
import:
- all
requires:
- arch:
- - [sh3, big]
- - [sh4a, big]
+ arch:
+ - [sh3, big]
+ - [sh4a, big]
diff --git a/modules/casiowin/monochromelib/docs/screen.en.md b/modules/casiowin/monochromelib/docs/screen.en.md
index 961f8dd..aeb1df6 100644
--- a/modules/casiowin/monochromelib/docs/screen.en.md
+++ b/modules/casiowin/monochromelib/docs/screen.en.md
@@ -10,25 +10,25 @@ with the screen in the MonochromeLib.
Once the VRAM is ready to be displayed (see [VRAM interactions](vram) for more
explanations), use the following function to update the screen using the VRAM:
-{% highlight c linenos %}
+```c
void ML_display_vram(void);
-{% endhighlight %}
+```
### Clear the screen
If you want to clear the screen but not the VRAM, although it isn't
recommended, you can use the following function:
-{% highlight c %}
+```c
void ML_clear_screen(void);
-{% endhighlight %}
+```
### Set and get the screen contrast
You can set the contrast using these two functions:
-{% highlight c linenos %}
+```c
void ML_set_contrast(unsigned char contrast);
unsigned char ML_get_contrast(void);
-{% endhighlight %}
+```
The contrast is a value between `ML_CONTRAST_MIN` and `ML_CONTRAST_MAX`,
ideally `ML_CONTRAST_NORMAL`.
diff --git a/modules/casiowin/monochromelib/docs/vram.en.md b/modules/casiowin/monochromelib/docs/vram.en.md
index 554cb72..a44f1b6 100644
--- a/modules/casiowin/monochromelib/docs/vram.en.md
+++ b/modules/casiowin/monochromelib/docs/vram.en.md
@@ -21,9 +21,9 @@ As the VRAM address can vary, it is **imperative** that you use this function
if you ought to interact with the VRAM directly, instead of hardcoding the
address, which lead many add-ins to compatibility problems.
-{% highlight c %}
+```c
char *ML_vram_address();
-{% endhighlight %}
+```
The `char*` return type is used for compatibility. As you might want to use
bitwise operations, it is recommended to cast the return value as
@@ -33,7 +33,7 @@ for example, using `-funsigned-char` on GCC.
### Colors
MonochromeLib defines the following set of colors and meta-colors:
-{% highlight c %}
+```c
typedef enum {
ML_TRANSPARENT = -1,
ML_WHITE,
@@ -41,7 +41,7 @@ typedef enum {
ML_XOR,
ML_CHECKER
} ML_Color
-{% endhighlight %}
+```
`ML_BLACK` and `ML_WHITE` correspond to the 'raw' colors, `ML_XOR` changes the
color of every affected pixel, and `ML_CHECKER` makes a "checkerboard" color,
@@ -54,10 +54,10 @@ If you don't want to interact with the VRAM directly, you can use these
simple functions to set and get the status of a pixel in the VRAM using
these functions:
-{% highlight c %}
+```c
void ML_pixel(int x, int y, ML_Color color);
ML_Color ML_pixel_test(int x, int y);
-{% endhighlight %}
+```
All of the [drawing functions](draw) can be done using these functions,
although the library functions interact directly with the VRAM, so they
@@ -67,6 +67,6 @@ are quicker and should be used if possible.
If you want to have an empty VRAM to redraw it, you can use the following
function:
-{% highlight c %}
+```c
void ML_clear_vram(void);
-{% endhighlight %}
+```
diff --git a/modules/compiler/target-gcc-sh/bits/smachine.h b/modules/compiler/host-gcc-sh/bits/smachine.h
index 3def798..74b794b 100644
--- a/modules/compiler/target-gcc-sh/bits/smachine.h
+++ b/modules/compiler/host-gcc-sh/bits/smachine.h
@@ -40,8 +40,8 @@ static inline void __set_ssr(__uint32_t __ssr) {
#endif
/* Vector base register management.
- * The vector base is the address from which is calculated the addresses of the
- * interrupt, exception and MMU exception handlers. */
+ * The vector base is the address from which is calculated the addresses of
+ * the interrupt, exception and MMU exception handlers. */
#if __NDIC_VBR
#elif __GNUC_ASM
diff --git a/modules/compiler/target-gcc-sh/bits/umachine.h b/modules/compiler/host-gcc-sh/bits/umachine.h
index 5bf972f..d6fecff 100644
--- a/modules/compiler/target-gcc-sh/bits/umachine.h
+++ b/modules/compiler/host-gcc-sh/bits/umachine.h
@@ -447,7 +447,7 @@ _LOCAL _ASM_INLINE __uint32_t __swapw(__uint32_t __data) {
/* Here are some other macros that seem to use the last ones...? */
#define end_cnvw(_RM) swapb(_RM)
-#define end_cnvl(_DATA) swapw(_DATA) /* _builtin_end_cnvl(data)? */
+#define end_cnvl(_DATA) swapw(_DATA) /* XXX: _builtin_end_cnvl(data)? */
/* Double-length Multiply as Signed.
* Performs 32-bit multiplication of two operands, and stores the 64-bit
diff --git a/modules/compiler/host-gcc-sh/info.yml b/modules/compiler/host-gcc-sh/info.yml
index 2d4084c..59827c6 100644
--- a/modules/compiler/host-gcc-sh/info.yml
+++ b/modules/compiler/host-gcc-sh/info.yml
@@ -4,6 +4,6 @@ magic: potatosdk-1.0
description: Host compiler bits for GCC for the SuperH architecture.
license: free
requires:
- host-compiler:
- - ['GNU', 'GCC']
- arch: [sh]
+ host-compiler:
+ - ['GNU', 'GCC']
+ arch: [sh]
diff --git a/modules/compiler/host-gcc/info.yml b/modules/compiler/host-gcc/info.yml
index 8b167ae..2247150 100644
--- a/modules/compiler/host-gcc/info.yml
+++ b/modules/compiler/host-gcc/info.yml
@@ -4,5 +4,5 @@ magic: potatosdk-1.0
description: Host compiler bits for GCC.
license: free
requires:
- host-compiler:
- - ['GNU', 'GCC']
+ host-compiler:
+ - ['GNU', 'GCC']
diff --git a/modules/compiler/host-renesas/bits/stdarg.h b/modules/compiler/host-renesas/bits/stdarg.h
index 078334e..b11f18e 100644
--- a/modules/compiler/host-renesas/bits/stdarg.h
+++ b/modules/compiler/host-renesas/bits/stdarg.h
@@ -3,22 +3,23 @@ typedef char* va_list;
/* (get the 4-aligned address) */
#define __va_ceil(_ADDR) \
- (va_list)(((__uintptr_t)(_ADDR) & ~3) + ((__uintptr_t)(_ADDR) & 3) ? 4 : 0)
+ (va_list)(((uintptr_t)(_ADDR) & ~3) + ((uintptr_t)(_ADDR) & 3) ? 4 : 0)
#define __va_floor(_ADDR) \
- (va_list)((__uintptr_t)(_ADDR) & ~3)
+ (va_list) ((uintptr_t)(_ADDR) & ~3)
/* Open and close a variable argument list. */
-#define _va_start(_AP, _PARAM) \
+#define va_start(_AP, _PARAM) \
(void)(_AP = __va_ceil((char*)&_PARAM + sizeof(_PARAM)))
-#define va_end(_AP) (void)(_AP = NULL)
+#define va_end(_AP) \
+ (void)(_AP = NULL)
/* Obtain an argument from the variable argument list. */
#define va_arg(_AP, _TYPE) \
- (*(_TYPE*)(_AP = __va_ceil(_AP + sizeof(_TYPE)), \
- __va_floor(_AP - sizeof(_TYPE))))
+ (*(_TYPE*)__va_floor((_AP = __va_ceil(_AP + sizeof(_TYPE))) \
+ - sizeof(_TYPE)))
/* Copy a variable argument list. */
-#define va_copy(_D, _S) { _D = _S }
+#define __va_copy(_D, _S) { _D = _S }
diff --git a/modules/compiler/host-renesas/info.yml b/modules/compiler/host-renesas/info.yml
index 81b6667..8113c4b 100644
--- a/modules/compiler/host-renesas/info.yml
+++ b/modules/compiler/host-renesas/info.yml
@@ -4,6 +4,6 @@ magic: potatosdk-1.0
description: Host compiler bits for SHC.
license: free
requires:
- host-compiler:
- - ['Hitachi', 'SHC']
- - ['Renesas', 'SHC']
+ host-compiler:
+ - ['Hitachi', 'SHC']
+ - ['Renesas', 'SHC']
diff --git a/modules/compiler/info.yml b/modules/compiler/info.yml
index e4c2579..78ce1f4 100644
--- a/modules/compiler/info.yml
+++ b/modules/compiler/info.yml
@@ -2,10 +2,10 @@
---
magic: potatosdk-1.0
description: >-
- Meta-system for modules that are compiler-dependant.
+ Meta-system for modules that are compiler-dependant.
default:
- c:
- - compiler/host-gcc
- - compiler/host-renesas
- - compiler/target-gcc-sh
- - compiler/target-renesas
+ c:
+ - compiler/host-gcc
+ - compiler/host-renesas
+ - compiler/target-gcc-sh
+ - compiler/target-renesas
diff --git a/modules/compiler/target-gcc-sh/copyright.yml b/modules/compiler/target-gcc-sh/copyright.yml
deleted file mode 100644
index 94e925f..0000000
--- a/modules/compiler/target-gcc-sh/copyright.yml
+++ /dev/null
@@ -1,5 +0,0 @@
-%YAML 1.2
----
-files: '*'
-copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
diff --git a/modules/compiler/target-gcc-sh/info.yml b/modules/compiler/target-gcc-sh/info.yml
deleted file mode 100644
index 38df5e7..0000000
--- a/modules/compiler/target-gcc-sh/info.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-%YAML 1.2
----
-magic: potatosdk-1.0
-description: Target compiler bits for GCC with a SuperH target.
-license: free
-requires:
- compiler:
- - ['GNU', 'GCC']
- arch: [sh]
diff --git a/modules/compiler/target-gcc-sh/roles.yml b/modules/compiler/target-gcc-sh/roles.yml
deleted file mode 100644
index f143f99..0000000
--- a/modules/compiler/target-gcc-sh/roles.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-%YAML 1.2
----
-
diff --git a/modules/compiler/target-renesas/info.yml b/modules/compiler/target-renesas/info.yml
index fc26ee9..2e47754 100644
--- a/modules/compiler/target-renesas/info.yml
+++ b/modules/compiler/target-renesas/info.yml
@@ -4,6 +4,6 @@ magic: potatosdk-1.0
description: Target compiler bits for SHC.
license: free
requires:
- compiler:
- - ['Hitachi', 'SHC']
- - ['Renesas', 'SHC']
+ compiler:
+ - ['Hitachi', 'SHC']
+ - ['Renesas', 'SHC']
diff --git a/modules/info.yml b/project.yml
index 48c475f..5ac1482 100644
--- a/modules/info.yml
+++ b/project.yml
@@ -1,8 +1,13 @@
%YAML 1.2
---
magic: potatosdk-1.0
+maintainer: [Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
version:
major: 0
minor: 1
indev: true
-maintainer: [Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+locations:
+ docroot: docs
+ modules: modules
+ config: .config.yml
+ build: build
diff --git a/tools/Internals/__init__.py b/tools/Internals/__init__.py
index 265c445..da93167 100755
--- a/tools/Internals/__init__.py
+++ b/tools/Internals/__init__.py
@@ -7,7 +7,7 @@ from .copyright import *
from .gettext import *
from .arch import *
-from .module import *
+from .project import *
from .config import *
from .topc import *
from .cache import *
diff --git a/tools/Internals/build/__init__.py b/tools/Internals/build/__init__.py
index 7d0d529..7921baf 100755
--- a/tools/Internals/build/__init__.py
+++ b/tools/Internals/build/__init__.py
@@ -8,6 +8,10 @@ from subprocess import call
from ..exceptions import *
+# ---
+# Get and list the tools.
+# ---
+
from .gnu_gcc import *
from .gnu_as import *
from .gnu_ar import *
@@ -16,26 +20,42 @@ from .gnu_ar import *
#from .renesas_optlnk import *
_tools = {
- ('GNU', 'GCC'): GNU_GCC,
- ('GNU', 'as'): GNU_AS,
- ('GNU', 'ar'): GNU_AR,
-# ('LLVM', 'Clang'): LLVM_Clang,
-# ('Renesas', 'SHC'): Renesas_SHC,
-# ('Hitachi', 'SHC'): Renesas_SHC,
-# ('Renesas', 'Asmsh'): Renesas_Asmsh,
-# ('Hitachi', 'Asmsh'): Renesas_Asmsh,
-# ('Renesas', 'Optlnk'): Renesas_OptLnk,
-# ('Hitachi', 'Optlnk'): Renesas_OptLnk,
-# ('Intel', 'ICC'): Intel_ICC,
-# ('IBM', 'XL C/C++'): IBM_XLC,
-# ('SDCC', 'SDCC'): SDCC_SDCC,
-# ('Borland', 'Turbo C'): Borland_TurboC,
-# ('Borland', 'Turbo C++'): Borland_TurboCpp
+ ('GNU', 'GCC'): GNU_GCC,
+ ('GNU', 'as'): GNU_AS,
+ ('GNU', 'ar'): GNU_AR,
+# ('LLVM', 'Clang'): LLVM_Clang,
+# ('Renesas', 'SHC'): Renesas_SHC,
+# ('Hitachi', 'SHC'): Renesas_SHC,
+# ('Renesas', 'Asmsh'): Renesas_Asmsh,
+# ('Hitachi', 'Asmsh'): Renesas_Asmsh,
+# ('Renesas', 'Optlnk'): Renesas_OptLnk,
+# ('Hitachi', 'Optlnk'): Renesas_OptLnk,
+# ('Intel', 'ICC'): Intel_ICC,
+# ('IBM', 'XL C'): IBM_XLC,
+# ('IBM', 'XL C/C++'): IBM_XLC,
+# ('SDCC', 'SDCC'): SDCC_SDCC,
+# ('Borland', 'Turbo C'): Borland_TurboC,
+# ('Borland', 'Turbo C++'): Borland_TurboCpp,
+# ('Bellard', 'TCC'): Bellard_TCC,
+# ('Lifeboat', 'Lattice C'): SAS_C,
+# ('SAS', 'SAS/C'): SAS_C,
+# ('Bell Labs', '0c'): Plan9_CC, -- little-endian MIPS 3000 family
+# ('Bell Labs', 'vc'): Plan9_CC, -- big-endian MIPS 3000 family
+# ('Bell Labs', '1c'): Plan9_CC, -- Motorola MC68000
+# ('Bell Labs', '2c'): Plan9_CC, -- Motorola MC68020
+# ('Bell Labs', '5c'): Plan9_CC, -- little-endian ARM
+# ('Bell Labs', '6c'): Plan9_CC, -- AMD64 and compatibles
+# ('Bell Labs', '7c'): Plan9_CC, -- Digital Alpha APX
+# ('Bell Labs', '8c'): Plan9_CC, -- Intel i386, i486, Pentium, etc.
+# ('Bell Labs', '9c'): Plan9_CC, -- 64-bit PowerPC
+# ('Bell Labs', 'kc'): Plan9_CC, -- Sun (now Oracle) SPARC
+# ('Bell Labs', 'qc'): Plan9_CC, -- PowerPC
}
-#*****************************************************************************#
-# Find the utilities #
-#*****************************************************************************#
+# ---
+# Find the utilities.
+# ---
+
def _find_cc(arch, endian, system, flavour, standard):
""" Find a C compiler. """
@@ -120,8 +140,13 @@ def _find_bin(arch, endian, system, flavour, abi):
Raise(NoBinException)
+# ---
# Iterate on operations.
+# ---
+
def get_build_operations(build_dir, modules):
+ """ Iterate on the operations to do. """
+
__cxx_ext = ['cpp', 'CPP', 'cc', 'CC', 'cp', 'CP', 'cxx', 'CXX',
'c++', 'C++']
@@ -142,6 +167,7 @@ def get_build_operations(build_dir, modules):
if objmtime < srcmtime:
yield ('cc', module, source)
+
for source in module.getfiles('src', __cxx_ext):
srcpath = module.getpath('src', source)
objpath = os.path.join(modbdir, '{}.o'.format(source))
@@ -170,15 +196,19 @@ def get_build_operations(build_dir, modules):
if objmtime < srcmtime:
yield ('asm', module, source)
-#*****************************************************************************#
-# Interact with the tools before using them. #
-#*****************************************************************************#
+ # TODO: linking operation
+
+# ---
+# Interact with the tools before using them.
+# ---
+
# The tools.
_current_tools = {}
__compiler = '(none)'
-# Find tools.
def find(languages, arch, endian, system, abi, flavour):
+ """ Find tools. """
+
ids, params = {}, {}
ids['cc'], params['cc'] = \
@@ -196,8 +226,9 @@ def find(languages, arch, endian, system, abi, flavour):
return {'ids': ids, 'params': params}
-# Setup the tools.
def setup(data):
+ """ Setup the tools. """
+
global _current_tools, __compiler
ids = data['ids']
@@ -240,8 +271,9 @@ def setup(data):
_current_tools['bin'] = \
ft.partial(_tools[bing]['bin'], binp)
-# Get an information.
def get(key):
+ """ Get an information. """
+
cpp_ext = ['cpp', 'CPP', 'cc', 'CC', 'cp', 'CP', 'cxx', 'CXX',
'c++', 'C++']
@@ -257,32 +289,38 @@ def get(key):
'cpp_ext': cpp_ext,
'asm_ext': ['s', 'S'],
}[key]
-#*****************************************************************************#
-# Build things. #
-#*****************************************************************************#
-# Compile C things.
+
+# ---
+# Build things.
+# ---
+
def cc(obj, src, incdirs=[], std='c89'):
+ """ Make an object out of a C source file. """
+
if not 'cc' in _current_tools:
print("No C compiler has been setup!")
Raise(SilentException)
return _current_tools['cc'](obj, src, incdirs, std)
-# Compile C++ things.
def cxx(obj, src, incdirs=[], std='c++98'):
+ """ Make an object out of a C++ source file. """
+
if not 'cxx' in _current_tools:
print("No C++ compiler has been setup!")
Raise(SilentException)
return _current_tools['cxx'](obj, src, indirs, std)
-# Compile ASM things.
def asm(obj, src):
+ """ Make an object out of an assembly source file. """
+
if not 'asm' in _current_tools:
print("No assembler has been setup!")
Raise(SilentException)
return _current_tools['asm'](obj, src)
-# Pack things up into a library.
def pack(lib, objs):
+ """ Pack objects in a library. """
+
if not 'pack' in _current_tools:
print("No packer has been setup!")
Raise(SilentException)
diff --git a/tools/Internals/build/gnu_as.py b/tools/Internals/build/gnu_as.py
index ff2d69d..265616f 100755
--- a/tools/Internals/build/gnu_as.py
+++ b/tools/Internals/build/gnu_as.py
@@ -74,9 +74,11 @@ def _configure(arch, endian, system, flavour, syntax):
flags += ['--isa=' + arch, '--big']
return {'path': path, 'flags': flags}
-#*****************************************************************************#
-# Usage #
-#*****************************************************************************#
+
+# ---
+# Usage.
+# ---
+
def _asm(params, obj, src):
""" Assemble using the GNU assembler. """
@@ -88,9 +90,10 @@ def _asm(params, obj, src):
# Make the call.
return call(commandline)
-#*****************************************************************************#
-# Main utility descriptor #
-#*****************************************************************************#
+# ---
+# Main utility descriptor.
+# ---
+
GNU_AS = {
'conf_asm': _configure,
'asm': _asm
diff --git a/tools/Internals/build/gnu_gcc.py b/tools/Internals/build/gnu_gcc.py
index 7e2432e..10db87e 100755
--- a/tools/Internals/build/gnu_gcc.py
+++ b/tools/Internals/build/gnu_gcc.py
@@ -20,9 +20,10 @@ from .utils import *
__all__ = ["GNU_GCC"]
-#*****************************************************************************#
-# Discovery, configuration #
-#*****************************************************************************#
+# ---
+# Discovery, configuration.
+# ---
+
def __get_gcc_bfd(path):
""" Get the BFD target out of the gcc binary path. """
@@ -121,9 +122,11 @@ def _configure_cc(arch, endian, system, flavour, standard):
def _configure_cxx(arch, endian, system, flavour, standard):
return _configure('cxx', arch, endian, system, flavour, standard)
-#*****************************************************************************#
-# Use the parameters #
-#*****************************************************************************#
+
+# ---
+# Use the parameters.
+# ---
+
def _makeenv(incdirs):
incpath = os.pathsep.join(incdirs)
env = os.environ.copy()
@@ -152,9 +155,10 @@ def _cxx(params, obj, src, incdirs, std):
# Make the call.
return call(commandline, env=_makeenv(incdirs))
-#*****************************************************************************#
-# Main utility descriptor #
-#*****************************************************************************#
+# ---
+# Main utility descriptor.
+# ---
+
GNU_GCC = {
'conf_cc': _configure_cc,
'conf_cxx': _configure_cxx,
diff --git a/tools/Internals/build/renesas_asmsh.py b/tools/Internals/build/renesas_asmsh.py
index f9ec5bf..af68c09 100755
--- a/tools/Internals/build/renesas_asmsh.py
+++ b/tools/Internals/build/renesas_asmsh.py
@@ -12,9 +12,10 @@ from .utils import *
__all__ = ["Renesas_Asmsh"]
-#*****************************************************************************#
-# Discovery, configuration #
-#*****************************************************************************#
+# ---
+# Discovery, configuration.
+# ---
+
def _configure(arch, endian, obj_format, std):
''' Get the parameters. '''
@@ -34,9 +35,10 @@ def _configure(arch, endian, obj_format, std):
return {'path': asmsh, 'CPU': CPU, 'flags': flags}
-#*****************************************************************************#
-# Usage #
-#*****************************************************************************#
+# ---
+# Usage.
+# ---
+
def _asm(self, obj, src, incdirs):
''' Assemble a source assembly file. '''
@@ -75,9 +77,10 @@ def _asm(self, obj, src, incdirs):
os.rename(tmpobj, obj)
return ret
-#*****************************************************************************#
-# Main utility descriptor #
-#*****************************************************************************#
+# ---
+# Main utility descriptor.
+# ---
+
Renesas_Asmsh = {
'conf_asm': _configure,
'asm': _asm
diff --git a/tools/Internals/build/renesas_shc.py b/tools/Internals/build/renesas_shc.py
index 51ee149..223802a 100755
--- a/tools/Internals/build/renesas_shc.py
+++ b/tools/Internals/build/renesas_shc.py
@@ -10,14 +10,15 @@
"""
import os
-from subprocess import call
+from subprocess import call as _call
from .utils import *
__all__ = ["Renesas_SHC"]
-#*****************************************************************************#
-# Discovery, configuration #
-#*****************************************************************************#
+# ---
+# Discovery, configuration.
+# ---
+
def _configure(typ, arch, endian, objfmt, std):
""" Get the parameters. """
@@ -43,9 +44,11 @@ def _configure_cc(args):
return _configure('c', *args)
def _configure_cxx(args):
return _configure('cxx', *args)
-#*****************************************************************************#
-# Usage #
-#*****************************************************************************#
+
+# ---
+# Usage.
+# ---
+
def _cc(params, obj, src, incdirs, std):
""" Compile a C source file into an object file. """
@@ -99,9 +102,10 @@ def _cxx(self, obj, src, incdirs=[]):
os.remove(tmpinfo[1])
return ret
-#*****************************************************************************#
-# Main utility descriptor #
-#*****************************************************************************#
+# ---
+# Main utility descriptor.
+# ---
+
Renesas_SHC = {
'conf_cc': _configure_cc,
'conf_cxx': _configure_cxx,
diff --git a/tools/Internals/build/utils/bfd.py b/tools/Internals/build/utils/bfd.py
index 62dbf08..ddb623f 100755
--- a/tools/Internals/build/utils/bfd.py
+++ b/tools/Internals/build/utils/bfd.py
@@ -23,9 +23,10 @@ import itertools as _itertools
from ...exceptions import *
from ...arch import get_arch_detail
-#*****************************************************************************#
-# Reference #
-#*****************************************************************************#
+# ---
+# Reference.
+# ---
+
# Known BFD Instruction Set Architectures (ISA).
#
# The correspondances make BFD architecture names correspond to a
@@ -90,9 +91,11 @@ _flavours = {
# 'plugin', 'srec', 'symbolsrec', 'verilog', 'tekhex', 'binary', 'ihex'
}
-#*****************************************************************************#
-# Prepare and check BFD targets #
-#*****************************************************************************#
+
+# ---
+# Prepare and check BFD targets.
+# ---
+
def prepare_bfd(arch, endian, system, flavour):
""" Make a list of BFDs that could correspond to the
given configuration. """
@@ -125,9 +128,10 @@ def check_bfd(bfds, raw):
return raw in bfds
-#*****************************************************************************#
-# Prepare and check AR targets #
-#*****************************************************************************#
+# ---
+# Prepare and check AR targets.
+# ---
+
def prepare_ar(arch, endian, system, flavour):
""" Make a list of GNU ar targets that could correspond to the given
configuration. """
diff --git a/tools/Internals/build/utils/formats.py b/tools/Internals/build/utils/formats.py
index b39dca3..3162f18 100755
--- a/tools/Internals/build/utils/formats.py
+++ b/tools/Internals/build/utils/formats.py
@@ -5,8 +5,11 @@
# This file contains the list of formats these tools can use/produce,
# with their extensions.
+
# ---
# Archive formats.
+# ---
+
__archive_formats = {
# Proprietary lib format used by Hitachi's tools.
'hlib': ['rlib', 'lib'],
@@ -16,7 +19,10 @@ __archive_formats = {
'a.out': ['a']
}
+# ---
# Object formats.
+# ---
+
__object_formats = {
'pe': ['obj'],
'elf': ['o', 'obj', 'robj'],
diff --git a/tools/Internals/cache.py b/tools/Internals/cache.py
index 35baa7f..18e4f6f 100755
--- a/tools/Internals/cache.py
+++ b/tools/Internals/cache.py
@@ -40,11 +40,16 @@ class CacheManager:
raise Exception("[INT] Cache setting argument should be a dict")
self.__categories[name] = _copy.deepcopy(cache)
- def __del__(self):
- """ Don't forget to save it. """
+ def save(self):
+ """ Save the cache. """
with open(self.__path, 'w') as out:
print(_yaml.dump(self.__categories,
version=(1, 2), width=60), file=out, end='')
+ def __del__(self):
+ """ Don't forget to save it. """
+
+ self.save()
+
# End of file.
diff --git a/tools/Internals/config.py b/tools/Internals/config.py
index 6986fe9..8752b11 100644..100755
--- a/tools/Internals/config.py
+++ b/tools/Internals/config.py
@@ -11,29 +11,29 @@ __all__ = ["UserConfig"]
class UserConfig:
""" The user configuration class.
Extracts data from the file, and offer utilities to interact
- with its elements easily.
- """
+ with its elements easily. """
- def __init__(self, path):
- """ Initialize the class, gather the information from the
- configuration, and deduce properties out of it.
-
- `path` is the user configuration file path.
- """
+ def __init__(self, path = None, orig = None):
+ """ Initialize the class.
+ `path` is the user configuration file path. """
+
+ self.path = path
+ self.orig = orig
+
+ def load(self):
+ """ Gather the information from the configuration,
+ and deduce properties out of it. """
# Load the configuration.
try:
- raw = yaml.load(open(path))
+ raw = yaml.load(open(self.path))
except (NotADirectoryError, FileNotFoundError):
- Raise(ConfigNotFoundException(path))
+ Raise(ConfigNotFoundException(self.path))
# Check the magic.
- if 'magic' in raw and raw['magic'] !='potatosdk-1.0':
+ if 'magic' in raw and raw['magic'] != 'potatosdk-1.0':
Raise(ConfigNotFoundException(path))
- # Keep the arguments.
- self.path = path
-
# Modules.
self.modules = []
if 'modules' in raw:
@@ -44,15 +44,23 @@ class UserConfig:
if 'tools' in raw:
self.tools = raw['tools']
- def write(self, out, orig=None):
- """ Write the configuration as a YAML file to an output. """
+ def write(self):
+ """ Write the configuration as a YAML file. """
- # XXX: TODO
-
- raw = {
- 'magic': 'potatosdk-1.0',
- 'modules': self.modules,
- 'orig': orig
+ config = {
+ 'magic': 'potatosdk-1.0',
+ 'paths': {
+ 'source': self.source,
+ 'cache': self.cache,
+ 'build': self.build,
+ },
+ 'tools': self.tools,
+ 'modules': modules,
+ 'orig': self.orig
}
+ with open(self.path, "w") as out:
+ print(yaml.dump(config, version=(1, 2), width=60),
+ file=out, end='')
+
# End of file.
diff --git a/tools/Internals/module.py b/tools/Internals/module.py
index a435524..8d56fff 100755
--- a/tools/Internals/module.py
+++ b/tools/Internals/module.py
@@ -58,7 +58,8 @@ class ModuleName:
def __init__(self, *params):
if len(params) == 1:
- self.platform, self.module = params[0].split('/')
+ *self.platform, self.module = params[0].split('/')
+ self.platform = '/'.join(self.platform)
elif len(params) == 2:
self.platform, self.module = params
else:
@@ -279,197 +280,4 @@ class SourceSystem:
modules[name] = module
return modules
-class SourceGlobal:
- """ The global source class.
- Extracts data from the filesystem. """
-
- def __init__(self, root, mtim = None, rules = []):
- """ Initialize the class, gather the information about the source,
- and deduce properties out of it.
-
- `root` is the modules root (generally `./modules`).
- `mtim` is the reference modification time for the user config.
- """
-
- # Open the global configuration.
- gconfigpath = os.path.join(root, 'info.yml')
- try:
- gconfig = yaml.load(open(gconfigpath))
- except (NotADirectoryError, FileNotFoundError):
- Raise(GlobalNotFoundException)
-
- # Check the difference to the reference time.
- if mtim != None:
- if os.path.getmtime(gconfigpath) > mtim:
- Raise(UpdatedGlobalException)
-
- # Check the magic.
- if 'magic' in gconfig and gconfig['magic'] != 'potatosdk-1.0':
- Raise(GlobalNotFoundException)
-
- # Keep the arguments.
- self.__root = root
- self.__mtim = mtim
- self.__rules = rules
-
- # Get the properties.
- self.maintainer = SourceMaintainer(gconfig['maintainer'])
- self.version = SourceVersion(gconfig['version'])
-
- # Loaded systems.
- self.__loaded = {}
-
- def getsystem(self, name):
- """ Get a system using its name, e.g. "casiowin". """
-
- if name in self.__loaded:
- return self.__loaded[name]
-
- system = SourceSystem(os.path.join(self.__root, name),
- name, self, self.__mtim, self.__rules)
- self.__loaded[name] = system
- return system
-
- def getallsystems(self):
- """ Get all of the existing systems. """
-
- systems = {}
- for name in os.listdir(self.__root):
- try: system = self.getsystem(name)
- except SystemNotFoundException: continue
- systems[name] = system
- return systems
-
- def getmodule(self, name):
- """ Get a module. """
-
- system = self.getsystem(name.system)
- return system.getmodule(name.module)
-
- def getmodules(self, names):
- """ Get a list of modules. """
-
- modules = {}
- for name in names:
- modules[name] = self.getmodule(ModuleName(name))
- return modules
-
- def getallmodules(self):
- """ Get all of the existing modules. """
-
- modules = {}
- for system_name, system in self.getallsystems().items():
- for module_name, module in system.getallmodules().items():
- nm = ModuleName(system_name, module_name)
- modules[str(nm)] = module
- return modules
-
- def findmodules(self, arch, endian, system = None,
- compiler = ('GNU', 'GCC'), hcompiler = ('GNU', 'GCC'),
- languages = ['c', 'c++'], addition = []):
- """ Find modules corresponding to a query, based on:
- - `arch`: the architecture for which to build;
- - `system`: the system for which to build;
- - `compiler`: the C/C++ compiler for which to build;
- - `hcompiler`: the C/C++ compiler with which to build;
- - `languages`: the programming languages for which to
- offer support;
- - `addition`: the additional modules to include. """
-
- modules = {}
-
- # In 'hand-written' information files, the user ain't using the
- # '!!python/tuple' trick, so we're just going to use a list instead
- # of a tuple.
- compiler = list(compiler)
-
- # Get the language defaults for the systems.
- # 'ds' means 'default systems', 'ls' means 'loaded systems',
- # 'sn' means 'system name'.
- default = {'c': [], 'c++': []}
- ds = [system]
- ls = []
- while ds:
- sn = ds.pop(0)
- if sn in ls:
- continue
- ls.append(sn)
-
- sys = self.getsystem(sn)
- ds.extend(sys.deps)
- if sys.arch and not (arch, endian) in sys.arch:
- Raise(UnsupportedArchForSystemException(arch, endian, sn))
- if 'c' in sys.defaults:
- default['c'] += sys.defaults['c']
- default['c++'] += sys.defaults['c']
- if 'c++' in sys.defaults:
- default['c++'] += sys.defaults['c++']
-
- # Gather the additional modules.
- for name in set(addition):
- module = self.getmodule(name)
- if module.arch and all(not x in module.arch \
- for x in ((arch, endian), (arch, None))):
- Raise(UnsupportedArchForModuleException(name, arch))
- continue
- if module.compilers and not compiler in module.compilers:
- Raise(UnsupportedCompilerForModuleException(name, compiler))
- continue
- modules[name] = module
-
- # Gather the defaults for the languages.
- # 'dm' means 'default modules', 'ldm' means 'language default modules'.
- dm = []
- for ldm in map(lambda x:default[x], languages):
- dm.extend(ldm)
- for name in dm:
- module = self.getmodule(name)
- if module.arch and all(not x in module.arch \
- for x in ((arch, endian), (arch, None))):
- continue
- if module.compilers and not compiler in module.compilers:
- continue
- modules[name] = module
-
- # Gather the dependencies.
- # 'newdeps' is a list of tuples, where the first element of each tuple
- # is the name of the module to gather, and the second is modules from
- # which the dependency comes from (for logging).
- newdeps = []
- blacklist = []
- while True:
- # Get the previous dependencies.
- for dep in newdeps:
- name = dep[0]
- try:
- module = self.getmodule(name)
- except (SystemNotFoundException, ModuleNotFoundException):
- Raise(UnresolvedDependencyException(name, dep[1]))
- blacklist.append(name)
- continue
-
- if module.arch and not arch in module.arch:
- blacklist.append(name)
- elif module.compiler and not compiler in module.compiler:
- blacklist.append(name)
- else:
- modules[name] = module
- newdeps = []
-
- # Check the dependencies.
- for name, module in modules.items():
- for dep in module.deps:
- if not dep in modules and not dep in blacklist:
- try: ndep = next(i for i in newdeps if i[0] == dep)
- except: newdeps.append([dep, [name]])
- else: ndep[1].append(name)
-
- # No dependency? Good!
- if not newdeps:
- break
-
- # TODO: check conflicts.
- # We're done!
- return modules
-
# End of file.
diff --git a/tools/Internals/project.py b/tools/Internals/project.py
new file mode 100755
index 0000000..6e4a155
--- /dev/null
+++ b/tools/Internals/project.py
@@ -0,0 +1,320 @@
+#!/usr/bin/env python3
+""" The main project class.
+ Everything should be managed through this class.
+"""
+
+import os as _os, re as _re
+import fnmatch as _fnmatch, datetime as _datetime
+import yaml as _yaml
+
+from .module import *
+
+__all__ = ["Project"]
+
+class Project:
+ """ The project class.
+ Extracts data from the filesystem. """
+
+ def __init__(self, path, mtim = None):
+ """ Initialize the class, gather the information about the source,
+ and deduce properties out of it.
+
+ `path` is the project path (`project.yml` by default).
+ `mtim` is the reference modification time not to edit after.
+ """
+
+ # Open the configuration.
+
+ try:
+ cfg = _yaml.load(open(path))
+ except (FileNotFoundError,):
+ Raise(GlobalNotFoundException)
+
+ # Check the difference to the reference time.
+
+ if mtim != None:
+ if _os.path.getmtime(path) > mtim:
+ Raise(UpdatedGlobalException)
+
+ # Check the magic, get the properties.
+
+ if 'magic' in cfg and cfg['magic'] != 'potatosdk-1.0':
+ Raise(GlobalNotFoundException)
+
+ self.maintainer = SourceMaintainer(cfg['maintainer'])
+ self.version = SourceVersion(cfg['version'])
+
+ prefix = os.path.dirname(path)
+ self.__prefix = prefix
+ self.docroot = cfg['locations']['docroot']
+ self.modroot = cfg['locations']['modules']
+ self.config = cfg['locations']['config']
+ self.build = cfg['locations']['build']
+
+ # Keep the arguments.
+ self.__root = os.path.join(self.__prefix, self.modroot)
+ self.__mtim = mtim
+ self.__rules = None
+
+ # Loaded systems.
+ self.__loaded = {}
+
+ def __loadrules(self, root):
+ """ Load the copyright rules from the project root. """
+
+ root = _os.path.join(root, '')
+ rules = {}
+
+ # Copyright file thing.
+ for rt, _, _ in _os.walk(root):
+ # Ignore file.
+ try:
+ with open(_os.path.join(rt, '.gitignore')) as f:
+ rulz = []
+ for line in f.readlines():
+ # Get what's before the comment.
+ line = _re.sub('([^\\\\](\\\\\\\\)*)#.*$', '\\1', line)
+ line = _re.sub('\\\\(.*)', '\\1', line)
+ line = line.strip()
+
+ if line: rulz.append(line)
+
+ for l in rulz:
+ if l[0] == '/':
+ nm = l[1:].split('/')
+ bases = [_os.path.join(rt, *nm)]
+ else:
+ nm = l.split('/')
+ bases = [_os.path.join(rt, *nm),
+ _os.path.join(rt, '**', *nm)]
+
+ for base in bases:
+ rules[base] = '===IGNORED==='
+ except FileNotFoundError:
+ pass
+
+ # Copyright file.
+ try:
+ with open(_os.path.join(rt, 'copyright.yml')) as f:
+ d_rules = _yaml.load_all(f.read())
+
+ # Read each rule.
+ for rule in d_rules:
+ ml = rule['files']
+ if type(ml) != list:
+ ml = [ml]
+
+ l = rule['license'] if 'license' in rule else 'free'
+ authors = []
+ if 'copyright' in rule:
+ for author in rule['copyright']:
+ if len(author) == 3:
+ authors.append(((author[0], author[0]),
+ author[1], author[2]))
+ else:
+ authors.append(((author[0], author[1]),
+ author[2], author[3]))
+ if not authors:
+ authors.append(__default_maintainer)
+
+ for m in ml:
+ spl = m.split('/')
+ m = _os.path.join(rt, *spl)
+ rules[m] = {'authors': authors, 'license': l}
+ except FileNotFoundError:
+ pass
+
+ self.rules = rules
+
+ def getcopyright(self, path):
+ """ Get a copyright rule. """
+
+ if not self.__rules:
+ self.__loadrules(self.__prefix)
+
+ if not _os.path.isfile(path):
+ raise NotAFileException
+ if _os.path.basename(path) == 'copyright.yml':
+ raise IgnoredFileException
+
+ match = None
+
+ for rule in rules:
+ # Check if the rule matches the path.
+ if not __match(rule, path):
+ continue
+
+ # Check if it is the first thing.
+ if not match:
+ match = rule
+ continue
+
+ # If the current rule is more precise, take it instead.
+ # TODO: of course that length rule is stupid and doesn't take into
+ # account things such as "arch/**/info.yml is more precise than
+ # arch/mysystem/mymodule/*", but it's a quick hack.
+
+ if len(rule) > len(match):
+ match = rule
+
+ if not match:
+ raise NoCopyrightException
+ rule = rules[match]
+ if rule == '===IGNORED===':
+ raise IgnoredFileException
+ return (rule['authors'], rule['license'])
+
+ def getsystem(self, name):
+ """ Get a system using its name, e.g. "casiowin". """
+
+ if name in self.__loaded:
+ return self.__loaded[name]
+
+ system = SourceSystem(os.path.join(self.__root, name),
+ name, self, self.__mtim, self.__rules)
+ self.__loaded[name] = system
+ return system
+
+ def getallsystems(self):
+ """ Get all of the existing systems. """
+
+ systems = {}
+ for name in os.listdir(self.__root):
+ try: system = self.getsystem(name)
+ except SystemNotFoundException: continue
+ systems[name] = system
+ return systems
+
+ def getmodule(self, name):
+ """ Get a module. """
+
+ system = self.getsystem(name.system)
+ return system.getmodule(name.module)
+
+ def getmodules(self, names):
+ """ Get a list of modules. """
+
+ modules = {}
+ for name in names:
+ modules[name] = self.getmodule(ModuleName(name))
+ return modules
+
+ def getallmodules(self):
+ """ Get all of the existing modules. """
+
+ modules = {}
+ for system_name, system in self.getallsystems().items():
+ for module_name, module in system.getallmodules().items():
+ nm = ModuleName(system_name, module_name)
+ modules[str(nm)] = module
+ return modules
+
+ def findmodules(self, arch, endian, system = None,
+ compiler = ('GNU', 'GCC'), hcompiler = ('GNU', 'GCC'),
+ languages = ['c', 'c++'], addition = []):
+ """ Find modules corresponding to a query, based on:
+ - `arch`: the architecture for which to build;
+ - `system`: the system for which to build;
+ - `compiler`: the C/C++ compiler for which to build;
+ - `hcompiler`: the C/C++ compiler with which to build;
+ - `languages`: the programming languages for which to
+ offer support;
+ - `addition`: the additional modules to include. """
+
+ modules = {}
+
+ # In 'hand-written' information files, the user ain't using the
+ # '!!python/tuple' trick, so we're just going to use a list instead
+ # of a tuple.
+ compiler = list(compiler)
+
+ # Get the language defaults for the systems.
+ # 'ds' means 'default systems', 'ls' means 'loaded systems',
+ # 'sn' means 'system name'.
+ default = {'c': [], 'c++': []}
+ ds = [system]
+ ls = []
+ while ds:
+ sn = ds.pop(0)
+ if sn in ls:
+ continue
+ ls.append(sn)
+
+ sys = self.getsystem(sn)
+ ds.extend(sys.deps)
+ if sys.arch and not (arch, endian) in sys.arch:
+ Raise(UnsupportedArchForSystemException(arch, endian, sn))
+ if 'c' in sys.defaults:
+ default['c'] += sys.defaults['c']
+ default['c++'] += sys.defaults['c']
+ if 'c++' in sys.defaults:
+ default['c++'] += sys.defaults['c++']
+
+ # Gather the additional modules.
+ for name in set(addition):
+ module = self.getmodule(name)
+ if module.arch and all(not x in module.arch \
+ for x in ((arch, endian), (arch, None))):
+ Raise(UnsupportedArchForModuleException(name, arch))
+ continue
+ if module.compilers and not compiler in module.compilers:
+ Raise(UnsupportedCompilerForModuleException(name, compiler))
+ continue
+ modules[name] = module
+
+ # Gather the defaults for the languages.
+ # 'dm' means 'default modules', 'ldm' means 'language default modules'.
+ dm = []
+ for ldm in map(lambda x:default[x], languages):
+ dm.extend(ldm)
+ for name in dm:
+ module = self.getmodule(name)
+ if module.arch and all(not x in module.arch \
+ for x in ((arch, endian), (arch, None))):
+ continue
+ if module.compilers and not compiler in module.compilers:
+ continue
+ modules[name] = module
+
+ # Gather the dependencies.
+ # 'newdeps' is a list of tuples, where the first element of each tuple
+ # is the name of the module to gather, and the second is modules from
+ # which the dependency comes from (for logging).
+ newdeps = []
+ blacklist = []
+ while True:
+ # Get the previous dependencies.
+ for dep in newdeps:
+ name = dep[0]
+ try:
+ module = self.getmodule(name)
+ except (SystemNotFoundException, ModuleNotFoundException):
+ Raise(UnresolvedDependencyException(name, dep[1]))
+ blacklist.append(name)
+ continue
+
+ if module.arch and not arch in module.arch:
+ blacklist.append(name)
+ elif module.compiler and not compiler in module.compiler:
+ blacklist.append(name)
+ else:
+ modules[name] = module
+ newdeps = []
+
+ # Check the dependencies.
+ for name, module in modules.items():
+ for dep in module.deps:
+ if not dep in modules and not dep in blacklist:
+ try: ndep = next(i for i in newdeps if i[0] == dep)
+ except: newdeps.append([dep, [name]])
+ else: ndep[1].append(name)
+
+ # No dependency? Good!
+ if not newdeps:
+ break
+
+ # TODO: check conflicts.
+ # We're done!
+ return modules
+
+# End of file.
diff --git a/tools/configure.py b/tools/configure.py
index 09ee814..d8fcdc8 100755
--- a/tools/configure.py
+++ b/tools/configure.py
@@ -31,138 +31,168 @@ def __getendian():
""" Internal function to get the current endianness. """
return sys.byteorder
-# ---
-# Set up the argument parser.
-# ---
-
-argparser = CarrotArgumentParser(\
- _("Configures libcarrot to adapt it to many kinds of configurations."),
- usage="%(prog)s [OPTION]...")
-
def __from_root(*x):
+ """ Get the path from the project root. """
+
return os.path.normpath(os.path.join(os.path.dirname(__file__), '..', *x))
-# Main arguments.
-argparser.add_argument('-v', '/V', '--version', dest='version',
- action='store_true', help=_("show the version message and exit"))
-argparser.add_argument('-q', '--quiet', '/-silent', dest='silent',
- action='store_true', help=_("disable the configuration logging"))
-
-# Paths.
-argparser.add_argument('-o', '--output', '/-config-cache', dest='out',
- default=__from_root('.config.yml'),
- help=_("the path of the output configuration file"))
-argparser.add_argument('-C', '--cache', dest='cache',
- default=__from_root('.cache.yml'), help=_("the path of the cache file"))
-argparser.add_argument('-m', dest='mroot',
- default=__from_root('modules'), help=_("the modules root"))
-argparser.add_argument('-B', '/O', '--build', '/-obj', dest='builddir',
- default=__from_root('build'), help=_("the build directory"))
-
-# Build-related configuration elements.
-grp = argparser.add_argument_group(_('Build options'))
-
-grp.add_argument('-t', '--target', dest='target', default=None,
- help=_("the target for the library"))
-grp.add_argument('/-arch', dest='arch', default=__getarch())
-grp.add_argument('/-system', dest='system', default=__getsystem())
-grp.add_argument('/-abi', dest='abi', default=None)
-grp.add_argument('-e', '--endian', '/-endianness', dest='endian',
- default=None, help=_("the architecture endianness"))
-grp.add_argument('-l', '--languages', dest='lang', default='c',
- help=_("languages that libcarrot should support"))
-grp.add_argument('-a', '--add', dest='modules',
- default=[], action='append', help=_("add a module in the configuration "
- "(cumulative)"))
-grp.add_argument('-F', '--flavour', '/-flavor', dest='flavour',
- default='elf', help=_("the development files flavour"))
-grp.add_argument('-T', '--tooldir', dest='tooldir', default=None,
- help=_("add a tools directory (cumulative)"))
-grp.add_argument('/-shared')
-grp.add_argument('/-static')
-
-# TODO: Options for maintainers, to prefer a compiler.
-argparser.add_argument('/-prefer-cc', dest='pref_cc', default=None)
-argparser.add_argument('/-prefer-cxx', dest='pref_cxx', default=None)
-argparser.add_argument('/-prefer-asm', dest='pref_asm', default=None)
-argparser.add_argument('/-prefer-pack', dest='pref_pack', default=None)
-argparser.add_argument('/-prefer-link', dest='pref_link', default=None)
-argparser.add_argument('/-prefer-bin', dest='pref_bin', default=None)
-
-# TODO: Installation-related elements.
-grp = argparser.add_argument_group(_('Installation directories'))
-
-grp.add_argument('--root', default="",
- help=_("root (do not use DESTDIR)"))
-grp.add_argument('--prefix', default="${root}/usr",
- help=_("architecture-independent files"))
-grp.add_argument('--exec-prefix', default="${prefix}",
- help=_("architecture-dependant files"))
-grp.add_argument('--datarootdir', default="${prefix}/share",
- help=_("read-only architecture-independent data root"))
-
-grp.add_argument('--bindir', default="${root}/bin",
- help=_("user executables"))
-grp.add_argument('--sbindir', default="${root}/sbin",
- help=_("system admin executables"))
-grp.add_argument('--libexecdir', default="${root}/libexec",
- help=_("program executables"))
-grp.add_argument('--libdir', default="${prefix}/lib",
- help=_("directory for libraries"))
-grp.add_argument('--includedir', '/-oldincludedir',
- default="${prefix}/include",
- help=_("directory for development headers"))
-grp.add_argument('--datadir', default="${datarootdir}",
- help=_("read-only architecture-independent data"))
-grp.add_argument('--sysconfdir', default="${prefix}/etc",
- help=_("read-only single-machine data"))
-grp.add_argument('--sharedstatedir', default="${prefix}/com",
- help=_("modifiable architecture-independent data"))
-grp.add_argument('--localstatedir', default="${prefix}/var",
- help=_("modifiable single-machine data"))
-
-grp.add_argument('--infodir', default="${datarootdir}/info",
- help=_("info documentation"))
-grp.add_argument('--mandir', default="${datarootdir}/man",
- help=_("man documentation"))
-grp.add_argument('--docdir', default="${datarootdir}/doc/libcarrot",
- help=_("documentation root"))
-grp.add_argument('--localedir', default="${datarootdir}/locale",
- help=_("locale-dependent data"))
-
-grp.add_argument('--htmldir', default="${docdir}",
- help=_("html documentation"))
-grp.add_argument('--dvidir', default="${docdir}",
- help=_("dvi documentation"))
-grp.add_argument('--pdfdir', default="${docdir}",
- help=_("pdf documenation"))
-grp.add_argument('--psdir', default="${docdir}",
- help=_("ps documentation"))
-
-# Reserved arguments (from the glibc configure script).
-argparser.add_argument('/-maintainer', action='store_true')
-
-argparser.add_argument('/-disable-option-checking', action='store_true')
-argparser.add_argument('/-disable-sanity-checks', action='store_true')
-argparser.add_argument('/-enable-shared', action='store_true')
-argparser.add_argument('/-enable-profile', action='store_true')
-argparser.add_argument('/-disable-timezone-tools', action='store_true')
-argparser.add_argument('/-enable-hardcoded-path-in-tests', action='store_true')
-argparser.add_argument('/-enable-stackguard-randomization',
- action='store_true')
-argparser.add_argument('/-enable-lock-elision', choices=('yes', 'no'),
- default='no')
-argparser.add_argument('/-disable-hidden-plt', action='store_true')
+# ---
+# Parse the command line arguments.
+# ---
+
+def get_args(argv = sys.argv[1:]):
+ """ Get the arguments using an argument parser. """
+
+ argparser = CarrotArgumentParser(\
+ description=_("Configures libcarrot to adapt it to many kinds " \
+ "of configurations."),
+ usage="%(prog)s [OPTION]...")
+
+ # Main arguments.
+
+ argparser.add_argument('-v', '/V', '--version', dest='version',
+ action='store_true', help=_("show the version message and exit"))
+ argparser.add_argument('/-maintainer', action='store_true')
+ argparser.add_argument('-q', '--quiet', '/-silent', dest='silent',
+ action='store_true', help=_("disable the configuration logging"))
+
+ # Locations.
+ # Options are there to override what is defined in the main project
+ # information file.
+
+ grp = argparser.add_argument_group(_('Build files and directories'))
+
+ grp.add_argument('-p', '--project', dest='projectfile',
+ default=__from_root('project.yml'),
+ help=_("the path to the project information file"))
+
+ grp.add_argument('-m', '--modroot', dest='mroot',
+ default=None, help=_("override the modules root"))
+ grp.add_argument('-B', '/O', '--build', '/-obj', dest='builddir',
+ default=None, help=_("override the build root"))
+
+ grp.add_argument('-o', '--output', '/-config-cache', dest='out',
+ default=None, help=_("override the output configuration file path"))
+ grp.add_argument('-C', '--cache', dest='cache',
+ default=None, help=_("override the cache file path"))
+
+ # Build-related configuration elements.
+
+ grp = argparser.add_argument_group(_('Build options'))
+
+ grp.add_argument('-t', '--target', dest='target', default=None,
+ help=_("the target for the library"))
+ grp.add_argument('/-arch', dest='arch', default=__getarch())
+ grp.add_argument('/-system', dest='system', default=__getsystem())
+ grp.add_argument('/-abi', dest='abi', default=None)
+ grp.add_argument('-e', '--endian', '/-endianness', dest='endian',
+ default=None, help=_("the architecture endianness"))
+ grp.add_argument('-l', '--languages', dest='lang', default='c',
+ help=_("languages that libcarrot should support"))
+ grp.add_argument('-a', '--add', dest='modules',
+ default=[], action='append', help=_("add a module in the configuration "
+ "(cumulative)"))
+ grp.add_argument('-F', '--flavour', '/-flavor', dest='flavour',
+ default='elf', help=_("the development files flavour"))
+ grp.add_argument('-T', '--tooldir', dest='tooldir', default=None,
+ help=_("add a tools directory (cumulative)"))
+ grp.add_argument('/-shared')
+ grp.add_argument('/-static')
+
+ # TODO: Options for maintainers, to prefer a compiler.
+
+ argparser.add_argument('/-prefer-cc', dest='pref_cc', default=None)
+ argparser.add_argument('/-prefer-cxx', dest='pref_cxx', default=None)
+ argparser.add_argument('/-prefer-asm', dest='pref_asm', default=None)
+ argparser.add_argument('/-prefer-pack', dest='pref_pack', default=None)
+ argparser.add_argument('/-prefer-link', dest='pref_link', default=None)
+ argparser.add_argument('/-prefer-bin', dest='pref_bin', default=None)
+
+ # TODO: Installation-related elements.
+
+ grp = argparser.add_argument_group(_('Installation directories'))
+
+ grp.add_argument('--root', default="",
+ help=_("root (do not use DESTDIR)"))
+ grp.add_argument('--prefix', default="${root}/usr",
+ help=_("architecture-independent files"))
+ grp.add_argument('--exec-prefix', dest='EXECPREFIX',
+ default="${prefix}",
+ help=_("architecture-dependant files"))
+ grp.add_argument('--datarootdir', default="${prefix}/share",
+ help=_("read-only architecture-independent data root"))
+
+ grp.add_argument('--bindir', default="${root}/bin",
+ help=_("user executables"))
+ grp.add_argument('--sbindir', default="${root}/sbin",
+ help=_("system admin executables"))
+ grp.add_argument('--libexecdir', default="${root}/libexec",
+ help=_("program executables"))
+ grp.add_argument('--libdir', default="${prefix}/lib",
+ help=_("directory for libraries"))
+ grp.add_argument('--includedir', '/-oldincludedir',
+ default="${prefix}/include",
+ help=_("directory for development headers"))
+ grp.add_argument('--datadir', default="${datarootdir}",
+ help=_("read-only architecture-independent data"))
+ grp.add_argument('--sysconfdir', default="${prefix}/etc",
+ help=_("read-only single-machine data"))
+ grp.add_argument('--sharedstatedir', dest='SHAREDSDIR',
+ default="${prefix}/com",
+ help=_("modifiable architecture-independent data"))
+ grp.add_argument('--localstatedir', dest='LOCALSDIR',
+ default="${prefix}/var",
+ help=_("modifiable single-machine data"))
+
+ grp.add_argument('--infodir', default="${datarootdir}/info",
+ help=_("info documentation"))
+ grp.add_argument('--mandir', default="${datarootdir}/man",
+ help=_("man documentation"))
+ grp.add_argument('--docdir', default="${datarootdir}/doc/libcarrot",
+ help=_("documentation root"))
+ grp.add_argument('--localedir', default="${datarootdir}/locale",
+ help=_("locale-dependent data"))
+
+ grp.add_argument('--htmldir', default="${docdir}",
+ help=_("html documentation"))
+ grp.add_argument('--dvidir', default="${docdir}",
+ help=_("dvi documentation"))
+ grp.add_argument('--pdfdir', default="${docdir}",
+ help=_("pdf documenation"))
+ grp.add_argument('--psdir', default="${docdir}",
+ help=_("ps documentation"))
+
+ # Reserved arguments for features (from the glibc configure script).
+
+ argparser.add_argument('/-disable-option-checking', action='store_true')
+ argparser.add_argument('/-disable-sanity-checks', action='store_true')
+ argparser.add_argument('/-enable-shared', action='store_true')
+ argparser.add_argument('/-enable-profile', action='store_true')
+ argparser.add_argument('/-disable-timezone-tools', action='store_true')
+ argparser.add_argument('/-enable-hardcoded-path-in-tests',
+ action='store_true')
+ argparser.add_argument('/-enable-stackguard-randomization',
+ action='store_true')
+ argparser.add_argument('/-enable-lock-elision', choices=('yes', 'no'),
+ default='no')
+ argparser.add_argument('/-disable-hidden-plt', action='store_true')
+
+ # Parse the arguments!
+
+ return argparser.parse_args(argv)
# ---
# Write the configuration.
# ---
def main():
- # Parse the arguments.
- args = argparser.parse_args()
+ """ Main function for the configure script. """
+
+ args = get_args()
+ cfg = UserConfig(args.out)
# Get the arch and system from the eventual target.
+
if args.target:
args.arch, *tab = args.target.split('-')
if not tab:
@@ -174,11 +204,11 @@ def main():
raise MissingSystemInTargetException
# Get the arch family, processor and endianness.
+
thing = get_arch_detail(args.arch)
if not thing: raise UnsupportedArchException(args.arch)
args.family, args.arch, endian = thing
- # Get the endianness.
if args.endian:
if endian: raise RedundantEndiannessException
else:
@@ -186,6 +216,7 @@ def main():
args.endian = endian
# Get the languages.
+
args.lang = set(args.lang.split(','))
try:
lang = next(lang for lang in args.lang if not lang in ['c', 'c++'])
@@ -194,19 +225,22 @@ def main():
pass
# Get the additional modules.
+
addm = []
for arg in args.modules:
addm += arg.split(',')
args.modules = addm
# Get the global source.
- g = SourceGlobal(args.mroot)
+
+ g = Project(args.projectfile)
if args.version:
print(_("libcarrot {}").format(str(g.version)))
print(_("Maintained by {}.").format(str(g.maintainer)))
return
# Get the platform.
+
s = g.getsystem(args.system)
if s.meta:
raise MetaSystemException(s.name)
@@ -219,15 +253,18 @@ def main():
raise UnsupportedArchForSystemException(args.arch, args.endian, s.name)
# Clean the repository.
+
ret = call(['python3', os.path.join('tools', 'make.py'), 'mrproper'])
if ret: Raise(SilentException)
# Find the tools.
+
found_tools = tools.find(args.lang, args.arch, args.endian,
args.system, args.abi, args.flavour)
tools.setup(found_tools)
# List the modules.
+
mods = g.findmodules(args.arch, args.endian, args.system,
tools.get('compiler'), tools.get('compiler'), args.lang, args.modules)
modules = list(mods.keys())
@@ -235,34 +272,21 @@ def main():
# XXX: shall we order modules by output type?
# If we do, it's instead of the previous `modules = list(mods.keys())`
# instruction!
- #
+
#modules = {}
#for name, module in mods.items():
# if not module.out in modules:
# modules[module.out] = []
# modules[module.out].append(name)
+ # Set the locations.
+ root = os.path.dirname(args.out)
+ cfg.source = os.path.relpath('modules', root)
+ cfg.cache = os.path.relpath(args.cache, root)
+ cfg.build = os.path.relpath(args.builddir, root)
+
# Write the configuration.
- with open(args.out, "w") as out:
- # Make the paths configuration.
- root = os.path.dirname(args.out)
- paths = {
- 'source': os.path.relpath('arch', root),
- 'cache': os.path.relpath(args.cache, root),
- 'build': os.path.relpath(args.builddir, root),
- }
-
- # Make the configuration.
- config = {
- 'magic': 'potatosdk-1.0',
- 'paths': paths,
- 'tools': found_tools,
- 'modules': modules,
- 'orig': ' '.join(map(shlex.quote, sys.argv))
- }
-
- # Dump the configuration.
- print(yaml.dump(config, version=(1, 2), width=60), file=out, end='')
+ cfg.write()
# Tell the user we're done.
if not args.silent:
diff --git a/tools/getcopyright.py b/tools/getcopyright.py
deleted file mode 100755
index a9107b2..0000000
--- a/tools/getcopyright.py
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/usr/bin/env python3
-""" This tool gets the copyright on a libcarrot file, using the
- copyright.yml files. Mainly a proof-of-concept.
-"""
-
-import os
-from Internals import *
-
-#*****************************************************************************#
-# Set up the arguments parser #
-#*****************************************************************************#
-argparser = CarrotArgumentParser(_(\
- "Gets the copyright of one or more files using the machine-readable "
- "copyright information files."))
-
-# Main arguments.
-argparser.add_argument('path', nargs='+', help=_("the files to check"))
-argparser.add_argument('-R', '--recursive', dest='rec', action='store_true',
- help=_("go through the folders recursively"))
-argparser.add_argument('--hide-public', dest='hidepub', action='store_true',
- help=_("hide files for which copyright is unavailable"))
-#*****************************************************************************#
-# Main function #
-#*****************************************************************************#
-def main():
- # Parse the arguments.
- args = argparser.parse_args()
-
- # Get the project root.
- root = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
- rules = get_copyright_rules(root)
-
- paths = []
- for path in args.path:
- if not os.path.exists(path):
- raise FileNotFoundException(path)
- elif os.path.isdir(path):
- if not args.rec: continue
- for rt, _, nms in os.walk(path):
- for nm in nms:
- paths.append(os.path.join(rt, nm))
- else:
- paths.append(path)
-
- first = True
- for path in sorted(set(paths)):
- # Correct the path.
- p0 = os.path.relpath(root, os.getcwd())
- p1 = os.path.relpath(os.path.join('.', path), root)
- p = os.path.join(p0, p1)
-
- # Get the copyright information.
- msg = None
- authors, license = [], ''
- try:
- authors, license = get_copyright(rules, p)
- except (NotAFileException, IgnoredFileException):
- continue
- except NoCopyrightException as e:
- if args.hidepub: continue
- msg = str(e)
- else:
- msg = ''
- for (start, end), name, mail in authors:
- ds = '%s-%s'%(start, end) if start < end else '%s'%start
- msg += 'Copyright (C) %s %s <%s>\n'%(ds, name, mail)
-
- # Put the information.
- if first: first = False
- else: print('')
- print('%s:'%path)
- msg = map(lambda x:' %s' % x, msg.splitlines())
- print(*msg, sep=os.linesep)
-
-if __name__ == "__main__":
- do_main(main)
-
-# End of file.
diff --git a/tools/make.py b/tools/make.py
index 94f68e5..be53076 100755
--- a/tools/make.py
+++ b/tools/make.py
@@ -9,15 +9,23 @@
and this is cool when you are just programming in one or more modules.
"""
-import os, traceback
+import os, sys, traceback
from shutil import rmtree, copyfile
+
import yaml
from Internals import *
_ = gettext
-#*****************************************************************************#
-# Commands #
-#*****************************************************************************#
+# ---
+# Commands.
+# ---
+
+def placeholder(args):
+ """ Placeholder for non-ready commands. """
+
+ print(_("Command `{cmd}` is not ready yet!").format(cmd=args.command),
+ file=sys.stderr)
+
def clean(args):
""" Clean the project (remove generated files in order to
force rebuild). """
@@ -190,9 +198,8 @@ def build(args):
if tools.pack(os.path.join('obj', libname), libs[lib]):
exit(1)
-def docs(args):
- print("This command isn't ready yet!")
- pass
+def build_docs(args):
+ """ Build the documentation. """
def install(args):
pass
@@ -205,76 +212,166 @@ def install(args):
# or `win32com.shell.IsUserAnAdmin()` on Windows)
# (if not, try sudoing the same command)
-#*****************************************************************************#
-# Parse arguments #
-#*****************************************************************************#
+def getcopyright(args):
+ """ Get the copyright information. """
+
+ # Get the project root.
+ root = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
+ rules = get_copyright_rules(root)
+
+ paths = []
+ for path in args.path:
+ if not os.path.exists(path):
+ raise FileNotFoundException(path)
+ elif os.path.isdir(path):
+ if not args.rec: continue
+ for rt, _, nms in os.walk(path):
+ for nm in nms:
+ paths.append(os.path.join(rt, nm))
+ else:
+ paths.append(path)
+
+ first = True
+ for path in sorted(set(paths)):
+ # Correct the path.
+ p0 = os.path.relpath(root, os.getcwd())
+ p1 = os.path.relpath(os.path.join('.', path), root)
+ p = os.path.join(p0, p1)
+
+ # Get the copyright information.
+ msg = None
+ authors, license = [], ''
+ try:
+ authors, license = get_copyright(rules, p)
+ except (NotAFileException, IgnoredFileException):
+ continue
+ except NoCopyrightException as e:
+ if args.hidepub: continue
+ msg = str(e)
+ else:
+ msg = ''
+ for (start, end), name, mail in authors:
+ ds = '%s-%s'%(start, end) if start < end else '%s'%start
+ msg += 'Copyright (C) %s %s <%s>\n'%(ds, name, mail)
+
+ # Put the information.
+ if first: first = False
+ else: print('')
+ print('%s:'%path)
+ msg = map(lambda x:' %s' % x, msg.splitlines())
+ print(*msg, sep=os.linesep)
+
+# ---
+# Parse the command line arguments.
+# ---
+
__carrot = """\
- ___
+ ___
`-._\ / `~~"--.,_
------>| `~~"--.,_
_.-'/ '.____,,,,----\"""~~```'
"""
-argparser = CarrotArgumentParser(description=_(\
- "Makes various operations requiring the library to be configured."))
-argparser.add_argument('-c', '--config', dest='config',
- default=os.path.join(os.path.dirname(__file__), '..', '.config.yml'),
- help=_("the configuration file path"))
-subs = argparser.add_subparsers(title=_("subcommands"), dest='command',
- metavar='<command>')
-
-# XXX: HACKZ.
-# GNU Make seems to call this script once with 'Makefile', then once with
-# the real rule.
-
-subs.add_parser('Makefile', help="(ignored)")
-
-commands = [
- ('help', ['halp'], "print help"),
- ('carrot', ['carrot'], "print an ASCII art carrot"),
- ('build', ['all', 'libcarrot'], "build the project"),
- ('clean', [], "clean the project"),
- ('distclean', ['mrproper'], "clean the project completely"),
- ('re', ['rebuild'], "rebuild the project"),
- ('docs', ['html'], "build the HTML docs"),
-]
-
-# Hack.
-# I would have preferred to use `action="store_const"` and the `const`
-# property on the subparsers, but... this will work.
-
-cmds = {
- 'help': lambda args: argparser.print_help(),
- 'carrot': lambda args: print(__carrot),
- 'build': build, 'clean': clean,
- 'distclean': mrproper,
- 're': lambda args: (clean(args), build(args)),
- 'docs': docs,
-}
-
-# Add all of the commands.
-
-for cmd, als, hlp in commands:
- sub = subs.add_parser(cmd, help=_(hlp), aliases=als)
- cmds[cmd] = (cmds[cmd], sub)
-
-# Add specific options.
-
-cmds['docs'][1].add_argument('-d', dest='hroot',
- default='html', help=_("the html root"))
-
-#*****************************************************************************#
-# Main interface. #
-#*****************************************************************************#
+def get_args(argv = sys.argv):
+ """ Get the arguments using an argument parser. """
+
+ argparser = CarrotArgumentParser(description=\
+ _("Makes various operations."))
+ argparser.add_argument('-c', '--config', dest='config',
+ default=os.path.join(os.path.dirname(__file__), '..', '.config.yml'),
+ help=_("the configuration file path"))
+ subs = argparser.add_subparsers(title=_("Subcommands"), dest='command',
+ metavar='<command>')
+
+ commands = [
+ ('build', "build the project",
+ ['all', 'libcarrot']),
+ ('clean', "clean the project",
+ []),
+ ('distclean', "clean the project completely",
+ ['mrproper']),
+ ('re', "rebuild the project",
+ ['rebuild']),
+ ('docs', "build the HTML docs",
+ ['html']),
+
+ ('help', "print help",
+ ['halp']),
+ ('carrot', "print an ASCII art carrot",
+ []),
+ ('getcopyright', "get the copyright information",
+ ['getcopy', 'gcpy']),
+
+ ('listcmds', "(ignored)",
+ []),
+ ('nothing', "(ignored)",
+ ['Makefile', 'ignore'], ),
+ ]
+
+ # Hack.
+ # I would have preferred to use `action="store_const"` and the `const`
+ # property on the subparsers, but... this will work.
+
+ def listcmds(args):
+ """ List the commands. """
+
+ lst = []
+ for cmd, _, als in commands:
+ lst.append(cmd)
+ #lst.extend([cmd] + als)
+ print(*lst, sep=os.linesep)
+
+ cmds = {
+ 'help': lambda args: argparser.print_help(),
+ 'carrot': lambda args: print(__carrot),
+ 'build': build, 'clean': clean,
+ 'distclean': mrproper,
+ 're': lambda args: (clean(args), build(args)),
+ 'getcopyright': getcopyright,
+ 'docs': build_docs,
+ 'listcmds': listcmds
+ }
+
+ # Add all of the commands.
+
+ for cmd, hlp, als in commands:
+ sub = subs.add_parser(cmd, help=_(hlp), aliases=als)
+ cmds[cmd] = (cmds[cmd] if cmd in cmds else lambda x: 0, sub)
+
+ # Add specific options.
+
+ cmds['docs'][1].add_argument('-d', dest='hroot',
+ default='html', help=_("the html root"))
+ cmds['getcopyright'][1].add_argument('path', nargs='+',
+ help=_("the files to check"))
+ cmds['getcopyright'][1].add_argument('-R', '--recursive',
+ dest='rec', action='store_true',
+ help=_("go through the folders recursively"))
+ cmds['getcopyright'][1].add_argument('--hide-public',
+ dest='hidepub', action='store_true',
+ help=_("hide files for which copyright is unavailable"))
+
+# ---
+# Main interface.
+# ---
+
def main():
""" Main function, checks the command and runs the appropriate
function. """
# Parse the arguments, execute the command.
+ # `argparse` actually returns the alias instead of the canonical command,
+ # so as a hack (XXX), we'll find the canonical command name ourselves.
+
args = argparser.parse_args()
+ for cmd, _, als in commands:
+ if args.command in als:
+ args.command = cmd
+ break
if not args.command in cmds:
exit(0)
- cmds[args.command][0](args)
+ ret = cmds[args.command][0](args)
+ exit(ret)
if __name__ == "__main__":
do_main(main)