aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas "Cakeisalie5" Touhey <thomas@touhey.fr>2017-07-19 21:48:30 +0200
committerThomas "Cakeisalie5" Touhey <thomas@touhey.fr>2017-07-19 21:48:30 +0200
commit9bd5ee0017cb7ddbcbd1dca50e292e68c6eca312 (patch)
tree25a9865aa932afabc4132a1cad1680169a4c0432
parent21c246e12eea469354842856a6f2e1337b9abe4e (diff)
Broke the build once again, to make it in a cleaner way.
-rw-r--r--.gitignore5
-rwxr-xr-xMakefile9
-rw-r--r--arch/all/compiler-gcc/bits/types.h181
-rw-r--r--arch/all/compiler-gcc/bits/types/exact.h27
-rw-r--r--arch/all/compiler-gcc/bits/types/fast.h27
-rw-r--r--arch/all/compiler-gcc/bits/types/least.h36
-rw-r--r--arch/all/compiler-gcc/bits/types/max.h12
-rw-r--r--arch/all/compiler-gcc/bits/types/primitive.h42
-rw-r--r--arch/all/compiler-gcc/bits/types/ptr.h9
-rw-r--r--arch/all/compiler-gcc/info.yml (renamed from arch/all/compiler-gcc/config.yml)5
-rw-r--r--arch/all/compiler-renesas/bits/types.h190
-rw-r--r--arch/all/compiler-renesas/bits/types/exact.h27
-rw-r--r--arch/all/compiler-renesas/bits/types/fast.h27
-rw-r--r--arch/all/compiler-renesas/bits/types/float.h10
-rw-r--r--arch/all/compiler-renesas/bits/types/least.h36
-rw-r--r--arch/all/compiler-renesas/bits/types/max.h12
-rw-r--r--arch/all/compiler-renesas/bits/types/primitive.h32
-rw-r--r--arch/all/compiler-renesas/bits/types/ptr.h9
-rw-r--r--arch/all/compiler-renesas/info.yml (renamed from arch/all/compiler-renesas/config.yml)5
-rw-r--r--arch/all/compiler-sdcc/README.md2
-rw-r--r--arch/all/compiler-sdcc/bits/compiler.h14
-rw-r--r--arch/all/compiler-sdcc/info.yml (renamed from arch/all/compiler-sdcc/config.yml)5
-rw-r--r--arch/all/compiler-turbo/info.yml (renamed from arch/all/compiler-turbo/config.yml)5
-rw-r--r--arch/all/compiler-xlc/README.md5
-rw-r--r--arch/all/compiler-xlc/bits/compiler.h32
-rw-r--r--arch/all/compiler-xlc/bits/endian.h9
-rw-r--r--arch/all/compiler-xlc/bits/types/primitive.h52
-rw-r--r--arch/all/compiler-xlc/info.yml6
-rw-r--r--arch/all/config.yml10
-rw-r--r--arch/all/core-cocorico/info.yml (renamed from arch/all/core-cocorico/config.yml)2
-rw-r--r--arch/all/core-sh/config.yml7
-rw-r--r--arch/all/core-sh/info.yml17
-rw-r--r--arch/all/core/include/stddef.h7
-rw-r--r--arch/all/core/info.yml (renamed from arch/all/core/config.yml)2
-rw-r--r--arch/all/cpp/config.yml6
-rw-r--r--arch/all/cpp/info.yml4
-rw-r--r--arch/all/ensigdsp-sh/README.md (renamed from arch/all/sh-ensigdsp/README.md)2
-rw-r--r--arch/all/ensigdsp-sh/include/ensigdsp.h (renamed from arch/all/sh-ensigdsp/include/ensigdsp.h)0
-rw-r--r--arch/all/ensigdsp-sh/info.yml (renamed from arch/all/sh-ensigdsp/config.yml)2
-rw-r--r--arch/all/iconv/info.yml (renamed from arch/all/iconv/config.yml)2
-rw-r--r--arch/all/info.yml18
-rw-r--r--arch/all/math/README.md (renamed from arch/all/core-math/README.md)0
-rw-r--r--arch/all/math/include/math.h (renamed from arch/all/core-math/include/math.h)0
-rw-r--r--arch/all/math/include/mathf.h (renamed from arch/all/core-math/include/mathf.h)0
-rw-r--r--arch/all/math/info.yml (renamed from arch/all/core-math/config.yml)2
-rw-r--r--arch/casiowin/config.yml6
-rw-r--r--arch/casiowin/easy-grayscales/info.yml (renamed from arch/casiowin/easy-grayscales/config.yml)2
-rw-r--r--arch/casiowin/easy-input/info.yml (renamed from arch/casiowin/easy-input/config.yml)2
-rw-r--r--arch/casiowin/fxlib-core/info.yml (renamed from arch/casiowin/fxlib-core/config.yml)2
-rw-r--r--arch/casiowin/fxlib-crt/info.yml (renamed from arch/casiowin/fxlib-crt/config.yml)2
-rw-r--r--arch/casiowin/fxlib/info.yml (renamed from arch/casiowin/fxlib/config.yml)2
-rw-r--r--arch/casiowin/info.yml14
-rw-r--r--arch/casiowin/libfxsys/info.yml (renamed from arch/casiowin/libfxsys/config.yml)2
-rw-r--r--arch/casiowin/monochromelib/info.yml (renamed from arch/casiowin/monochromelib/config.yml)2
-rw-r--r--arch/casiowin/revolutionfx/info.yml (renamed from arch/casiowin/revolutionfx/config.yml)2
-rw-r--r--arch/info.yml19
-rw-r--r--config.yml7
-rwxr-xr-xconfigure2
-rwxr-xr-xtools/Build/__gnu__.py25
-rwxr-xr-xtools/Build/__util__.py36
-rw-r--r--tools/FORMATS.md128
-rw-r--r--tools/Internals/__init__.py8
-rw-r--r--tools/Internals/exceptions.py150
-rwxr-xr-xtools/Internals/module.py (renamed from tools/Module/__init__.py)94
-rwxr-xr-xtools/Internals/suph.py (renamed from tools/makeinc.py)160
-rwxr-xr-xtools/Internals/tools/__init__.py (renamed from tools/Build/__init__.py)79
-rwxr-xr-xtools/Internals/tools/__util__.py54
-rw-r--r--tools/Internals/tools/formats.py (renamed from tools/Build/formats.py)0
-rw-r--r--tools/Internals/tools/gnu_ar.py (renamed from tools/Build/gnu_ar.py)26
-rw-r--r--tools/Internals/tools/gnu_as.py (renamed from tools/Build/gnu_as.py)14
-rwxr-xr-xtools/Internals/tools/gnu_gcc.py (renamed from tools/Build/gnu_gcc.py)11
-rwxr-xr-xtools/Internals/tools/renesas_asmsh.py (renamed from tools/Build/renesas_asmsh.py)2
-rwxr-xr-xtools/Internals/tools/renesas_optlnk.py (renamed from tools/Build/renesas_optlnk.py)2
-rwxr-xr-xtools/Internals/tools/renesas_shc.py (renamed from tools/Build/renesas_shc.py)6
-rw-r--r--tools/Module/object.py72
-rw-r--r--tools/README.md56
-rw-r--r--tools/config.template.yml6
-rwxr-xr-xtools/configure.py196
-rwxr-xr-xtools/make.py45
79 files changed, 1265 insertions, 881 deletions
diff --git a/.gitignore b/.gitignore
index d8c431f..38d6623 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,12 +1,15 @@
/Makefile.cfg
-/build.yml
/obj
/include
+
+# Old top-level generated things
/lib*.a
/lib*.dll
/crt*.o
# cache
+/build.yml
+/.config.yml
/.makeinc-cache
# that was for modules
diff --git a/Makefile b/Makefile
index c809baa..e11c9b9 100755
--- a/Makefile
+++ b/Makefile
@@ -1,14 +1,15 @@
#!/usr/bin/make -f
all:
- @tools/make.py build
+ @/usr/bin/env python3 tools/make.py build
clean:
- @tools/make.py clean
+ @/usr/bin/env python3 tools/make.py clean
mrproper:
- @tools/make.py mrproper
+ @/usr/bin/env python3 tools/make.py mrproper
re:
- @tools/make.py re
+ @/usr/bin/env python3 tools/make.py re
+.SILENT:
.PHONY: all clean mrproper re
# End of file.
diff --git a/arch/all/compiler-gcc/bits/types.h b/arch/all/compiler-gcc/bits/types.h
deleted file mode 100644
index ad05447..0000000
--- a/arch/all/compiler-gcc/bits/types.h
+++ /dev/null
@@ -1,181 +0,0 @@
-/* ************************************************************************* */
-/* Basic integer types */
-/* ************************************************************************* */
-/* Char type. */
-
-#define __CHAR_BIT __CHAR_BIT__
-#define __CHAR_IS_SIGNED !defined(__CHAR_UNSIGNED__)
-
-#define __CHAR_WIDTH ( 8)
-#define __CHAR_MIN (-__SCHAR_MAX__ - 1)
-#define __CHAR_MAX (+__SCHAR_MAX__)
-#define __UCHAR_MIN ( 0U)
-#define __UCHAR_MAX ( __SCHAR_MAX__ * 2U + 1U)
-
-/* Short type. */
-
-#define __SHRT_WIDTH __SHRT_WIDTH__
-#define __SHRT_MIN (-__SHRT_MAX__ - 1)
-#define __SHRT_MAX (+__SHRT_MAX__)
-#define __USHRT_MIN ( 0U)
-#define __USHRT_MAX ( __SHRT_MAX__ * 2U + 1U)
-
-/* Int type. */
-
-#define __INT_WIDTH __INT_WIDTH__
-#define __INT_MIN (-__INT_MAX__ - 1)
-#define __INT_MAX (+__INT_MAX__)
-#define __UINT_MIN ( 0U)
-#define __UINT_MAX ( __INT_MAX__ * 2U + 1U)
-
-/* Long type. */
-
-#define __LONG_WIDTH __LONG_WIDTH__
-#define __LONG_MIN (-__LONG_MAX__ - 1L)
-#define __LONG_MAX (+__LONG_MAX__)
-#define __ULONG_MIN ( 0UL)
-#define __ULONG_MAX (+__LONG_MAX__ * 2UL + 1UL)
-
-/* Long long type. */
-
-#define __LLONG_WIDTH ( 64)
-#define __LLONG_MIN (-__LLONG_MAX__ - 1LL)
-#define __LLONG_MAX (+__LLONG_MAX__)
-#define __ULLONG_MIN ( 0ULL)
-#define __ULLONG_MAX (+__LLONG_MAX__ * 2ULL + 1ULL)
-/* ************************************************************************* */
-/* Exactly N-bits integer types */
-/* ************************************************************************* */
-/* These are the types that contain exactly N bits. */
-
-typedef __INT8_TYPE__ __int8_t;
-typedef __UINT8_TYPE__ __uint8_t;
-typedef __INT16_TYPE__ __int16_t;
-typedef __UINT16_TYPE__ __uint16_t;
-typedef __INT32_TYPE__ __int32_t;
-typedef __UINT32_TYPE__ __uint32_t;
-
-#define __INT8_WIDTH ( 8)
-#define __INT8_MIN __INT8_C(-128)
-#define __INT8_MAX __INT8_C(+127)
-#define __UINT8_MIN __UINT8_C( 0)
-#define __UINT8_MAX __UINT8_C( 255)
-#define __PRI8 "hh"
-
-#define __INT16_WIDTH ( 16)
-#define __INT16_MIN __INT16_C(-32768)
-#define __INT16_MAX __INT16_C(+32767)
-#define __UINT16_MIN __UINT16_C( 0)
-#define __UINT16_MAX __UINT16_C( 65535)
-#define __PRI16 "h"
-
-#define __INT32_WIDTH ( 32)
-#define __INT32_MIN __INT32_C(-2147483648)
-#define __INT32_MAX __INT32_C(+2147483647)
-#define __UINT32_MIN __UINT32_C(0)
-#define __UINT32_MAX __UINT32_C( 4294967295)
-#define __PRI32 ""
-/* ************************************************************************* */
-/* At least N-bits integer types */
-/* ************************************************************************* */
-/* These are the types that can contain at least N bits. */
-
-typedef __int8_t __int_least8_t;
-typedef __uint8_t __uint_least8_t;
-typedef __int16_t __int_least16_t;
-typedef __uint16_t __uint_least16_t;
-typedef __int32_t __int_least32_t;
-typedef __uint32_t __uint_least32_t;
-
-#define __INT_LEAST8_WIDTH __INT8_WIDTH
-#define __INT_LEAST8_MIN __INT8_MIN
-#define __INT_LEAST8_MAX __INT8_MAX
-#define __UINT_LEAST8_MIN __UINT8_MIN
-#define __UINT_LEAST8_MAX __UINT8_MAX
-#define __PRILEAST8 __PRI8
-
-#define __INT8_C(_X) _X
-#define __UINT8_C(_X) _X ## U
-
-#define __INT_LEAST16_WIDTH __INT16_WIDTH
-#define __INT_LEAST16_MIN __INT16_MIN
-#define __INT_LEAST16_MAX __INT16_MAX
-#define __UINT_LEAST16_MIN __UINT16_MIN
-#define __UINT_LEAST16_MAX __UINT16_MAX
-#define __PRILEAST16 __PRI16
-
-#define __INT16_C(_X) _X
-#define __UINT16_C(_X) _X ## U
-
-#define __INT_LEAST32_WIDTH __INT32_WIDTH
-#define __INT_LEAST32_MIN __INT32_MIN
-#define __INT_LEAST32_MAX __INT32_MAX
-#define __UINT_LEAST32_MIN __UINT32_MIN
-#define __UINT_LEAST32_MAX __UINT32_MAX
-#define __PRILEAST32 __PRI32
-
-#define __INT32_C(_X) _X ## L
-#define __UINT32_C(_X) _X ## UL
-/* ************************************************************************* */
-/* Fastest integer types for N-bits values */
-/* ************************************************************************* */
-/* These types are the fastest that can contain N-bits values. */
-
-typedef __int32_t __int_fast8_t;
-typedef __uint32_t __uint_fast8_t;
-typedef __int32_t __int_fast16_t;
-typedef __uint32_t __uint_fast16_t;
-typedef __int32_t __int_fast32_t;
-typedef __uint32_t __uint_fast32_t;
-
-#define __INT_FAST8_WIDTH __INT32_WIDTH
-#define __INT_FAST8_MIN __INT32_MIN
-#define __INT_FAST8_MAX __INT32_MAX
-#define __UINT_FAST8_MIN __UINT32_MIN
-#define __UINT_FAST8_MAX __UINT32_MAX
-#define __PRIFAST8 __PRI32
-
-#define __INT_FAST16_WIDTH __INT32_WIDTH
-#define __INT_FAST16_MIN __INT32_MIN
-#define __INT_FAST16_MAX __INT32_MAX
-#define __UINT_FAST16_MIN __UINT32_MIN
-#define __UINT_FAST16_MAX __UINT32_MAX
-#define __PRIFAST16 __PRI32
-
-#define __INT_FAST32_WIDTH __INT32_WIDTH
-#define __INT_FAST32_MIN __INT32_MIN
-#define __INT_FAST32_MAX __INT32_MAX
-#define __UINT_FAST32_MIN __UINT32_MIN
-#define __UINT_FAST32_MAX __UINT32_MAX
-#define __PRIFAST32 __PRI32
-/* ************************************************************************* */
-/* Pointer-like integer types */
-/* ************************************************************************* */
-/* These types have the same width as a pointer. */
-
-typedef __int32_t __intptr_t;
-typedef __uint32_t __uintptr_t;
-
-#define __INTPTR_WIDTH __INT32_WIDTH
-#define __INTPTR_MIN __INT32_MIN
-#define __INTPTR_MAX __INT32_MAX
-#define __UINTPTR_MIN __UINT32_MIN
-#define __UINTPTR_MAX __UINT32_MAX
-#define __PRIPTR __PRI32
-/* ************************************************************************* */
-/* Greatest-width integer types */
-/* ************************************************************************* */
-/* These types have the greatest width you will ever be able to access. */
-
-typedef __int32_t __intmax_t;
-typedef __uint32_t __uintmax_t;
-
-#define __INTMAX_WIDTH __INT32_WIDTH
-#define __INTMAX_MIN __INT32_MIN
-#define __INTMAX_MAX __INT32_MAX
-#define __UINTMAX_MIN __UINT32_MIN
-#define __UINTMAX_MAX __UINT32_MAX
-#define __PRIMAX __PRI32
-
-#define __INTMAX_C(_X) _X ## L
-#define __UINTMAX_C(_X) _X ## UL
diff --git a/arch/all/compiler-gcc/bits/types/exact.h b/arch/all/compiler-gcc/bits/types/exact.h
new file mode 100644
index 0000000..7377e65
--- /dev/null
+++ b/arch/all/compiler-gcc/bits/types/exact.h
@@ -0,0 +1,27 @@
+typedef __INT8_TYPE__ __int8_t;
+typedef __UINT8_TYPE__ __uint8_t;
+typedef __INT16_TYPE__ __int16_t;
+typedef __UINT16_TYPE__ __uint16_t;
+typedef __INT32_TYPE__ __int32_t;
+typedef __UINT32_TYPE__ __uint32_t;
+
+#define __INT8_WIDTH ( 8)
+#define __INT8_MIN __INT8_C(-128)
+#define __INT8_MAX __INT8_C(+127)
+#define __UINT8_MIN __UINT8_C( 0)
+#define __UINT8_MAX __UINT8_C( 255)
+#define __PRI8 "hh"
+
+#define __INT16_WIDTH ( 16)
+#define __INT16_MIN __INT16_C(-32768)
+#define __INT16_MAX __INT16_C(+32767)
+#define __UINT16_MIN __UINT16_C( 0)
+#define __UINT16_MAX __UINT16_C( 65535)
+#define __PRI16 "h"
+
+#define __INT32_WIDTH ( 32)
+#define __INT32_MIN __INT32_C(-2147483648)
+#define __INT32_MAX __INT32_C(+2147483647)
+#define __UINT32_MIN __UINT32_C(0)
+#define __UINT32_MAX __UINT32_C( 4294967295)
+#define __PRI32 ""
diff --git a/arch/all/compiler-gcc/bits/types/fast.h b/arch/all/compiler-gcc/bits/types/fast.h
new file mode 100644
index 0000000..33d3b9a
--- /dev/null
+++ b/arch/all/compiler-gcc/bits/types/fast.h
@@ -0,0 +1,27 @@
+typedef __int32_t __int_fast8_t;
+typedef __uint32_t __uint_fast8_t;
+typedef __int32_t __int_fast16_t;
+typedef __uint32_t __uint_fast16_t;
+typedef __int32_t __int_fast32_t;
+typedef __uint32_t __uint_fast32_t;
+
+#define __INT_FAST8_WIDTH __INT32_WIDTH
+#define __INT_FAST8_MIN __INT32_MIN
+#define __INT_FAST8_MAX __INT32_MAX
+#define __UINT_FAST8_MIN __UINT32_MIN
+#define __UINT_FAST8_MAX __UINT32_MAX
+#define __PRIFAST8 __PRI32
+
+#define __INT_FAST16_WIDTH __INT32_WIDTH
+#define __INT_FAST16_MIN __INT32_MIN
+#define __INT_FAST16_MAX __INT32_MAX
+#define __UINT_FAST16_MIN __UINT32_MIN
+#define __UINT_FAST16_MAX __UINT32_MAX
+#define __PRIFAST16 __PRI32
+
+#define __INT_FAST32_WIDTH __INT32_WIDTH
+#define __INT_FAST32_MIN __INT32_MIN
+#define __INT_FAST32_MAX __INT32_MAX
+#define __UINT_FAST32_MIN __UINT32_MIN
+#define __UINT_FAST32_MAX __UINT32_MAX
+#define __PRIFAST32 __PRI32
diff --git a/arch/all/compiler-gcc/bits/types/least.h b/arch/all/compiler-gcc/bits/types/least.h
new file mode 100644
index 0000000..a1338ec
--- /dev/null
+++ b/arch/all/compiler-gcc/bits/types/least.h
@@ -0,0 +1,36 @@
+typedef __int8_t __int_least8_t;
+typedef __uint8_t __uint_least8_t;
+typedef __int16_t __int_least16_t;
+typedef __uint16_t __uint_least16_t;
+typedef __int32_t __int_least32_t;
+typedef __uint32_t __uint_least32_t;
+
+#define __INT_LEAST8_WIDTH __INT8_WIDTH
+#define __INT_LEAST8_MIN __INT8_MIN
+#define __INT_LEAST8_MAX __INT8_MAX
+#define __UINT_LEAST8_MIN __UINT8_MIN
+#define __UINT_LEAST8_MAX __UINT8_MAX
+#define __PRILEAST8 __PRI8
+
+#define __INT8_C(_X) _X
+#define __UINT8_C(_X) _X ## U
+
+#define __INT_LEAST16_WIDTH __INT16_WIDTH
+#define __INT_LEAST16_MIN __INT16_MIN
+#define __INT_LEAST16_MAX __INT16_MAX
+#define __UINT_LEAST16_MIN __UINT16_MIN
+#define __UINT_LEAST16_MAX __UINT16_MAX
+#define __PRILEAST16 __PRI16
+
+#define __INT16_C(_X) _X
+#define __UINT16_C(_X) _X ## U
+
+#define __INT_LEAST32_WIDTH __INT32_WIDTH
+#define __INT_LEAST32_MIN __INT32_MIN
+#define __INT_LEAST32_MAX __INT32_MAX
+#define __UINT_LEAST32_MIN __UINT32_MIN
+#define __UINT_LEAST32_MAX __UINT32_MAX
+#define __PRILEAST32 __PRI32
+
+#define __INT32_C(_X) _X ## L
+#define __UINT32_C(_X) _X ## UL
diff --git a/arch/all/compiler-gcc/bits/types/max.h b/arch/all/compiler-gcc/bits/types/max.h
new file mode 100644
index 0000000..0e27663
--- /dev/null
+++ b/arch/all/compiler-gcc/bits/types/max.h
@@ -0,0 +1,12 @@
+typedef __int32_t __intmax_t;
+typedef __uint32_t __uintmax_t;
+
+#define __INTMAX_WIDTH __INT32_WIDTH
+#define __INTMAX_MIN __INT32_MIN
+#define __INTMAX_MAX __INT32_MAX
+#define __UINTMAX_MIN __UINT32_MIN
+#define __UINTMAX_MAX __UINT32_MAX
+#define __PRIMAX __PRI32
+
+#define __INTMAX_C(_X) _X ## L
+#define __UINTMAX_C(_X) _X ## UL
diff --git a/arch/all/compiler-gcc/bits/types/primitive.h b/arch/all/compiler-gcc/bits/types/primitive.h
new file mode 100644
index 0000000..08efbee
--- /dev/null
+++ b/arch/all/compiler-gcc/bits/types/primitive.h
@@ -0,0 +1,42 @@
+/* Char type. */
+
+#define __CHAR_BIT __CHAR_BIT__
+#define __CHAR_IS_SIGNED !defined(__CHAR_UNSIGNED__)
+
+#define __CHAR_WIDTH ( 8)
+#define __CHAR_MIN (-__SCHAR_MAX__ - 1)
+#define __CHAR_MAX (+__SCHAR_MAX__)
+#define __UCHAR_MIN ( 0U)
+#define __UCHAR_MAX ( __SCHAR_MAX__ * 2U + 1U)
+
+/* Short type. */
+
+#define __SHRT_WIDTH __SHRT_WIDTH__
+#define __SHRT_MIN (-__SHRT_MAX__ - 1)
+#define __SHRT_MAX (+__SHRT_MAX__)
+#define __USHRT_MIN ( 0U)
+#define __USHRT_MAX ( __SHRT_MAX__ * 2U + 1U)
+
+/* Int type. */
+
+#define __INT_WIDTH __INT_WIDTH__
+#define __INT_MIN (-__INT_MAX__ - 1)
+#define __INT_MAX (+__INT_MAX__)
+#define __UINT_MIN ( 0U)
+#define __UINT_MAX ( __INT_MAX__ * 2U + 1U)
+
+/* Long type. */
+
+#define __LONG_WIDTH __LONG_WIDTH__
+#define __LONG_MIN (-__LONG_MAX__ - 1L)
+#define __LONG_MAX (+__LONG_MAX__)
+#define __ULONG_MIN ( 0UL)
+#define __ULONG_MAX (+__LONG_MAX__ * 2UL + 1UL)
+
+/* Long long type. */
+
+#define __LLONG_WIDTH ( 64)
+#define __LLONG_MIN (-__LLONG_MAX__ - 1LL)
+#define __LLONG_MAX (+__LLONG_MAX__)
+#define __ULLONG_MIN ( 0ULL)
+#define __ULLONG_MAX (+__LLONG_MAX__ * 2ULL + 1ULL)
diff --git a/arch/all/compiler-gcc/bits/types/ptr.h b/arch/all/compiler-gcc/bits/types/ptr.h
new file mode 100644
index 0000000..53b01e4
--- /dev/null
+++ b/arch/all/compiler-gcc/bits/types/ptr.h
@@ -0,0 +1,9 @@
+typedef __int32_t __intptr_t;
+typedef __uint32_t __uintptr_t;
+
+#define __INTPTR_WIDTH __INT32_WIDTH
+#define __INTPTR_MIN __INT32_MIN
+#define __INTPTR_MAX __INT32_MAX
+#define __UINTPTR_MIN __UINT32_MIN
+#define __UINTPTR_MAX __UINT32_MAX
+#define __PRIPTR __PRI32
diff --git a/arch/all/compiler-gcc/config.yml b/arch/all/compiler-gcc/info.yml
index 114f7a2..431f476 100644
--- a/arch/all/compiler-gcc/config.yml
+++ b/arch/all/compiler-gcc/info.yml
@@ -1,6 +1,7 @@
%YAML 1.2
---
-version: potatosdk-1.0
+magic: potatosdk-1.0
description: Compiler bit headers for GCC.
requires:
- compiler: ['GNU/GCC']
+ compiler:
+ - ['GNU', 'GCC']
diff --git a/arch/all/compiler-renesas/bits/types.h b/arch/all/compiler-renesas/bits/types.h
deleted file mode 100644
index 25ccc97..0000000
--- a/arch/all/compiler-renesas/bits/types.h
+++ /dev/null
@@ -1,190 +0,0 @@
-/* ************************************************************************* */
-/* Basic integer types */
-/* ************************************************************************* */
-/* Char type. */
-
-#define __CHAR_BIT ( 8)
-#define __CHAR_IS_SIGNED 1
-
-#define __CHAR_WIDTH ( 8)
-#define __CHAR_MIN (-128)
-#define __CHAR_MAX (+127)
-#define __UCHAR_MIN ( 0)
-#define __UCHAR_MAX ( 255)
-
-/* Short type. */
-
-#define __SHRT_WIDTH ( 16)
-#define __SHRT_MIN (-32768)
-#define __SHRT_MAX (+32767)
-#define __USHRT_MIN ( 0)
-#define __USHRT_MAX (65535)
-
-/* Int type. */
-
-#define __INT_WIDTH ( 32)
-#define __INT_MIN (-2147483648)
-#define __INT_MAX (+2147483647)
-#define __UINT_MIN ( 0)
-#define __UINT_MAX ( 4294967295)
-
-/* Long type. */
-
-#define __LONG_WIDTH ( 32)
-#define __LONG_MIN (-2147483648L)
-#define __LONG_MAX (+2147483647L)
-#define __ULONG_MIN ( 0)
-#define __ULONG_MAX ( 4294967295UL)
-/* ************************************************************************* */
-/* XXX: move this to some other place */
-/* ************************************************************************* */
-/* These constants define whether the floating-point type `float` is
- * single-precision (`_FPS` defined) or double-precision (`_FPD`),
- * and if `double` is treated as a `float` (`_FLT` and `__FLT__` defined). */
-
-#if defined(_FPD)
-# define __FLOAT_DOUBLE 1
-#else
-# define __FLOAT_DOUBLE 0
-#endif
-#if defined(_FLT) || defined(__FLT__)
-# define __DOUBLE_FLOAT 1
-#else
-# define __DOUBLE_FLOAT 0
-#endif
-/* ************************************************************************* */
-/* Exactly N-bits integer types */
-/* ************************************************************************* */
-/* These are the types that contain exactly N bits. */
-
-typedef signed char __int8_t;
-typedef unsigned char __uint8_t;
-typedef signed short __int16_t;
-typedef unsigned short __uint16_t;
-typedef signed long __int32_t;
-typedef unsigned long __uint32_t;
-
-#define __INT8_WIDTH ( 8)
-#define __INT8_MIN __INT8_C(-128)
-#define __INT8_MAX __INT8_C( 127)
-#define __UINT8_MIN __UINT8_C( 0)
-#define __UINT8_MAX __UINT8_C( 255)
-#define __PRI8 "hh"
-
-#define __INT16_WIDTH ( 16)
-#define __INT16_MIN __INT16_C(-32768)
-#define __INT16_MAX __INT16_C( 32767)
-#define __UINT16_MIN __UINT16_C( 0)
-#define __UINT16_MAX __UINT16_C( 65535)
-#define __PRI16 "h"
-
-#define __INT32_WIDTH ( 32)
-#define __INT32_MIN __INT32_C(-2147483648)
-#define __INT32_MAX __INT32_C( 2147483647)
-#define __UINT32_MIN __UINT32_C(0)
-#define __UINT32_MAX __UINT32_C( 4294967295)
-#define __PRI32 ""
-/* ************************************************************************* */
-/* At least N-bits integer types */
-/* ************************************************************************* */
-/* These are the types that can contain at least N bits. */
-
-typedef __int8_t __int_least8_t;
-typedef __uint8_t __uint_least8_t;
-typedef __int16_t __int_least16_t;
-typedef __uint16_t __uint_least16_t;
-typedef __int32_t __int_least32_t;
-typedef __uint32_t __uint_least32_t;
-
-#define __INT_LEAST8_WIDTH __INT8_WIDTH
-#define __INT_LEAST8_MIN __INT8_MIN
-#define __INT_LEAST8_MAX __INT8_MAX
-#define __UINT_LEAST8_MIN __UINT8_MIN
-#define __UINT_LEAST8_MAX __UINT8_MAX
-#define __PRILEAST8 __PRI8
-
-#define __INT8_C(_X) _X
-#define __UINT8_C(_X) _X
-
-#define __INT_LEAST16_WIDTH __INT16_WIDTH
-#define __INT_LEAST16_MIN __INT16_MIN
-#define __INT_LEAST16_MAX __INT16_MAX
-#define __UINT_LEAST16_MIN __UINT16_MIN
-#define __UINT_LEAST16_MAX __UINT16_MAX
-#define __PRILEAST16 __PRI16
-
-#define __INT16_C(_X) _X
-#define __UINT16_C(_X) _X
-
-#define __INT_LEAST32_WIDTH __INT32_WIDTH
-#define __INT_LEAST32_MIN __INT32_MIN
-#define __INT_LEAST32_MAX __INT32_MAX
-#define __UINT_LEAST32_MIN __UINT32_MIN
-#define __UINT_LEAST32_MAX __UINT32_MAX
-#define __PRILEAST32 __PRI32
-
-#define __INT32_C(_X) _X ## L
-#define __UINT32_C(_X) _X ## UL
-/* ************************************************************************* */
-/* Fastest integer types for N-bits values */
-/* ************************************************************************* */
-/* These types are the fastest that can contain N-bits values. */
-
-typedef __int32_t __int_fast8_t;
-typedef __uint32_t __uint_fast8_t;
-typedef __int32_t __int_fast16_t;
-typedef __uint32_t __uint_fast16_t;
-typedef __int32_t __int_fast32_t;
-typedef __uint32_t __uint_fast32_t;
-
-#define __INT_FAST8_WIDTH __INT32_WIDTH
-#define __INT_FAST8_MIN __INT32_MIN
-#define __INT_FAST8_MAX __INT32_MAX
-#define __UINT_FAST8_MIN __UINT32_MIN
-#define __UINT_FAST8_MAX __UINT32_MAX
-#define __PRIFAST8 __PRI32
-
-#define __INT_FAST16_WIDTH __INT32_WIDTH
-#define __INT_FAST16_MIN __INT32_MIN
-#define __INT_FAST16_MAX __INT32_MAX
-#define __UINT_FAST16_MIN __UINT32_MIN
-#define __UINT_FAST16_MAX __UINT32_MAX
-#define __PRIFAST16 __PRI32
-
-#define __INT_FAST32_WIDTH __INT32_WIDTH
-#define __INT_FAST32_MIN __INT32_MIN
-#define __INT_FAST32_MAX __INT32_MAX
-#define __UINT_FAST32_MIN __UINT32_MIN
-#define __UINT_FAST32_MAX __UINT32_MAX
-#define __PRIFAST32 __PRI32
-/* ************************************************************************* */
-/* Pointer-like integer types */
-/* ************************************************************************* */
-/* These types have the same width as a pointer. */
-
-typedef __int32_t __intptr_t;
-typedef __uint32_t __uintptr_t;
-
-#define __INTPTR_WIDTH __INT32_WIDTH
-#define __INTPTR_MIN __INT32_MIN
-#define __INTPTR_MAX __INT32_MAX
-#define __UINTPTR_MIN __UINT32_MIN
-#define __UINTPTR_MAX __UINT32_MAX
-#define __PRIPTR __PRI32
-/* ************************************************************************* */
-/* Greatest-width integer types */
-/* ************************************************************************* */
-/* These types have the greatest width you will ever be able to access. */
-
-typedef __int32_t __intmax_t;
-typedef __uint32_t __uintmax_t;
-
-#define __INTMAX_WIDTH __INT32_WIDTH
-#define __INTMAX_MIN __INT32_MIN
-#define __INTMAX_MAX __INT32_MAX
-#define __UINTMAX_MIN __UINT32_MIN
-#define __UINTMAX_MAX __UINT32_MAX
-#define __PRIMAX __PRI32
-
-#define __INTMAX_C(_X) _X ## L
-#define __UINTMAX_C(_X) _X ## UL
diff --git a/arch/all/compiler-renesas/bits/types/exact.h b/arch/all/compiler-renesas/bits/types/exact.h
new file mode 100644
index 0000000..1dcf7fd
--- /dev/null
+++ b/arch/all/compiler-renesas/bits/types/exact.h
@@ -0,0 +1,27 @@
+typedef signed char __int8_t;
+typedef unsigned char __uint8_t;
+typedef signed short __int16_t;
+typedef unsigned short __uint16_t;
+typedef signed long __int32_t;
+typedef unsigned long __uint32_t;
+
+#define __INT8_WIDTH ( 8)
+#define __INT8_MIN __INT8_C(-128)
+#define __INT8_MAX __INT8_C( 127)
+#define __UINT8_MIN __UINT8_C( 0)
+#define __UINT8_MAX __UINT8_C( 255)
+#define __PRI8 "hh"
+
+#define __INT16_WIDTH ( 16)
+#define __INT16_MIN __INT16_C(-32768)
+#define __INT16_MAX __INT16_C( 32767)
+#define __UINT16_MIN __UINT16_C( 0)
+#define __UINT16_MAX __UINT16_C( 65535)
+#define __PRI16 "h"
+
+#define __INT32_WIDTH ( 32)
+#define __INT32_MIN __INT32_C(-2147483648)
+#define __INT32_MAX __INT32_C( 2147483647)
+#define __UINT32_MIN __UINT32_C(0)
+#define __UINT32_MAX __UINT32_C( 4294967295)
+#define __PRI32 ""
diff --git a/arch/all/compiler-renesas/bits/types/fast.h b/arch/all/compiler-renesas/bits/types/fast.h
new file mode 100644
index 0000000..33d3b9a
--- /dev/null
+++ b/arch/all/compiler-renesas/bits/types/fast.h
@@ -0,0 +1,27 @@
+typedef __int32_t __int_fast8_t;
+typedef __uint32_t __uint_fast8_t;
+typedef __int32_t __int_fast16_t;
+typedef __uint32_t __uint_fast16_t;
+typedef __int32_t __int_fast32_t;
+typedef __uint32_t __uint_fast32_t;
+
+#define __INT_FAST8_WIDTH __INT32_WIDTH
+#define __INT_FAST8_MIN __INT32_MIN
+#define __INT_FAST8_MAX __INT32_MAX
+#define __UINT_FAST8_MIN __UINT32_MIN
+#define __UINT_FAST8_MAX __UINT32_MAX
+#define __PRIFAST8 __PRI32
+
+#define __INT_FAST16_WIDTH __INT32_WIDTH
+#define __INT_FAST16_MIN __INT32_MIN
+#define __INT_FAST16_MAX __INT32_MAX
+#define __UINT_FAST16_MIN __UINT32_MIN
+#define __UINT_FAST16_MAX __UINT32_MAX
+#define __PRIFAST16 __PRI32
+
+#define __INT_FAST32_WIDTH __INT32_WIDTH
+#define __INT_FAST32_MIN __INT32_MIN
+#define __INT_FAST32_MAX __INT32_MAX
+#define __UINT_FAST32_MIN __UINT32_MIN
+#define __UINT_FAST32_MAX __UINT32_MAX
+#define __PRIFAST32 __PRI32
diff --git a/arch/all/compiler-renesas/bits/types/float.h b/arch/all/compiler-renesas/bits/types/float.h
new file mode 100644
index 0000000..e5c1619
--- /dev/null
+++ b/arch/all/compiler-renesas/bits/types/float.h
@@ -0,0 +1,10 @@
+#if defined(_FPD)
+# define __FLOAT_DOUBLE 1
+#else
+# define __FLOAT_DOUBLE 0
+#endif
+#if defined(_FLT) || defined(__FLT__)
+# define __DOUBLE_FLOAT 1
+#else
+# define __DOUBLE_FLOAT 0
+#endif
diff --git a/arch/all/compiler-renesas/bits/types/least.h b/arch/all/compiler-renesas/bits/types/least.h
new file mode 100644
index 0000000..8a2f57a
--- /dev/null
+++ b/arch/all/compiler-renesas/bits/types/least.h
@@ -0,0 +1,36 @@
+typedef __int8_t __int_least8_t;
+typedef __uint8_t __uint_least8_t;
+typedef __int16_t __int_least16_t;
+typedef __uint16_t __uint_least16_t;
+typedef __int32_t __int_least32_t;
+typedef __uint32_t __uint_least32_t;
+
+#define __INT_LEAST8_WIDTH __INT8_WIDTH
+#define __INT_LEAST8_MIN __INT8_MIN
+#define __INT_LEAST8_MAX __INT8_MAX
+#define __UINT_LEAST8_MIN __UINT8_MIN
+#define __UINT_LEAST8_MAX __UINT8_MAX
+#define __PRILEAST8 __PRI8
+
+#define __INT8_C(_X) _X
+#define __UINT8_C(_X) _X
+
+#define __INT_LEAST16_WIDTH __INT16_WIDTH
+#define __INT_LEAST16_MIN __INT16_MIN
+#define __INT_LEAST16_MAX __INT16_MAX
+#define __UINT_LEAST16_MIN __UINT16_MIN
+#define __UINT_LEAST16_MAX __UINT16_MAX
+#define __PRILEAST16 __PRI16
+
+#define __INT16_C(_X) _X
+#define __UINT16_C(_X) _X
+
+#define __INT_LEAST32_WIDTH __INT32_WIDTH
+#define __INT_LEAST32_MIN __INT32_MIN
+#define __INT_LEAST32_MAX __INT32_MAX
+#define __UINT_LEAST32_MIN __UINT32_MIN
+#define __UINT_LEAST32_MAX __UINT32_MAX
+#define __PRILEAST32 __PRI32
+
+#define __INT32_C(_X) _X ## L
+#define __UINT32_C(_X) _X ## UL
diff --git a/arch/all/compiler-renesas/bits/types/max.h b/arch/all/compiler-renesas/bits/types/max.h
new file mode 100644
index 0000000..0e27663
--- /dev/null
+++ b/arch/all/compiler-renesas/bits/types/max.h
@@ -0,0 +1,12 @@
+typedef __int32_t __intmax_t;
+typedef __uint32_t __uintmax_t;
+
+#define __INTMAX_WIDTH __INT32_WIDTH
+#define __INTMAX_MIN __INT32_MIN
+#define __INTMAX_MAX __INT32_MAX
+#define __UINTMAX_MIN __UINT32_MIN
+#define __UINTMAX_MAX __UINT32_MAX
+#define __PRIMAX __PRI32
+
+#define __INTMAX_C(_X) _X ## L
+#define __UINTMAX_C(_X) _X ## UL
diff --git a/arch/all/compiler-renesas/bits/types/primitive.h b/arch/all/compiler-renesas/bits/types/primitive.h
new file mode 100644
index 0000000..b0168fb
--- /dev/null
+++ b/arch/all/compiler-renesas/bits/types/primitive.h
@@ -0,0 +1,32 @@
+#define __CHAR_BIT ( 8)
+#define __CHAR_IS_SIGNED 1
+
+#define __CHAR_WIDTH ( 8)
+#define __CHAR_MIN (-128)
+#define __CHAR_MAX (+127)
+#define __UCHAR_MIN ( 0)
+#define __UCHAR_MAX ( 255)
+
+/* Short type. */
+
+#define __SHRT_WIDTH ( 16)
+#define __SHRT_MIN (-32768)
+#define __SHRT_MAX (+32767)
+#define __USHRT_MIN ( 0)
+#define __USHRT_MAX (65535)
+
+/* Int type. */
+
+#define __INT_WIDTH ( 32)
+#define __INT_MIN (-2147483648)
+#define __INT_MAX (+2147483647)
+#define __UINT_MIN ( 0)
+#define __UINT_MAX ( 4294967295)
+
+/* Long type. */
+
+#define __LONG_WIDTH ( 32)
+#define __LONG_MIN (-2147483648L)
+#define __LONG_MAX (+2147483647L)
+#define __ULONG_MIN ( 0)
+#define __ULONG_MAX ( 4294967295UL)
diff --git a/arch/all/compiler-renesas/bits/types/ptr.h b/arch/all/compiler-renesas/bits/types/ptr.h
new file mode 100644
index 0000000..53b01e4
--- /dev/null
+++ b/arch/all/compiler-renesas/bits/types/ptr.h
@@ -0,0 +1,9 @@
+typedef __int32_t __intptr_t;
+typedef __uint32_t __uintptr_t;
+
+#define __INTPTR_WIDTH __INT32_WIDTH
+#define __INTPTR_MIN __INT32_MIN
+#define __INTPTR_MAX __INT32_MAX
+#define __UINTPTR_MIN __UINT32_MIN
+#define __UINTPTR_MAX __UINT32_MAX
+#define __PRIPTR __PRI32
diff --git a/arch/all/compiler-renesas/config.yml b/arch/all/compiler-renesas/info.yml
index 31fd893..2302179 100644
--- a/arch/all/compiler-renesas/config.yml
+++ b/arch/all/compiler-renesas/info.yml
@@ -1,6 +1,7 @@
%YAML 1.2
---
-version: potatosdk-1.0
+magic: potatosdk-1.0
description: Compiler bit headers for Renesas C/C++ compiler.
requires:
- compiler: ['Renesas/SHC']
+ compiler:
+ - ['Renesas', 'SHC']
diff --git a/arch/all/compiler-sdcc/README.md b/arch/all/compiler-sdcc/README.md
index bfd8692..4b2d750 100644
--- a/arch/all/compiler-sdcc/README.md
+++ b/arch/all/compiler-sdcc/README.md
@@ -3,4 +3,4 @@ Because of GNU not supporting the tiny targets, someone made a compiler that
used adapted versions of the GNU binutils, and managed small targets not a lot
of GPL'd compilers did manage.
-This module provides the bits headers for this compiler.
+This module provides the header bits for this compiler.
diff --git a/arch/all/compiler-sdcc/bits/compiler.h b/arch/all/compiler-sdcc/bits/compiler.h
index 69b418e..eb75025 100644
--- a/arch/all/compiler-sdcc/bits/compiler.h
+++ b/arch/all/compiler-sdcc/bits/compiler.h
@@ -4,12 +4,14 @@
#if !defined(__SDCC)
# error "This header should only be used with SDCC!"
#endif
-/* ************************************************************************* */
-/* Detection and version checking */
-/* ************************************************************************* */
-/* SDCC provides the `SDCC` macro in the older versions, or `__SDCC` later and
- * still now. It has the decimal MMmm format, where `MM` is the major and
- * `mm` the minor. */
+
+/* For detection and version checking, SDCC provides the `SDCC` macro in
+ * legacy versions, or `__SDCC` otherwise.
+ *
+ * If `__SDCC_VERSION_MAJOR` and `__SDCC_VERSION_MINOR` are defined,
+ * they should be used.
+ * Otherwise, both macros should be of the decimal MMmm format,
+ * where `MM` is the major and `mm` the minor. */
#if defined(__SDCC_VERSION_MAJOR) && defined(__SDCC_VERSION_MINOR)
# define __SDCC_PREREQ(_MAJ, _MIN) \
diff --git a/arch/all/compiler-sdcc/config.yml b/arch/all/compiler-sdcc/info.yml
index a8af667..79f3846 100644
--- a/arch/all/compiler-sdcc/config.yml
+++ b/arch/all/compiler-sdcc/info.yml
@@ -1,6 +1,7 @@
%YAML 1.2
---
-version: potatosdk-1.0
+magic: potatosdk-1.0
description: Compiler bit headers for SDCC.
requires:
- compiler: ['sdcc']
+ compiler:
+ - ['SDCC', 'SDCC']
diff --git a/arch/all/compiler-turbo/config.yml b/arch/all/compiler-turbo/info.yml
index b058195..fcadc18 100644
--- a/arch/all/compiler-turbo/config.yml
+++ b/arch/all/compiler-turbo/info.yml
@@ -1,6 +1,7 @@
%YAML 1.2
---
-version: potatosdk-1.0
+magic: potatosdk-1.0
description: Compiler bit headers for the Turbo C Compiler.
requires:
- compiler: ['turbo']
+ compiler:
+ - ['Borland', 'Turbo C']
diff --git a/arch/all/compiler-xlc/README.md b/arch/all/compiler-xlc/README.md
new file mode 100644
index 0000000..5023f4a
--- /dev/null
+++ b/arch/all/compiler-xlc/README.md
@@ -0,0 +1,5 @@
+# IBM XLC Compiler
+XLC is the main C/C++ compiler for the AIX platform. (?)
+
+This module provides the header bits for this compiler.
+They may be a little too approximative, so don't trust them yet.
diff --git a/arch/all/compiler-xlc/bits/compiler.h b/arch/all/compiler-xlc/bits/compiler.h
new file mode 100644
index 0000000..8084454
--- /dev/null
+++ b/arch/all/compiler-xlc/bits/compiler.h
@@ -0,0 +1,32 @@
+#if !defined(__IBMC__) && !defined(__xlC__)
+# error "This header should only be used with IBM XLC!"
+#endif
+
+/* For detection and version checking, IBM XLC provides the `__IBMC__`,
+ * `__xlc__`, `__xlC__` and `__xlC_ver__` macros.
+ * `__IBMC__` is probably historical, so it should be checked if no other
+ * macro is there. `__xlc__` is unusable for version checking,
+ * so I'll be using the other macros.
+ *
+ * `__IBMC__` is as VRM (in base 10), where V is the version number (major),
+ * R is the release number (minor), and M is the modification number (patch?).
+ *
+ * `__xlc__` is a string of the format "V.R.M.F", where V represents the
+ * version number (major), R represents the release number (minor), M
+ * represents the modification number and F is the fix level (patch?).
+ *
+ * `__xlC__` indicates the VR level of the XL compiler version
+ * in the 0xVVRR format, where 'VV' represents the version number (major),
+ * and 'RR' represents the release number (minor).
+ *
+ * `__xlC_ver__` indicates the MF level of the XL compiler version
+ * in the 0x0000MMFF format, where 'MM' represents the version number,
+ * and 'RR' represents the release number. */
+
+#if defined(__xlC__)
+# define __XLC_PREREQ(_VER, _REL) \
+ ((__xlC__) >= ((_VER) << 8) | ((_REL) << 8))
+#else /* defined(__IBMC__) */
+# define __XLC_PREREQ(_MAJ, _MIN) \
+ ((__IBMC__) >= (_MAJ) * 100 + (_MIN) * 10)
+#endif
diff --git a/arch/all/compiler-xlc/bits/endian.h b/arch/all/compiler-xlc/bits/endian.h
new file mode 100644
index 0000000..e5b1359
--- /dev/null
+++ b/arch/all/compiler-xlc/bits/endian.h
@@ -0,0 +1,9 @@
+/* The IBM C compiler provides the `_BIG_ENDIAN` and/or `__BIG_ENDIAN__`
+ * pre-defined macros to know if the platform is big endian or not. */
+
+#if (defined(_BIG_ENDIAN) && _BIG_ENDIAN) \
+ || (defined(__BIG_ENDIAN__) && __BIG_ENDIAN__)
+# define __BYTE_ORDER __BIG_ENDIAN
+#else
+# define __BYTE_ORDER __LITTLE_ENDIAN
+#endif
diff --git a/arch/all/compiler-xlc/bits/types/primitive.h b/arch/all/compiler-xlc/bits/types/primitive.h
new file mode 100644
index 0000000..727147e
--- /dev/null
+++ b/arch/all/compiler-xlc/bits/types/primitive.h
@@ -0,0 +1,52 @@
+/* Char type. */
+
+#define __CHAR_BIT 8
+#define __CHAR_IS_SIGNED \
+ (defined(__CHAR_SIGNED) && __CHAR_SIGNED) || \
+ (defined(__CHAR_SIGNED__) && __CHAR_SIGNED__)
+
+#define __CHAR_WIDTH ( 8)
+#define __CHAR_MIN (-127 - 1)
+#define __CHAR_MAX (+127)
+#define __UCHAR_MIN (0U)
+#define __UCHAR_MAX (255U)
+
+/* Short type. */
+
+#define __SHRT_WIDTH ( 16)
+#define __SHRT_MIN (-32767 - 1)
+#define __SHRT_MAX (+32767)
+#define __USHRT_MIN (0U)
+#define __USHRT_MAX (65536U)
+
+/* Int type. */
+
+#define __INT_WIDTH ( 32)
+#define __INT_MIN (-2147483647 - 1)
+#define __INT_MAX (+2147483647)
+#define __UINT_MIN (0U)
+#define __UINT_MAX (4294967296U)
+
+/* Long type. */
+
+#if defined(__64BIT__) && __64BIT__
+# define __LONG_WIDTH ( 32)
+# define __LONG_MIN (-2147483647 - 1)
+# define __LONG_MAX (+2147483647)
+# define __ULONG_MIN (0UL)
+# define __ULONG_MAX (4294967296U)
+#else
+# define __LONG_WIDTH ( 64)
+# define __LONG_MIN (-9223372036854775807 - 1)
+# define __LONG_MAX (+9223372036854775807)
+# define __ULONG_MIN (0ULL)
+# define __ULONG_MAX (18446744073709551616ULL)
+#endif
+
+/* Long long type. */
+
+#define __LLONG_WIDTH ( 64)
+#define __LLONG_MIN (-9223372036854775807 - 1)
+#define __LLONG_MAX (+9223372036854775807)
+#define __ULLONG_MIN (0ULL)
+#define __ULLONG_MAX (18446744073709551616ULL)
diff --git a/arch/all/compiler-xlc/info.yml b/arch/all/compiler-xlc/info.yml
new file mode 100644
index 0000000..bfdc8d1
--- /dev/null
+++ b/arch/all/compiler-xlc/info.yml
@@ -0,0 +1,6 @@
+%YAML 1.2
+---
+magic: potatosdk-1.0
+description: Compiler bit headers for IBM XLC.
+requires:
+ compiler: ['IBM', 'XL C/C++']
diff --git a/arch/all/config.yml b/arch/all/config.yml
deleted file mode 100644
index f53047e..0000000
--- a/arch/all/config.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-%YAML 1.2
----
-version: potatosdk-1.0
-arch: ['sh1', 'sh2', 'sh2e', 'sh2a', 'sh2afpu', 'sh2dsp', 'sh3',
-'sh3dsp', 'sh4', 'sh4a', 'sh4aldsp']
-default:
- c: ['all/core', 'all/core-sh', 'all/core-math',
- 'all/compiler-gcc', 'all/compiler-renesas',
- 'all/compiler-sdcc', 'all/compiler-turbo']
- c++: ['all/cpp']
diff --git a/arch/all/core-cocorico/config.yml b/arch/all/core-cocorico/info.yml
index fa1a18f..0a61f1c 100644
--- a/arch/all/core-cocorico/config.yml
+++ b/arch/all/core-cocorico/info.yml
@@ -1,4 +1,4 @@
%YAML 1.2
---
-version: potatosdk-1.0
+magic: potatosdk-1.0
description: Implementation of `stdcocorico.h`.
diff --git a/arch/all/core-sh/config.yml b/arch/all/core-sh/config.yml
deleted file mode 100644
index b2ab2d4..0000000
--- a/arch/all/core-sh/config.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-%YAML 1.2
----
-version: potatosdk-1.0
-description: The core libc, SuperH-specific parts.
-requires:
- arch: ['sh1', 'sh2', 'sh2e', 'sh2a', 'sh2afpu', 'sh2dsp', 'sh3',
- 'sh3dsp', 'sh4', 'sh4a', 'sh4aldsp']
diff --git a/arch/all/core-sh/info.yml b/arch/all/core-sh/info.yml
new file mode 100644
index 0000000..c42a4f9
--- /dev/null
+++ b/arch/all/core-sh/info.yml
@@ -0,0 +1,17 @@
+%YAML 1.2
+---
+magic: potatosdk-1.0
+description: The core libc, SuperH-specific parts.
+requires:
+ arch:
+ - sh1
+ - sh2
+ - sh2e
+ - sh2a
+ - sh2afpu
+ - sh2dsp
+ - sh3
+ - sh3dsp
+ - sh4
+ - sh4a
+ - sh4aldsp
diff --git a/arch/all/core/include/stddef.h b/arch/all/core/include/stddef.h
index fe4a59f..e4c61c0 100644
--- a/arch/all/core/include/stddef.h
+++ b/arch/all/core/include/stddef.h
@@ -5,7 +5,12 @@
#include <cdefs.h>
__BEGIN_NAMESPACE_STD
-#include_bits <types.h>
+#include_bits <types/primitive.h>
+#include_bits <types/exact.h>
+#include_bits <types/least.h>
+#include_bits <types/fast.h>
+#include_bits <types/ptr.h>
+#include_bits <types/max.h>
/* `ptrdiff_t` is the signed integer type of the result of subtracting two
* pointers. */
diff --git a/arch/all/core/config.yml b/arch/all/core/info.yml
index 480f09a..e1b618e 100644
--- a/arch/all/core/config.yml
+++ b/arch/all/core/info.yml
@@ -1,4 +1,4 @@
%YAML 1.2
---
-version: potatosdk-1.0
+magic: potatosdk-1.0
description: The core libc.
diff --git a/arch/all/cpp/config.yml b/arch/all/cpp/config.yml
deleted file mode 100644
index 9ec37d2..0000000
--- a/arch/all/cpp/config.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-%YAML 1.2
----
-version: potatosdk-1.0
-description: The C++ extension.
-requires:
- arch: ['sh3', 'sh4a']
diff --git a/arch/all/cpp/info.yml b/arch/all/cpp/info.yml
new file mode 100644
index 0000000..0c54a32
--- /dev/null
+++ b/arch/all/cpp/info.yml
@@ -0,0 +1,4 @@
+%YAML 1.2
+---
+magic: potatosdk-1.0
+description: The C++ extension.
diff --git a/arch/all/sh-ensigdsp/README.md b/arch/all/ensigdsp-sh/README.md
index efdfbd7..1c8c54e 100644
--- a/arch/all/sh-ensigdsp/README.md
+++ b/arch/all/ensigdsp-sh/README.md
@@ -1,4 +1,4 @@
-# `all/sh-ensigdsp` -- a DSP library for the SuperH architecture
+# `all/ensigdsp-sh` -- a DSP library for the SuperH architecture
This module brings a compatibility layer for the Ensigma SuperH library,
originally made in 1995 by Ensigma, then modified by Renesas as they bought
Ensigma.
diff --git a/arch/all/sh-ensigdsp/include/ensigdsp.h b/arch/all/ensigdsp-sh/include/ensigdsp.h
index c24cdfc..c24cdfc 100644
--- a/arch/all/sh-ensigdsp/include/ensigdsp.h
+++ b/arch/all/ensigdsp-sh/include/ensigdsp.h
diff --git a/arch/all/sh-ensigdsp/config.yml b/arch/all/ensigdsp-sh/info.yml
index 7eff148..22a87aa 100644
--- a/arch/all/sh-ensigdsp/config.yml
+++ b/arch/all/ensigdsp-sh/info.yml
@@ -1,6 +1,6 @@
%YAML 1.2
---
-version: potatosdk-1.0
+magic: potatosdk-1.0
description: Ensigma DSP library.
requires:
arch: ['sh2dsp', 'sh3dsp', 'sh4aldsp']
diff --git a/arch/all/iconv/config.yml b/arch/all/iconv/info.yml
index 1b3a537..8ca1c3d 100644
--- a/arch/all/iconv/config.yml
+++ b/arch/all/iconv/info.yml
@@ -1,4 +1,4 @@
%YAML 1.2
---
-version: potatosdk-1.0
+magic: potatosdk-1.0
description: The generic character conversion interface.
diff --git a/arch/all/info.yml b/arch/all/info.yml
new file mode 100644
index 0000000..dbae5a4
--- /dev/null
+++ b/arch/all/info.yml
@@ -0,0 +1,18 @@
+%YAML 1.2
+---
+magic: potatosdk-1.0
+description: >-
+ All of the files in this platform are common for all platforms.
+default:
+ c:
+ - all/core
+ - all/core-sh
+ - all/compiler-gcc
+ - all/compiler-renesas
+ - all/compiler-sdcc
+ - all/compiler-turbo
+ - all/compiler-xlc
+ - all/math
+ - all/iconv
+ c++:
+ - all/cpp
diff --git a/arch/all/core-math/README.md b/arch/all/math/README.md
index 2baf079..2baf079 100644
--- a/arch/all/core-math/README.md
+++ b/arch/all/math/README.md
diff --git a/arch/all/core-math/include/math.h b/arch/all/math/include/math.h
index 6bfcfa3..6bfcfa3 100644
--- a/arch/all/core-math/include/math.h
+++ b/arch/all/math/include/math.h
diff --git a/arch/all/core-math/include/mathf.h b/arch/all/math/include/mathf.h
index 67e3a7d..67e3a7d 100644
--- a/arch/all/core-math/include/mathf.h
+++ b/arch/all/math/include/mathf.h
diff --git a/arch/all/core-math/config.yml b/arch/all/math/info.yml
index f61d542..1b24119 100644
--- a/arch/all/core-math/config.yml
+++ b/arch/all/math/info.yml
@@ -1,5 +1,5 @@
%YAML 1.2
---
-version: potatosdk-1.0
+magic: potatosdk-1.0
description: The core libc.
out: libm
diff --git a/arch/casiowin/config.yml b/arch/casiowin/config.yml
deleted file mode 100644
index 25caedc..0000000
--- a/arch/casiowin/config.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-%YAML 1.2
----
-version: potatosdk-1.0
-arch: ['sh3', 'sh4a']
-default:
- c: ['casiowin/fxlib', 'casiowin/fxlib-core', 'casiowin/fxlib-crt']
diff --git a/arch/casiowin/easy-grayscales/config.yml b/arch/casiowin/easy-grayscales/info.yml
index b177f68..2f6bc31 100644
--- a/arch/casiowin/easy-grayscales/config.yml
+++ b/arch/casiowin/easy-grayscales/info.yml
@@ -1,6 +1,6 @@
%YAML 1.2
---
-version: potatosdk-1.0
+magic: potatosdk-1.0
description: Compatibility layer with the easy gray library.
requires:
deps: ['casiowin/fxlib']
diff --git a/arch/casiowin/easy-input/config.yml b/arch/casiowin/easy-input/info.yml
index 7259b17..d457904 100644
--- a/arch/casiowin/easy-input/config.yml
+++ b/arch/casiowin/easy-input/info.yml
@@ -1,6 +1,6 @@
%YAML 1.2
---
-version: potatosdk-1.0
+magic: potatosdk-1.0
description: Easy input dialogs.
requires:
deps: ['casiowin/fxlib']
diff --git a/arch/casiowin/fxlib-core/config.yml b/arch/casiowin/fxlib-core/info.yml
index fc5e627..af64c1d 100644
--- a/arch/casiowin/fxlib-core/config.yml
+++ b/arch/casiowin/fxlib-core/info.yml
@@ -1,4 +1,4 @@
%YAML 1.2
---
-version: potatosdk-1.0
+magic: potatosdk-1.0
description: The FX library libc bits.
diff --git a/arch/casiowin/fxlib-crt/config.yml b/arch/casiowin/fxlib-crt/info.yml
index d3ece93..cbb5117 100644
--- a/arch/casiowin/fxlib-crt/config.yml
+++ b/arch/casiowin/fxlib-crt/info.yml
@@ -1,5 +1,5 @@
%YAML 1.2
---
-version: potatosdk-1.0
+magic: potatosdk-1.0
description: The CASIOWIN startup files.
out: crt
diff --git a/arch/casiowin/fxlib/config.yml b/arch/casiowin/fxlib/info.yml
index f242c43..a2368b8 100644
--- a/arch/casiowin/fxlib/config.yml
+++ b/arch/casiowin/fxlib/info.yml
@@ -1,5 +1,5 @@
%YAML 1.2
---
-version: potatosdk-1.0
+magic: potatosdk-1.0
description: The FX library (port).
out: libfx
diff --git a/arch/casiowin/info.yml b/arch/casiowin/info.yml
new file mode 100644
index 0000000..3416f70
--- /dev/null
+++ b/arch/casiowin/info.yml
@@ -0,0 +1,14 @@
+%YAML 1.2
+---
+magic: potatosdk-1.0
+description: >-
+ The name of the OS on CASIO's fx-9860G series calculators, from 2005
+ to nowadays' monochrome calculators.
+arch:
+- sh3
+- sh4a
+default:
+ c:
+ - casiowin/fxlib
+ - casiowin/fxlib-core
+ - casiowin/fxlib-crt
diff --git a/arch/casiowin/libfxsys/config.yml b/arch/casiowin/libfxsys/info.yml
index 8662019..993c6c6 100644
--- a/arch/casiowin/libfxsys/config.yml
+++ b/arch/casiowin/libfxsys/info.yml
@@ -1,6 +1,6 @@
%YAML 1.2
---
-version: potatosdk-1.0
+magic: potatosdk-1.0
description: fx-9860G libfxsys port.
out: libfxsys
deps: ['casiowin/fxlib']
diff --git a/arch/casiowin/monochromelib/config.yml b/arch/casiowin/monochromelib/info.yml
index 1cdc696..59350cf 100644
--- a/arch/casiowin/monochromelib/config.yml
+++ b/arch/casiowin/monochromelib/info.yml
@@ -1,6 +1,6 @@
%YAML 1.2
---
-version: potatosdk-1.0
+magic: potatosdk-1.0
description: Graphics library for the fx-9860G.
out: libmonochrome
deps: ['casiowin/fxlib']
diff --git a/arch/casiowin/revolutionfx/config.yml b/arch/casiowin/revolutionfx/info.yml
index f89649b..2a11ada 100644
--- a/arch/casiowin/revolutionfx/config.yml
+++ b/arch/casiowin/revolutionfx/info.yml
@@ -1,6 +1,6 @@
%YAML 1.2
---
-version: potatosdk-1.0
+magic: potatosdk-1.0
description: RevolutionFX port.
out: librevolutionfx
deps: ['casiowin/fxlib']
diff --git a/arch/info.yml b/arch/info.yml
new file mode 100644
index 0000000..0bab38a
--- /dev/null
+++ b/arch/info.yml
@@ -0,0 +1,19 @@
+%YAML 1.2
+---
+magic: potatosdk-1.0
+version: "0.1-indev"
+description: A modular libc for your platform.
+arch:
+- sh1
+- sh2
+- sh2e
+- sh2a
+- sh2afpu
+- sh2dsp
+- sh3
+- sh3dsp
+- sh4
+- sh4a
+- sh4aldsp
+- x86
+- x86_64
diff --git a/config.yml b/config.yml
deleted file mode 100644
index e5d43af..0000000
--- a/config.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-%YAML 1.2
----
-version: potatosdk-1.0
-type: library
-lib-version: "0.1-indev"
-description: A modular libc for your platform.
-modules: './arch'
diff --git a/configure b/configure
index d253caa..da6bab3 100755
--- a/configure
+++ b/configure
@@ -2,7 +2,7 @@
cd "$(dirname "$0")"
# Use the Python tool.
-tools/configure.py "$@"
+/usr/bin/env python3 tools/configure.py "$@"
exit $?
# End of file.
diff --git a/tools/Build/__gnu__.py b/tools/Build/__gnu__.py
deleted file mode 100755
index 91f860d..0000000
--- a/tools/Build/__gnu__.py
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/env python3
-""" GNU tools specific utilities. """
-
-from .__util__ import getutil
-__all__ = ['getgnu']
-
-# Supported arches.
-__prefixes = [
- (['sh1', 'sh2', 'sh2e', 'sh2a', 'sh2afpu', 'sh2dsp', 'sh3',
- 'sh3dsp', 'sh4', 'sh4a', 'sh4aldsp'],
- ['sh', 'sh1', 'sh2', 'sh2a', 'sh2e', 'sh2eb', 'sh2le',
- 'sh3', 'sh3e', 'sh3eb', 'sh3le', 'sh3ele',
- 'sh4', 'sh4a', 'sh4eb', 'sh4le']),
- (['i286', 'i386', 'i486', 'i586', 'i686'],
- ['x86', 'i286', 'i386', 'i486', 'i586', 'i686'])
-]
-
-def getgnu(arch, tool):
- for arches, prefixes in __prefixes:
- if not arch in arches:
- continue
- return getutil(tool,
- ['%s-elf-%s' %(pre, tool) for pre in prefixes] +
- ['%s-elf-%s.exe'%(pre, tool) for pre in prefixes])
- raise Exception
diff --git a/tools/Build/__util__.py b/tools/Build/__util__.py
deleted file mode 100755
index 8b4003a..0000000
--- a/tools/Build/__util__.py
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/env python3
-
-import os
-__all__ = ["getutil"]
-
-# The path and path management.
-__path = os.environ['PATH'].split(os.pathsep) if 'PATH' in os.environ else []
-def add_tooldir(tooldir):
- global __path
- if tooldir:
- __path.append(tooldir)
-
-# Tool management.
-def getutil(name, tools):
- # Check that the tools is a list.
- if type(tools) != list:
- tools = [tools]
-
- # Look through the directories in the paths.
- for udir in __path:
- l = os.listdir(udir)
- for tool in tools:
- if tool in l:
- return os.path.join(udir, tool)
-
- # There is no such utility :(
- raise Exception(("'%s' not found, please add the utility directory "
- + "in your path,\nor use the `--tooldir` option.") % name)
-
-# Path management.
-def addpath(udir):
- PATH.append(udir)
-if 'PATH' in os.environ:
- PATH = os.environ['PATH'].split(os.pathsep)
-
-# End of file.
diff --git a/tools/FORMATS.md b/tools/FORMATS.md
new file mode 100644
index 0000000..22563e4
--- /dev/null
+++ b/tools/FORMATS.md
@@ -0,0 +1,128 @@
+# Information, configuration and cache file formats.
+libcarrot uses YAML-encoded configurations. Each configuration written by
+a human should start with `magic: potatosdk-1.0`.
+
+## Global configuration
+The global configuration is in `arch/info.yml`. It has the following
+fields:
+
+- `version`: the project version;
+- `description`: the project description;
+- `arch`: the supported architectures.
+
+An example global configuration would be:
+
+ magic: potatosdk-1.0
+ description: >
+ The best C library in the world.
+ version: 1.14-indev
+ arch:
+ - sh3
+ - sh4a
+ - x86
+ - i386
+ - i486
+ - i686
+ - x86_64
+
+## Platform configuration
+Each platform (even `all`, which is the "common" platform for all code)
+have the following fields in their configuration:
+
+- `description`: a description of the platform;
+- `default`: the default packages for each language;
+- `requires/arch` (opt.): subset of architectures the platform supports;
+
+An example configuration is the following:
+
+ magic: potatosdk-1.0
+ description: >-
+ That incredible platform we should all go on.
+ default:
+ c:
+ - myplatform/somepackage
+ - myplatform/someotherpackage
+ c++:
+ - myplatform/thatotherpackagetoo
+ - anotherone/thatpackagefromthatotherplatform
+ requires:
+ arch:
+ - sh3
+ - sh4a
+
+Notice that C defaults are added into the C++ defaults too.
+
+## Module configuration
+Each module has a configuration too, with the following fields:
+
+- `description`: a description of the module;
+- `deps`: the module dependencies (language-related dependencies excluded);
+- `conflicts`: the module(s) this module shouldn't be selected with;
+- `requires/arch`: subset of the architectures the module supports;
+- `requires/compiler`: subset of C/C++ compilers the module supports;
+
+An example configuration is the following:
+
+ magic: potatosdk-1.0
+ description: some incredible module bringing future to your home.
+ deps:
+ - all/some_general_useful_library
+ conflicts:
+ - myplatform/some_anonymous_hater
+ - myplatform/some_module_that_defines_the_same_thing_as_me
+ requires:
+ arch:
+ - sh3
+ - sh4a
+ compiler:
+ - GNU/GCC
+ - Renesas/SHC
+
+## Configuration
+The library should only be configured once at a time, then built any number
+of times you want (several builds per configuration are possible, and even
+encouraged). It is generally stored in `.config.yml`, generated (not man-made),
+and contains the following fields:
+
+- `module`: the modules to build;
+- `tools/cc`: the C compiler to use;
+- `tools/cc_params`: the C compiler parameters;
+- `tools/cxx`: the C++ compiler to use;
+- `tools/cxx_params`: the C++ compiler parameters;
+- `tools/asm`: the assembler to use;
+- `tools/asm_params`: the assembler parameters;
+- `tools/pack`: the packer to use;
+- `tools/pack_params`: the packer parameters.
+
+Parameters depend on the utility class and on the sort of things it wants to
+save. An example user configuration is:
+
+ magic: potatosdk-1.0
+ modules:
+ - all/core
+ - all/core-math
+ - all/core-sh
+ - all/compiler-gcc
+ - casiowin/fxlib
+ - casiowin/fxlib-core
+ - casiowin/fxlib-crt
+ tools:
+ asm: GNU/AS
+ asm_params:
+ flags: [--isa=sh3, --big]
+ path: /opt/fx/bin/sh3eb-elf-as
+ cc: GNU/GCC
+ cc_params:
+ flags: [-Wall, -Wextra, -Wno-attributes, -O2, -nostartfiles,
+ -fno-builtin-function, -mhitachi, -fomit-frame-pointer, -m3, -mb]
+ path: /opt/fx/bin/sh3eb-elf-gcc
+ std: [c89, c99, c11]
+ cxx: GNU/GCC
+ cxx_params:
+ flags: [-Wall, -Wextra, -Wno-attributes, -O2, -nostartfiles,
+ -fno-builtin-function, -mhitachi, -fomit-frame-pointer, -m3, -mb]
+ path: /opt/fx/bin/sh3eb-elf-gcc
+ std: [c++98, c++11, c++14, c++17]
+ pack: GNU/AR
+ pack_params:
+ path: /opt/fx/bin/sh3eb-elf-ar
diff --git a/tools/Internals/__init__.py b/tools/Internals/__init__.py
new file mode 100644
index 0000000..52b44c9
--- /dev/null
+++ b/tools/Internals/__init__.py
@@ -0,0 +1,8 @@
+#!/usr/bin/env python3
+import sys
+
+from .exceptions import *
+from .tools import *
+from .module import gather_modules, list_modules
+
+# End of file.
diff --git a/tools/Internals/exceptions.py b/tools/Internals/exceptions.py
new file mode 100644
index 0000000..5b2d6d7
--- /dev/null
+++ b/tools/Internals/exceptions.py
@@ -0,0 +1,150 @@
+#!/usr/bin/env python3
+""" Exceptions that can occur in the libcarrot custom build tools.
+ To manage them correctly, you should use the `do_main()` function.
+"""
+
+import sys
+
+#*****************************************************************************#
+# Main definitions #
+#*****************************************************************************#
+# Base classes.
+# - `PotatoException` is the main exception class, which stops the program
+# as soon as it is raised.
+# - `PotatoWarning` is the main warning class, which just prints a message
+# when it is raised.
+
+class PotatoException(Exception):
+ ''' The base class for PotatoSDK exceptions. '''
+ ret = 1
+class PotatoWarning(Exception):
+ ''' The base class for PotatoSDK warnings. '''
+ pass
+
+# Function to raise one of these.
+
+def Raise(exc):
+ ''' Raise either a local exception or warning. '''
+ try:
+ raise exc
+ except PotatoWarning as e:
+ print("WARNING: %s"%str(e))
+
+# Main function wrapper.
+
+def do_main(main_func):
+ ''' The main function wrapper. '''
+ try:
+ main_func()
+ exit(0)
+ except SilentException:
+ exit(1)
+ except PotatoException as e:
+ print("ERROR: %s"%str(e), file=sys.stderr)
+ exit(e.ret)
+#*****************************************************************************#
+# Exceptions definitions #
+#*****************************************************************************#
+class SilentException(PotatoException):
+ """ The silent exception, for exiting silently (usually because the
+ error messages have already been put, eventually by sub-commands. """
+
+ def __init__(self):
+ super(SilentException, self).__init__("")
+
+class UnsupportedLanguageException(PotatoException):
+ """ One of the given languages were unsupported. """
+
+ ret = 2
+ def __init__(self, lang):
+ super(UnsupportedLanguageException, self).__init__("""\
+Language '%s' is unsupported."""%lang)
+
+class UnsupportedArchException(PotatoException):
+ """ The given arch was unsupported. """
+
+ ret = 2
+ def __init__(self, arch):
+ super(UnsupportedArchException, self).__init__("""\
+Architecture '%s' is unsupported."""%arch)
+
+class UnsupportedPlatformException(PotatoException):
+ """ The given platform was unsupported. """
+
+ ret = 2
+ def __init__(self, platform):
+ super(UnsupportedPlatformException, self).__init__("""\
+Platform '%s' is unsupported."""%platform)
+
+class UpdatedModuleException(PotatoException):
+ """ The configuration of a module has been updated since the
+ last user configuration. """
+
+ ret = 2
+ def __init__(self, name):
+ super(UpdatedModuleException, self).__init__("""\
+Module '%s' config has been updated since last configuration.
+Please re-configure."""%name)
+
+class UpdatedPlatformException(PotatoException):
+ """ The configuration of a platform has been updated since the
+ last user configuration. """
+
+ ret = 2
+ def __init__(self, name):
+ super(UpdatedPlatformException, self).__init__("""\
+Platform '%s' config has been updated since last configuration.
+Please re-configure."""%name)
+
+class UpdatedGlobalException(PotatoException):
+ """ The global configuration has been updated since the
+ last user configuration. """
+
+ ret = 2
+ def __init__(self, name):
+ super(UpdatedGlobalException, self).__init__("""\
+Global config has been updated since last configuration.
+Please re-configure."""%name)
+
+class UnresolvedDependencyException(PotatoException):
+ """ A module dependency could not be resolved. """
+
+ ret = 2
+ def __init__(self, name, from_modules):
+ super(UnresolvedDependencyException, self).__init__("""\
+Dependency '%s' from '%s' does not exist or could not be loaded!""" \
+ %(name, "', '".join(from_modules)))
+
+class InvalidCommandException(PotatoException):
+ """ The given command was unknown. """
+
+ ret = 2
+ def __init__(self, command):
+ super(InvalidCommandException, self).__init__("""\
+Unknown command '%s'."""%command)
+
+class ToolNotFoundException(PotatoException):
+ """ A tool was not found! """
+
+ ret = 2
+ def __init__(self, name):
+ super(ToolNotFoundException, self).__init__("""\
+Tool '%s' was not found for this architecture, please add the utility
+directory to your path, or use the `--tooldir` configuration option."""%name)
+
+class UnsupportedArchForModuleException(PotatoWarning):
+ """ A module doesn't support an architecture. """
+
+ def __init__(self, name, arch):
+ super(UnsupportedArchForModuleException, self).__init__("""\
+'%s' additional module doesn't support '%s' arch!"""%(name, arch))
+
+class UnsupportedCompilerForModuleException(PotatoWarning):
+ """ A module doesn't support a compiler. """
+
+ def __init__(self, name, compiler):
+ super(UnsupportedCompilerForModuleException, self).__init__("""\
+'%s' additional module doesn't support '%s' compiler from '%s'!""" \
+ %(name, compiler[1], compiler[0]))
+
+# End of file.
diff --git a/tools/Module/__init__.py b/tools/Internals/module.py
index 3886782..0ef9159 100755
--- a/tools/Module/__init__.py
+++ b/tools/Internals/module.py
@@ -3,9 +3,76 @@
import os, sys
import yaml
-from sys import stderr
-from .object import SourceModule
+from .exceptions import *
+
+# The module class.
+class SourceModule:
+ ''' The source module class.
+ `root` is the modules root.
+ `name` is the module category and name, e.g. `casiowin/fxlib`. '''
+ def __init__(self, root, name):
+ ''' Initialize the class, gather the information from the FS. '''
+ nameparts = name.split('/') + ['info.yml']
+ configpath = os.path.join(root, *nameparts)
+ config = yaml.load(open(configpath).read())
+
+ # Get the meta information.
+ self.root = root
+ self.name = name
+ nameparts = name.split('/')
+ self.__root = os.path.join(self.root, *nameparts)
+ self.description = config['description']
+ self.compiler = config['compiler'] if 'compiler' in config else []
+ self.deps = config['deps'] if 'deps' in config else []
+ self.conflicts = config['conflicts'] if 'conflicts' in config else []
+ self.out = config['out'] if 'out' in config else 'libc'
+ self.mtim = os.path.getmtime(configpath)
+ if 'requires' in config:
+ req = config['requires']
+ self.compiler = req['compiler'] if 'compiler' in req else None
+ self.arch = req['arch'] if 'arch' in req else []
+ else:
+ self.compiler = None
+ self.arch = []
+
+ # Get non-initialized options from the parent configuration.
+ platform_config_path = \
+ os.path.join(root, name.split('/')[0], 'info.yml')
+ try: cfile = open(platform_config_path)
+ except: True
+ else:
+ platform_config = yaml.load(cfile); del cfile
+ if not 'arch' in config and 'arch' in platform_config:
+ self.arch = platform_config['arch']
+
+ def getpath(self, *elements):
+ ''' Get the complete path of a subdirectory. '''
+ return os.path.join(self.__root, *elements)
+
+ def getfiles(self, directory, extensions):
+ ''' Get the files list. '''
+
+ # Check if it is the object directory.
+ if directory == 'obj':
+ root = os.path.join(directory, self.name, '')
+ else:
+ root = os.path.join(self.root, self.name, directory, '')
+
+ # Get the source files.
+ files = []
+ for r, _, filenames in os.walk(root):
+ for f in filenames:
+ pos = f.find('.')
+ if pos < 0 and None in extensions:
+ continue
+ elif pos >= 0 and not f[pos + 1:] in extensions:
+ continue
+ name, ext = f, None
+ if pos >= 0: ext = name[pos + 1:]
+ files.append(os.path.join(r[len(root):], name))
+
+ return files
# Gather a list of modules.
def gather_modules(root, lst, mtim):
@@ -15,15 +82,12 @@ def gather_modules(root, lst, mtim):
for name in lst:
module = SourceModule(root, name)
if module.mtim > mtim:
- print("""\
-Module '%s' data has been updated since configuration.
-Please re-configure."""%name, file=sys.stderr)
- return 1, []
+ Raise(UpdatedPlatformException(name))
modules[name] = module
return 0, modules
# List modules.
-def list_modules(root, arch, compiler = 'GNU/GCC', \
+def list_modules(root, arch, compiler = ('GNU', 'GCC'), \
languages = ['c', 'c++'], platform = None, additional_modules = []):
''' Get the list of modules to make, based on the platform agnostic and
platform-specific language defaults, the architecture, the platform,
@@ -37,31 +101,32 @@ def list_modules(root, arch, compiler = 'GNU/GCC', \
for name in set(additional_modules):
module = SourceModule(root, name)
if arch and module.arch and not arch in module.arch:
- print("Warning: '%s' additional module doesn't support '%s' arch!" \
- %(name, arch), file=stderr)
+ Raise(UnsupportedArchForModuleException(name, arch))
continue
if module.compiler and not compiler in module.compiler:
- print("Warning: '%s' additional module doesn't support '%s' compiler!" \
- %(name, tools.get('compiler')), file=stderr)
+ Raise(UnsupportedCompilerForModuleException(name, compiler))
continue
modules[name] = module
# Now, we shall get the language defaults for the platform,
# using the platform-specific configuration files.
default = {}
- with open(os.path.join(root, 'all', 'config.yml')) as f:
+ with open(os.path.join(root, 'all', 'info.yml')) as f:
config = yaml.load(f.read())
if 'default' in config:
for key in config['default']:
if not key in default: default[key] = []
default[key] += config['default'][key]
if platform:
- with open(os.path.join(root, platform, 'config.yml')) as f:
+ try:
+ f = open(os.path.join(root, platform, 'info.yml'))
config = yaml.load(f.read())
if 'default' in config:
for key in config['default']:
if not key in default: default[key] = []
default[key] += config['default'][key]
+ except FileNotFoundError:
+ Raise(UnsupportedPlatformException(platform))
# Add C dependencies to C++ dependencies.
if not 'c++' in default:
@@ -93,8 +158,7 @@ def list_modules(root, arch, compiler = 'GNU/GCC', \
try:
module = SourceModule(root, name, default)
except Exception:
- print("Error: Dependency '%s' from '%s' does not exist!"
- %(name, "', '".join(dep[1])), file=stderr)
+ Raise(UnresolvedDependencyException(name, dep[1]))
blacklist.append(name)
continue
if (not module.arch or arch in module.arch) \
diff --git a/tools/makeinc.py b/tools/Internals/suph.py
index ffa308f..251401c 100755
--- a/tools/makeinc.py
+++ b/tools/Internals/suph.py
@@ -3,57 +3,7 @@
import os, yaml
from sys import stderr
-from argparse import ArgumentParser
-#*****************************************************************************#
-# Parse the arguments #
-#*****************************************************************************#
-# Define the argument parser.
-argparser = ArgumentParser(prog='makeinc.py',
- description="""
-makeinc.py is libcarrot's C super-preprocessor.
-It adds preprocessor operations such as `#include_bits`, and tries to optimize
-the files for production.
-""")
-argparser.add_argument('out',
- help='the output include folder')
-argparser.add_argument('path', nargs='*',
- help='the include directories')
-argparser.add_argument('--bits', action='append',
- help='add to the bits path', default=[])
-argparser.add_argument('--cache', default='.makeinc-cache',
- help='path to the makeinc dependencies cache')
-
-# Parse the arguments.
-args = argparser.parse_args()
-
-# Correct the path.
-incdirs = []
-for arg in args.path:
- incdirs += arg.split(':')
-args.path = incdirs
-
-# Correct the bits path.
-bits = []
-for arg in args.bits:
- bits += arg.split(':')
-args.bits = bits
-
-# Open the cache.
-try:
- with open(args.cache) as f:
- cache = yaml.load(f.read())
-except:
- cache = {}
-# (magic word)
-if not 'ver' in cache:
- cache = {'ver': 'bits-krieg'}
-if not 'bits' in cache:
- cache['bits'] = {}
-if not 'inc' in cache:
- cache['inc'] = {}
-ics = {}
-bts = {}
-newbts = {}
+
#*****************************************************************************#
# Useful functions #
#*****************************************************************************#
@@ -276,54 +226,72 @@ def make_header(base, name, out_path):
ics[name] = {'base': base, 'bits': bdeps,
'mtim': os.path.getmtime(out_path)}
-#*****************************************************************************#
-# Make the folder #
-#*****************************************************************************#
-# Update the new bits.
-for name in cache['bits']:
- newbts[name] = look_for_bits(name)
-
-# List includes.
-dirs = []
-names = []
-for base in args.path:
+
+
+
+def suph(incdir, incdirs, bitdirs):
+ # Open the cache.
+ try:
+ with open(args.cache) as f:
+ cache = yaml.load(f.read())
+ except:
+ cache = {}
+ # (magic word)
+ if not 'ver' in cache:
+ cache = {'ver': 'bits-krieg'}
+ if not 'bits' in cache:
+ cache['bits'] = {}
+ if not 'inc' in cache:
+ cache['inc'] = {}
+ ics = {}
+ bts = {}
+ newbts = {}
+
+ # Update the new bits.
+ for name in cache['bits']:
+ newbts[name] = look_for_bits(name)
+
+ # List includes.
+ dirs = []
+ names = []
+ for base in args.path:
+ lst = []
+ base = os.path.join(base, '')
+ for root, _, nms in os.walk(base):
+ lst += [os.path.join(root, name)[len(base):] for name in nms \
+ if name[0] != '.' and (name[-2:].lower() == '.h' \
+ or name[-4:].lower() != '.hpp' or name.find('.') < 0)]
+ for nm in lst:
+ if not nm in names:
+ dirs.append(base)
+ names.append(nm)
+ continue
+ print('ERROR: "%s" is in "%s" and "%s", exiting"' \
+ %(nm, dirs[names.index(nm)], base))
+ exit(1)
+
+ # Make the output include directory.
+ try: os.makedirs(args.out)
+ except FileExistsError: pass
+
+ # Check for the intruders.
lst = []
- base = os.path.join(base, '')
- for root, _, nms in os.walk(base):
- lst += [os.path.join(root, name)[len(base):] for name in nms \
- if name[0] != '.' and (name[-2:].lower() == '.h' \
- or name[-4:].lower() != '.hpp' or name.find('.') < 0)]
+ for root, _, nms in os.walk(args.out):
+ lst += [os.path.join(root, name)[len(os.path.join(args.out, '')):] \
+ for name in nms]
for nm in lst:
if not nm in names:
- dirs.append(base)
- names.append(nm)
- continue
- print('ERROR: "%s" is in "%s" and "%s", exiting"' \
- %(nm, dirs[names.index(nm)], base))
- exit(1)
+ os.remove(os.path.join(args.out, nm))
+
+ # Make the includes.
+ for path in zip(dirs, names):
+ localpath = os.path.join(args.out, path[1])
+
+ make_header(path[0], path[1], localpath)
-# Make the output include directory.
-try: os.makedirs(args.out)
-except FileExistsError: pass
-
-# Check for the intruders.
-lst = []
-for root, _, nms in os.walk(args.out):
- lst += [os.path.join(root, name)[len(os.path.join(args.out, '')):] \
- for name in nms]
-for nm in lst:
- if not nm in names:
- os.remove(os.path.join(args.out, nm))
-
-# Make the includes.
-for path in zip(dirs, names):
- localpath = os.path.join(args.out, path[1])
-
- make_header(path[0], path[1], localpath)
-
-# Save the cache.
-with open(args.cache, 'w') as cout:
- print(yaml.dump({'ver': 'bits-krieg', 'bits': bts, 'inc': ics},
- version=(1, 2), width=60), file=cout, end='')
+ # Save the cache.
+ with open(args.cache, 'w') as cout:
+ print(yaml.dump({'ver': 'bits-krieg', 'bits': bts, 'inc': ics},
+ version=(1, 2), width=60), file=cout, end='')
# End of file.
diff --git a/tools/Build/__init__.py b/tools/Internals/tools/__init__.py
index 4c2577c..af725b6 100755
--- a/tools/Build/__init__.py
+++ b/tools/Internals/tools/__init__.py
@@ -2,6 +2,7 @@
import os, sys, functools as ft
from subprocess import call
+from .__util__ import *
from .gnu_gcc import *
from .gnu_as import *
@@ -10,7 +11,6 @@ from .renesas_shc import *
from .renesas_asmsh import *
from .renesas_optlnk import *
-from .__util__ import add_tooldir as add_dir
#*****************************************************************************#
# Super-preprocessor #
#*****************************************************************************#
@@ -24,27 +24,36 @@ def suph(incdir, incdirs, bitdirs):
# Main list #
#*****************************************************************************#
__c_compilers = {
- ('gnu', 'gcc'): GNU_GCC,
- ('renesas', 'shc'): Renesas_SHC,
+ ('GNU', 'GCC'): GNU_GCC,
+ ('Renesas', 'SHC'): Renesas_SHC,
+# ('Hitachi', 'SHC'): Renesas_SHC,
+# ('IBM', 'XL C/C++'): IBM_XLC,
+# ('SDCC', 'SDCC'): SDCC_SDCC,
+# ('Borland', 'Turbo C'): Borland_TurboC,
}
__cxx_compilers = {
- ('gnu', 'gcc'): GNU_GCC,
- ('renesas', 'shc'): Renesas_SHC,
+ ('GNU', 'GCC'): GNU_GCC,
+ ('Renesas', 'SHC'): Renesas_SHC,
+# ('Hitachi', 'SHC'): Renesas_SHC,
+# ('IBM', 'XL C/C++'): IBM_XLC,
+# ('Borland', 'Turbo C++'): Borland_TurboCpp,
}
__assemblers = {
- ('gnu', 'as'): GNU_AS,
- ('renesas', 'asmsh'): Renesas_Asmsh,
+ ('GNU', 'as'): GNU_AS,
+ ('Renesas', 'Asmsh'): Renesas_Asmsh,
+# ('Hitachi', 'Asmsh'): Renesas_Asmsh,
}
__c_assemblers = {
- ('gnu', 'gcc'): GNU_GCC
+ ('GNU', 'GCC'): GNU_GCC
}
__archivers = {
- ('gnu', 'ar'): GNU_AR,
- ('renesas', 'optlnk'): Renesas_OptLnk,
+ ('GNU', 'ar'): GNU_AR,
+ ('Renesas', 'Optlnk'): Renesas_OptLnk,
+# ('Hitachi', 'Optlnk'): Renesas_OptLnk,
}
#*****************************************************************************#
# Interact with the tools before using them. #
@@ -55,44 +64,50 @@ __compiler = '(none)'
# Find tools.
def find(languages, arch):
- cp = __c_compilers['gnu', 'gcc']['getparams']('cc', arch)
- cxxp = __cxx_compilers['gnu', 'gcc']['getparams']('cxx', arch)
- asmcp = __c_assemblers['gnu', 'gcc']['getparams']('asmc', arch)
- asp = __assemblers['gnu', 'as']['getparams']('asm', arch)
- arp = __archivers['gnu', 'ar']['getparams']('pack', arch)
+ cc_name = ('GNU', 'GCC')
+ cxx_name = ('GNU', 'GCC')
+ asm_name = ('GNU', 'as')
+ asmc_name = ('GNU', 'GCC')
+ pack_name = ('GNU', 'ar')
+
+ cp = __c_compilers[cc_name]['getparams']('cc', arch)
+ cxxp = __cxx_compilers[cxx_name]['getparams']('cxx', arch)
+ asmcp = __c_assemblers[asmc_name]['getparams']('asmc', arch)
+ asp = __assemblers[asm_name]['getparams']('asm', arch)
+ arp = __archivers[pack_name]['getparams']('pack', arch)
return {
- 'cc': 'GNU/GCC', 'cc_params': cp,
- 'cxx': 'GNU/GCC', 'cxx_params': cxxp,
- 'asm': 'GNU/AS', 'asm_params': asp,
- 'asmc': 'GNU/GCC', 'asmc_params': asmcp,
- 'pack': 'GNU/AR', 'pack_params': arp}
+ 'cc': cc_name, 'cc_params': cp,
+ 'cxx': cxx_name, 'cxx_params': cxxp,
+ 'asm': asm_name, 'asm_params': asp,
+ 'asmc': asmc_name, 'asmc_params': asmcp,
+ 'pack': pack_name, 'pack_params': arp}
# Setup the tools.
def setup(data):
global __tools, __compiler
- cc = data['cc'].split('/')
- cxx = data['cxx'].split('/')
- asm = data['asm'].split('/')
- asmc = data['asmc'].split('/')
- pck = data['pack'].split('/')
+ cc = data['cc']
+ cxx = data['cxx']
+ asm = data['asm']
+ asmc = data['asmc']
+ pck = data['pack']
__tools['cc'] = \
- ft.partial(__c_compilers[cc[0].lower(), cc[1].lower()]['cc'],
+ ft.partial(__c_compilers[cc[0], cc[1]]['cc'],
data['cc_params'])
__compiler = data['cc']
__tools['cxx'] = \
- ft.partial(__cxx_compilers[cxx[0].lower(), cxx[1].lower()]['cxx'],
+ ft.partial(__cxx_compilers[cxx[0], cxx[1]]['cxx'],
data['cxx_params'])
__tools['asm'] = \
- ft.partial(__assemblers[asm[0].lower(), asm[1].lower()]['asm'],
+ ft.partial(__assemblers[asm[0], asm[1]]['asm'],
data['asm_params'])
__tools['asmc'] = \
- ft.partial(__c_assemblers[asmc[0].lower(), asmc[1].lower()]['asmc'],
+ ft.partial(__c_assemblers[asmc[0], asmc[1]]['asmc'],
data['asmc_params'])
__tools['pack'] = \
- ft.partial(__archivers[pck[0].lower(), pck[1].lower()]['pack'],
+ ft.partial(__archivers[pck[0], pck[1]]['pack'],
data['pack_params'])
# Get an information.
@@ -106,7 +121,7 @@ def get(key):
# Extensions
'obj_ext': 'o',
- 'lib_ext': 'a',
+ 'lib_ext': 'a',
'cc_ext': ['c', 'CC'],
'cxx_ext': cpp_ext,
'cpp_ext': cpp_ext,
@@ -150,3 +165,5 @@ def pack(lib, objs):
print("No packer has been setup!")
exit(1)
return __tools['pack'](lib, objs)
+
+# End of file.
diff --git a/tools/Internals/tools/__util__.py b/tools/Internals/tools/__util__.py
new file mode 100755
index 0000000..8ec1e79
--- /dev/null
+++ b/tools/Internals/tools/__util__.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python3
+
+import os
+from ..exceptions import *
+
+#*****************************************************************************#
+# Path management #
+#*****************************************************************************#
+# The path and path management.
+__path = os.environ['PATH'].split(os.pathsep) if 'PATH' in os.environ else []
+def add_tooldir(tooldir):
+ global __path
+ if tooldir:
+ __path.append(tooldir)
+
+# Tool management.
+def getutil(name, tools):
+ # Check that the tools is a list.
+ if type(tools) != list:
+ tools = [tools]
+
+ # Look through the directories in the paths.
+ for udir in __path:
+ l = os.listdir(udir)
+ for tool in tools:
+ if tool in l:
+ return os.path.join(udir, tool)
+
+ # There is no such utility :(
+ Raise(ToolNotFoundException(name))
+#*****************************************************************************#
+# GNU-specific utilities #
+#*****************************************************************************#
+# Supported arches.
+__gnu_prefixes = [
+ (['sh1', 'sh2', 'sh2e', 'sh2a', 'sh2afpu', 'sh2dsp', 'sh3',
+ 'sh3dsp', 'sh4', 'sh4a', 'sh4aldsp'],
+ ['sh', 'sh1', 'sh2', 'sh2a', 'sh2e', 'sh2eb', 'sh2le',
+ 'sh3', 'sh3e', 'sh3eb', 'sh3le', 'sh3ele',
+ 'sh4', 'sh4a', 'sh4eb', 'sh4le']),
+ (['i286', 'i386', 'i486', 'i586', 'i686'],
+ ['x86', 'i286', 'i386', 'i486', 'i586', 'i686'])
+]
+
+def getgnu(arch, tool):
+ for arches, prefixes in __gnu_prefixes:
+ if not arch in arches:
+ continue
+ return getutil(tool,
+ ['%s-elf-%s' %(pre, tool) for pre in prefixes] +
+ ['%s-elf-%s.exe'%(pre, tool) for pre in prefixes])
+ Raise(ToolNotFoundException(tool))
+
+# End of file.
diff --git a/tools/Build/formats.py b/tools/Internals/tools/formats.py
index 7d880ab..7d880ab 100644
--- a/tools/Build/formats.py
+++ b/tools/Internals/tools/formats.py
diff --git a/tools/Build/gnu_ar.py b/tools/Internals/tools/gnu_ar.py
index f7ea422..b4a2fb3 100644
--- a/tools/Build/gnu_ar.py
+++ b/tools/Internals/tools/gnu_ar.py
@@ -3,12 +3,32 @@
import os
import tempfile
-from subprocess import call
-from .__gnu__ import getgnu
+from subprocess import call, check_output
+from .__util__ import *
def __getparams(typ, arch):
''' Get the params. '''
- gar = getgnu(arch, 'ar')
+
+ # Get the utility
+ try: gar = getgnu(arch, 'ar')
+ except ToolNotFoundException:
+ gar = getutil('ar', ['ar', 'ar.exe'])
+ env = os.environ.copy()
+ env['LANG'] = 'en_US'
+ out = check_output([gar, '--help'], env=env).decode()
+ lns = [line for line in out.splitlines() if len(line.split(':')) == 3 \
+ and line.split(':')[1] == ' supported targets']
+ if len(lns) != 1:
+ Raise(ToolNotFoundException('ar'))
+ targets = lns[0].split(':')[2].split()
+ target_found = False
+ for target in targets:
+ target = '_'.join(target.split('-')[1:])
+ if target == arch:
+ target_found = True
+ break
+ if not target_found:
+ Raise(ToolNotFoundException('ar'))
return {'path': gar}
diff --git a/tools/Build/gnu_as.py b/tools/Internals/tools/gnu_as.py
index f4bf6dc..efe7e08 100644
--- a/tools/Build/gnu_as.py
+++ b/tools/Internals/tools/gnu_as.py
@@ -2,14 +2,22 @@
''' The GNU assembler. '''
import os
-from subprocess import call
-from .__gnu__ import getgnu
+from subprocess import call, check_output
+from .__util__ import *
def __getparams(typ, arch):
''' Get the parameters. '''
# Get the utility.
- gas = [getgnu(arch, 'as')]
+ try: gas = [getgnu(arch, 'as')]
+ except ToolNotFoundException:
+ gas = getutil('as', ['as', 'as.exe'])
+ env = os.environ.copy()
+ env['LANG'] = 'en_US'
+ out = check_output([gas, '--version'], env=env).decode()
+ bfd = out.splitlines()[-1].split('`')[1].split("'")[0]
+ if bfd.split('-')[0] != arch:
+ Raise(ToolNotFoundException('as'))
# Get the flags.
flags = []
diff --git a/tools/Build/gnu_gcc.py b/tools/Internals/tools/gnu_gcc.py
index 53b439c..d849a50 100755
--- a/tools/Build/gnu_gcc.py
+++ b/tools/Internals/tools/gnu_gcc.py
@@ -2,9 +2,9 @@
''' The GNU C Compiler. '''
import os
-from subprocess import call, DEVNULL
+from subprocess import call, check_output, DEVNULL
from tempfile import mkstemp
-from .__gnu__ import getgnu
+from .__util__ import *
def __teststd(path, standards):
''' Test if GCC supports those standards using the `-std` option. '''
@@ -31,7 +31,12 @@ def __getparams(typ, arch):
''' Get the parameters. '''
# Get the compiler path.
- gcc = getgnu(arch, 'gcc')
+ try: gcc = getgnu(arch, 'gcc')
+ except ToolNotFoundException:
+ gcc = getutil('gcc', ['gcc', 'gcc.exe'])
+ bfd = check_output([gcc, '-dumpmachine']).decode().strip()
+ if bfd.split('-')[0] != arch:
+ Raise(ToolNotFoundException('gcc'))
# Get the compilation flags.
# TODO: use `-ffreestanding` (implies `-fno-builtin`?)
diff --git a/tools/Build/renesas_asmsh.py b/tools/Internals/tools/renesas_asmsh.py
index 48e21d1..8fff98c 100755
--- a/tools/Build/renesas_asmsh.py
+++ b/tools/Internals/tools/renesas_asmsh.py
@@ -3,7 +3,7 @@
import os, tempfile
from subprocess import call
-from .__util__ import getutil
+from .__util__ import *
def __getparams(typ, arch):
''' Get the parameters. '''
diff --git a/tools/Build/renesas_optlnk.py b/tools/Internals/tools/renesas_optlnk.py
index 30c749f..50fe02a 100755
--- a/tools/Build/renesas_optlnk.py
+++ b/tools/Internals/tools/renesas_optlnk.py
@@ -3,7 +3,7 @@
import os, tempfile
from subprocess import call
-from .__util__ import getutil
+from .__util__ import *
def __getparams(typ, arch):
''' Get the parameters. '''
diff --git a/tools/Build/renesas_shc.py b/tools/Internals/tools/renesas_shc.py
index 86ad128..836f781 100755
--- a/tools/Build/renesas_shc.py
+++ b/tools/Internals/tools/renesas_shc.py
@@ -3,13 +3,13 @@
import os
from subprocess import call
-from .__util__ import getutil
+from .__util__ import *
def __getparams(typ, arch):
''' Get the parameters. '''
- if arch[:2] == 'sh':
- raise Exception
+ if arch[:2] != 'sh':
+ raise UnsupportedArchException(arch)
shc = getutil('shc', ['shc.exe'])
CPU = arch.upper()
diff --git a/tools/Module/object.py b/tools/Module/object.py
deleted file mode 100644
index c75fe37..0000000
--- a/tools/Module/object.py
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/usr/bin/env python3
-''' Source module class. '''
-
-import os, yaml
-
-# The module class.
-class SourceModule:
- ''' The source module class.
- `root` is the modules root.
- `name` is the module category and name, e.g. `casiowin/fxlib`. '''
- def __init__(self, root, name):
- ''' Initialize the class, gather the information from the FS. '''
- nameparts = name.split('/') + ['config.yml']
- configpath = os.path.join(root, *nameparts)
- config = yaml.load(open(configpath).read())
-
- # Get the meta information.
- self.root = root
- self.name = name
- nameparts = name.split('/')
- self.__root = os.path.join(self.root, *nameparts)
- self.description = config['description']
- self.compiler = config['compiler'] if 'compiler' in config else []
- self.deps = config['deps'] if 'deps' in config else []
- self.conflicts = config['conflicts'] if 'conflicts' in config else []
- self.out = config['out'] if 'out' in config else 'libc'
- self.mtim = os.path.getmtime(configpath)
- if 'requires' in config:
- req = config['requires']
- self.compiler = req['compiler'] if 'compiler' in req else None
- self.arch = req['arch'] if 'arch' in req else []
- else:
- self.compiler = None
- self.arch = []
-
- # Get non-initialized options from the parent configuration.
- platform_config_path = \
- os.path.join(root, name.split('/')[0], 'config.yml')
- try: cfile = open(platform_config_path)
- except: True
- else:
- platform_config = yaml.load(cfile); del cfile
- if not 'arch' in config and 'arch' in platform_config:
- self.arch = platform_config['arch']
-
- def getpath(self, *elements):
- ''' Get the complete path of a subdirectory. '''
- return os.path.join(self.__root, *elements)
-
- def getfiles(self, directory, extensions):
- ''' Get the files list. '''
-
- # Check if it is the object directory.
- if directory == 'obj':
- root = os.path.join(directory, self.name, '')
- else:
- root = os.path.join(self.root, self.name, directory, '')
-
- # Get the source files.
- files = []
- for r, _, filenames in os.walk(root):
- for f in filenames:
- pos = f.find('.')
- if pos < 0 and None in extensions:
- continue
- elif pos >= 0 and not f[pos + 1:] in extensions:
- continue
- name, ext = f, None
- if pos >= 0: ext = name[pos + 1:]
- files.append(os.path.join(r[len(root):], name))
-
- return files
diff --git a/tools/README.md b/tools/README.md
deleted file mode 100644
index f795abc..0000000
--- a/tools/README.md
+++ /dev/null
@@ -1,56 +0,0 @@
-# Configuration file format
-libcarrot uses YAML-encoded configurations. Each configuration written by
-a human should start with `version: potatosdk-1.0`.
-
-## Platform configuration
-Each platform (even `all`, which is the "common" platform) have the following
-members in their configuration:
-
-- `description`: a description of the platform;
-- `arch`: list of architectures the platform supports;
-- `default`: the default packages for each language.
-
-An example configuration is the following:
-
- version: potatosdk-1.0
- description: that incredible platform we should all go on.
- arch: ['sh3', 'sh4a']
- default:
- c: ['myplatform/somepackage', 'myplatform/someotherpackage']
- c++: ['myplatform/thatotherpackagetoo']
-
-## Module configuration
-Each module has a configuration too, with:
-
-- `description`: a description of the module;
-- `arch`: list of the architecture the module supports;
-- `lang`: the language(s) the module is coded in;
-- `compiler`: the compiler(s) the module is made for;
-- `deps`: the dependencies of the module (don't include what's required with
- the language, it will be added automatically);
-- `conflicts`: the module(s) the current module shouldn't be selected with.
-
-An example configuration is the following:
-
- version: potatosdk-1.0
- description: some incredible module bringing future to your home.
- lang: 'c'
- deps: ['all/some_general_library_for_the_arch']
- conflicts: ['myplatform/some_anonymous_hater']
-
-## Configuration cache
-The library should only be configured once, then built any number of times
-you want. The configuration cache, stored in `<project>/current.yml`,
-and generated (not man-made), contains the following members:
-
-- `arch`: the architecture for which to build;
-- `utils`: the utilities;
-
-An example configuration is the following:
-
- version: potatosdk-1.0
- arch: 'sh3'
- platform: null
- modules:
- utils:
- cc: {'id': 'gcc', 'path': '/opt/fx/bin/sh3eb-elf-gcc'}
diff --git a/tools/config.template.yml b/tools/config.template.yml
deleted file mode 100644
index 99d8c90..0000000
--- a/tools/config.template.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-version: potatosdk-1.0
-description: A wonderful package.
-lang: 'c++'
-arch: ['sh3', 'sh4a']
-deps: ['all/core', 'all/sh-intrinsic']
-conflicts: ['this/package', 'this/one-two']
diff --git a/tools/configure.py b/tools/configure.py
index 6fbc77a..cf9fdb8 100755
--- a/tools/configure.py
+++ b/tools/configure.py
@@ -1,25 +1,38 @@
#!/usr/bin/env python3
''' Configure how to build libcarrot. '''
-import os, yaml
-from argparse import ArgumentParser
+import os, sys, platform, shlex, argparse
from subprocess import call
-import Build as tools
-from Module import list_modules
+import yaml
+from Internals import *
+
+# Internal function to get the platform.
+def __getplatform():
+ return platform.system().lower()
+
+# Internal function to get the architecture.
+def __getarch():
+ name = platform.machine()
+ return name
#*****************************************************************************#
-# Arguments decoding #
+# Set up the arguments parser #
#*****************************************************************************#
-argparser = ArgumentParser(prog='configure.py')
+argparser = argparse.ArgumentParser(prog='configure.py')
-argparser.add_argument('-v', '--version', dest='version', action='store_true',
- help="show the version message and exit")
+# Main arguments (`-h, --help` is automatic).
+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")
argparser.add_argument('-o', '--output', dest='out',
- default=os.path.join(os.getcwd(), 'build.yml'),
+ default=os.path.join(os.getcwd(), '.config.yml'),
help='the output configuration file')
-argparser.add_argument('--arch', dest='arch', default='sh3',
+
+# Configuration-related arguments.
+argparser.add_argument('--arch', dest='arch', default=__getarch(),
help='architecture for which to build')
-argparser.add_argument('--platform', dest='platform', default=None,
+argparser.add_argument('--platform', dest='platform', default=__getplatform(),
help='platform (OS) for which to build')
argparser.add_argument('--languages', dest='lang', default='c',
help='languages that libcarrot is supposed to support')
@@ -29,62 +42,115 @@ argparser.add_argument('--add', dest='modules',
argparser.add_argument('--tooldir', dest='tooldir', default=None,
help='directory with the toolchain in it')
-# Parse the arguments.
-args = argparser.parse_args()
-
-# Get the additional modules.
-addm = []
-for arg in args.modules:
- addm += arg.split(',')
-args.modules = addm
-
-# Get the main configuration.
-root = os.path.join(os.path.dirname(__file__), '..')
-config = yaml.load(open(os.path.join(root, "config.yml")).read())
-
-# Check the version.
-if args.version:
- print(config['lib-version'])
- exit(0)
-
-# Get the languages.
-lang = set(args.lang.split(','))
-if any(not x in ["c", "c++"] for x in lang):
- print("error: one of the language was unsupported.")
- exit(1)
-args.lang = lang
-#*****************************************************************************#
-# Prepare for the configuration #
-#*****************************************************************************#
-# Clean the repository.
-ret = call(['python3', os.path.join('tools', 'make.py'), 'mrproper'])
-if ret: exit(ret)
-#*****************************************************************************#
-# Get the configuration #
-#*****************************************************************************#
-# Find the tools.
-found_tools = tools.find(args.lang, args.arch)
-tools.setup(found_tools)
-
-# Check the main configuration.
-if 'arch' in config and not args.arch in globalconfig['arch']:
- print("error: unsupported arch for libcarrot")
- exit(1)
-mroot = os.path.normpath(os.path.join(root, config['modules']))
-
-# List the modules.
-modules = list_modules(mroot, args.arch, tools.get('compiler'), args.lang,
- args.platform, args.modules)
-if not modules:
- print("error: no modules, check that your config is correct.")
- exit(1)
+# Reserved arguments (from the glibc configure script).
+argparser.add_argument('--maintainer', action='store_true',
+ help=argparse.SUPPRESS)
+argparser.add_argument('-C', '--config-cache', action='store_true',
+ help=argparse.SUPPRESS)
+argparser.add_argument('--cache-file', help=argparse.SUPPRESS)
+
+argparser.add_argument('--prefix', help=argparse.SUPPRESS)
+argparser.add_argument('--exec-prefix', help=argparse.SUPPRESS)
+
+argparser.add_argument('--bindir', help=argparse.SUPPRESS)
+argparser.add_argument('--sbindir', help=argparse.SUPPRESS)
+argparser.add_argument('--libexecdir', help=argparse.SUPPRESS)
+argparser.add_argument('--sysconfdir', help=argparse.SUPPRESS)
+argparser.add_argument('--sharedstatedir', help=argparse.SUPPRESS)
+argparser.add_argument('--localstatedir', help=argparse.SUPPRESS)
+argparser.add_argument('--libdir', help=argparse.SUPPRESS)
+argparser.add_argument('--includedir', help=argparse.SUPPRESS)
+argparser.add_argument('--oldincludedir', help=argparse.SUPPRESS)
+argparser.add_argument('--datarootdir', help=argparse.SUPPRESS)
+argparser.add_argument('--datadir', help=argparse.SUPPRESS)
+argparser.add_argument('--infodir', help=argparse.SUPPRESS)
+argparser.add_argument('--localedir', help=argparse.SUPPRESS)
+argparser.add_argument('--mandir', help=argparse.SUPPRESS)
+argparser.add_argument('--docdir', help=argparse.SUPPRESS)
+argparser.add_argument('--htmldir', help=argparse.SUPPRESS)
+argparser.add_argument('--dvidir', help=argparse.SUPPRESS)
+argparser.add_argument('--pdfdir', help=argparse.SUPPRESS)
+argparser.add_argument('--psdir', help=argparse.SUPPRESS)
+
+argparser.add_argument('--disable-option-checking', action='store_true',
+ help=argparse.SUPPRESS)
+argparser.add_argument('--disable-sanity-checks', action='store_true',
+ help=argparse.SUPPRESS)
+argparser.add_argument('--enable-shared', action='store_true',
+ help=argparse.SUPPRESS)
+argparser.add_argument('--enable-profile', action='store_true',
+ help=argparse.SUPPRESS)
+argparser.add_argument('--disable-timezone-tools', action='store_true',
+ help=argparse.SUPPRESS)
+argparser.add_argument('--enable-hardcoded-path-in-tests', action='store_true',
+ help=argparse.SUPPRESS)
+argparser.add_argument('--enable-stackguard-randomization',
+ action='store_true', help=argparse.SUPPRESS)
+argparser.add_argument('--enable-lock-elision', choices=('yes', 'no'),
+ default='no', help=argparse.SUPPRESS)
+argparser.add_argument('--disable-hidden-plt', action='store_true',
+ help=argparse.SUPPRESS)
#*****************************************************************************#
# Write the configuration #
#*****************************************************************************#
-with open(args.out, "w") as out:
- print(yaml.dump({"version": "potatosdk-1.0", "tools": found_tools,
- "modules": modules},
- version=(1, 2), width=60), file=out, end='')
+def main():
+ # Parse the arguments.
+ args = argparser.parse_args()
+
+ # Get the languages.
+ args.lang = set(args.lang.split(','))
+ for lang in args.lang:
+ if not lang in ['c', 'c++']:
+ Raise(UnsupportedLanguageException(lang))
+
+ # Get the additional modules.
+ addm = []
+ for arg in args.modules:
+ addm += arg.split(',')
+ args.modules = addm
+
+ # Clean the repository.
+ ret = call(['python3', os.path.join('tools', 'make.py'), 'mrproper'])
+ if ret: Raise(SilentException)
+
+ # Get the roots.
+ root = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
+ mroot = os.path.join(root, 'arch')
+
+ # Check the main configuration.
+ globalconfig = yaml.load(open(os.path.join('arch', 'info.yml')).read())
+ if args.version:
+ print(globalconfig['version'])
+ return
+
+ # Get the rest.
+ mroot = os.path.normpath(os.path.join('arch'))
+ if 'arch' in globalconfig and not args.arch in globalconfig['arch']:
+ print("error: unsupported arch for libcarrot")
+ exit(1)
+
+ # List the modules.
+ modules = list_modules(mroot, args.arch, tools.get('compiler'), args.lang,
+ args.platform, args.modules)
+ if not modules:
+ print("error: no modules, check that your config is correct.")
+ exit(1)
+
+ # Find the tools.
+ found_tools = tools.find(args.lang, args.arch)
+ tools.setup(found_tools)
+
+ # Write the configuration.
+ with open(args.out, "w") as out:
+ print(yaml.dump({"magic": "potatosdk-1.0", "tools": found_tools,
+ "modules": modules, "orig": ' '.join(map(shlex.quote, sys.argv))},
+ version=(1, 2), width=60), file=out, end='')
+
+ # Tell the user we're done.
+ if not args.silent:
+ print("Configuration loaded, you can make now.")
+
+if __name__ == "__main__":
+ do_main(main)
-print("Configuration loaded, you can make now.")
# End of file.
diff --git a/tools/make.py b/tools/make.py
index cce6d2e..922b7d5 100755
--- a/tools/make.py
+++ b/tools/make.py
@@ -2,12 +2,11 @@
''' The PotatoSDK is an SDK using different toolchains to compile libcarrot. '''
import os, traceback
-import yaml
from argparse import ArgumentParser
from shutil import rmtree, copyfile
-from Module import list_modules, gather_modules
-import Build as tools
+import yaml
+from Internals import *
#*****************************************************************************#
# Parse arguments #
#*****************************************************************************#
@@ -21,9 +20,6 @@ argparser.add_argument('-i', '--include', dest='incdir', default='include',
argparser.add_argument('--obj', dest='objdir', default='obj',
help='the generated objects directory')
argparser.add_argument('command', help='the command to execute')
-
-# Parse the arguments, get the configuration.
-args = argparser.parse_args()
#*****************************************************************************#
# Commands #
#*****************************************************************************#
@@ -212,20 +208,25 @@ def build(args):
#*****************************************************************************#
# Main interface. #
#*****************************************************************************#
-# Make the command.
-args.command = args.command.lower()
-if args.command in ['build']:
- ret = build(args)
-elif args.command in ['clean']:
- ret = clean(args)
-elif args.command in ['mrproper']:
- ret = mrproper(args)
-elif args.command in ['re', 'rebuild']:
- ret = clean(args)
- if not ret: build(args)
-else:
- print("Unknown command '%s'."%args.command)
- ret = 1
-
-exit(ret)
+def main():
+ # Parse the arguments, get the configuration.
+ args = argparser.parse_args()
+
+ # Make the command.
+ args.command = args.command.lower()
+ if args.command in ['build']:
+ build(args)
+ elif args.command in ['clean']:
+ clean(args)
+ elif args.command in ['mrproper']:
+ mrproper(args)
+ elif args.command in ['re', 'rebuild']:
+ clean(args)
+ build(args)
+ else:
+ raise InvalidCommandException(args.command)
+
+if __name__ == "__main__":
+ do_main(main)
+
# End of file.