summaryrefslogtreecommitdiffhomepage
path: root/CMakeLists.txt
AgeCommit message (Collapse)Author
2022-09-09ubus: add toplevel constants for ubus status codesJo-Philipp Wich
Add constants for ubus status codes to the toplevel module scope in order to avoid the need for magic values in the code. Suggested-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-03-31build: remove legacy json-c checkJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-03-31build: add polyfills for older libjson-c versionsJo-Philipp Wich
The libjson-c versions commonly shipped by Debian and Ubuntu lack unsigned 64bit integer support and a number of extended API functions. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-03-23build: fix symlink install targetJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-03-22build: only stage ucc symlink if compile support is enabledJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-03-21main: turn ucode into multicall executableJo-Philipp Wich
Turn the ucode executable into a multicall binary and select default flags based on the name it was invoked with. Introduce two new symlinks "ucc" and "utpl" which start ucode in compile and template mode respectively. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-03-15build: consolidate CMakeLists.txt and cover OS X deviationsJo-Philipp Wich
- Add OS X specific linker flags - Default disable Linux specific modules on OS X - Simplify json-c discovery - Fix uloop_timeout_remaining64() detection Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-03-02lib: introduce uloop bindingJo-Philipp Wich
The uloop module allows controlling the uloop event loop and supports adding timeouts, processes and file descriptors. Example: #!ucode -RS let fs = require("fs"); let uloop = require("uloop"); let fd1 = fs.popen("echo 1; sleep 1; echo 2; sleep 1; echo 3", "r"); let fd2 = fs.popen("echo 4; sleep 1; echo 5; sleep 1; echo 6", "r"); function fd_read_callback(flags) { if (flags & uloop.ULOOP_READ) { let line = this.handle().read("line"); printf("Line from fd <%s/%d>: <%s>\n", this, this.fileno(), trim(line)); } } uloop.init(); uloop.timer(1500, function() { printf("Timeout after 1500ms\n"); }); uloop.handle(fd1, fd_read_callback, uloop.ULOOP_READ); uloop.handle(fd2, fd_read_callback, uloop.ULOOP_READ); uloop.process("date", [ "+%s" ], { LC_ALL: "C" }, function(exitcode) { printf("Date command exited with code %d\n", exitcode); }); uloop.run(); Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-01-18syntax: drop legacy syntax supportJo-Philipp Wich
Drop support for the `local` keyword and `delete` function calls. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-01-18build: support building without compile capabilitiesJo-Philipp Wich
Introduce a new default enable CMake option "COMPILE_SUPPORT" which allows to disable source code compilation in the ucode interpreter. Such an interpreter will only be able to load precompiled ucode files. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-01-18types: add initial infrastructure for function serializationJo-Philipp Wich
- Introduce a new "program" entity which holds the list of functions created during compilation - Instead of storing pointers to the in-memory function representation in the constant list, store the index of the function within the program's function list - When loading functions from the constant list, retrieve the function by index from the program entity Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-01-04treewide: rework numeric value handlingJo-Philipp Wich
- Parse integer literals as unsigned numeric values in order to be able to represent the entire unsigned 64bit value range - Stop parsing minus-prefixed integer literals as negative numbers but treat them as separate minus operator followed by a positive integer instead - Only store unsigned numeric constants in bytecode - Rework numeric comparison logic to be able to handle full 64bit unsigned integers - If possible, yield unsigned 64 bit results for additions - Simplify numeric value conversion API - Compile code with -fwrapv for defined signed overflow semantics Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-10-31lib: introduce struct libraryJo-Philipp Wich
Introduce a new "struct" library which is a port of the Python 3.10 struct module with a reduced set of API functions. It supports the same format patterns and conversions while providing the following methods: struct = require('struct'); buf = struct.pack("fmt", args...); values = struct.unpack("fmt", buf); struct_inst = struct.new("fmt"); buf = struct_inst.pack(args...); values = struct_inst.unpack(buf); Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-10-22lib: introduce resolver libraryJo-Philipp Wich
This adds a simple, UDP-only DNS resolver library mimicking the operation of the extended busybox nslookup applet. Simply querying a domain name will perform A + AAAA resolving by default: # ucode -mresolv -Rs 'printf("%.J\n", resolv.query("example.com"))' { "example.com": { "A": [ "93.184.216.34" ], "AAAA": [ "2606:2800:220:1:248:1893:25c8:1946" ] } } Passing IP addresses will automatically perform PTR requests: # ucode -mresolv -Rs 'printf("%.J\n", resolv.query("8.8.8.8"))' { "8.8.8.8.in-addr.arpa": { "PTR": [ "dns.google" ] } } # ucode -mresolv -Rs 'printf("%.J\n", resolv.query("2001:4860:4860::8888"))' { "8.8.8.8.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.6.8.4.0.6.8.4.1.0.0.2.ip6.arpa": { "PTR": [ "dns.google" ] } } Additional options for query type and nameserver selection can be passed via a second optional options dictionary: # ucode -mresolv -Rs 'printf("%.J\n", resolv.query([ "openwrt.org", "example.org", "doesnotexist.tld" ], { type: [ "A", "AAAA", "MX" ], nameserver: [ "1.1.1.1", "8.8.4.4" ], timeout: 5000, retries: 2, edns_maxsize: 4096 }))' { "openwrt.org": { "A": [ "139.59.209.225" ], "MX": [ [ 10, "util-01.infra.openwrt.org" ] ], "AAAA": [ "2a03:b0c0:3:d0::1af1:1" ] }, "example.org": { "A": [ "93.184.216.34" ], "AAAA": [ "2606:2800:220:1:248:1893:25c8:1946" ], "MX": [ [ 0, "." ] ] }, "doesnotexist.tld": { "rcode": "NXDOMAIN" } } Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-09-21lib: introduce Linux 802.11 netlink bindingJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-09-15lib: introduce Linux route netlink bindingJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-07-11treewide: harmonize function namingJo-Philipp Wich
- Ensure that most functions follow the subject_verb naming schema - Move type related function from value.c to types.c - Rename value.c to vallist.c Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-07-11examples: add libucode usage examplesJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-07-11treewide: move header files into dedicated directoryJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-07-11build: install header filesJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-07-11build: split into libucode and ucode cliJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-05-25main: simplify REQUIRE_SEARCH_PATH initializationJo-Philipp Wich
Do not require parsing in C, pre-split string in cmake and pass it as command separated string array down to CPP, so that it can be interpolated directly into a char *path[] array. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-05-19build: let require search patch default to CMAKE_INSTALL_PREFIXJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-05-18compiler, lexer: add NO_LEGACY define to disable legacy syntax featuresJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-05-14build: lower minimum required CMake version to v3.13Jo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-04-27treewide: ISO C / pedantic complianceJo-Philipp Wich
- Shuffle typedefs to avoid need for non-compliant forward declarations - Fix non-compliant empty struct initializers - Remove use of braced expressions - Remove use of anonymous unions - Avoid `void *` pointer arithmetic - Fix several warnings reported by gcc -pedantic mode and clang 11 compilation Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-04-27build: output error messages on test failuresJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-04-25treewide: rework internal data type systemJo-Philipp Wich
Instead of relying on json_object values internally, use custom types to represent the different ucode value types which brings a number of advantages compared to the previous approach: - Due to the use of tagged pointers, small integer, string and bool values can be stored directly in the pointer addresses, vastly reducing required heap memory - Ability to create circular data structures such as `let o; o = { test: o };` - Ability to register custom `tostring()` function through prototypes - Initial mark/sweep GC implementation to tear down circular object graphs on VM deinit The change also paves the way for possible future extensions such as constant variables and meta methods for custom ressource types. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-04-23tests: add more testsPetr Štetiar
* add cram based tests * test under either valgrind or LLVM sanitizers * add libFuzzer template Signed-off-by: Petr Štetiar <ynezz@true.cz>
2021-04-23cmake: do not output binaries into lib directoryPetr Štetiar
It doesn't work properly with out of tree builds etc. Signed-off-by: Petr Štetiar <ynezz@true.cz>
2021-04-23cmake: enable extra compiler checksPetr Štetiar
Let's enforce additional automatic checks enforced by the compiler in order to catch possible errors during compilation. Signed-off-by: Petr Štetiar <ynezz@true.cz>
2021-04-23cmake: fix includes and librariesPetr Štetiar
So it can be built out of the tree. Signed-off-by: Petr Štetiar <ynezz@true.cz>
2021-04-23cmake: make 3.0 minimum versionPetr Štetiar
Probably using 3.0+ features anyway and should silence following warning: CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake. Update the VERSION argument <min> value or use a ...<max> suffix to tell CMake that the project does not need compatibility with older versions. Signed-off-by: Petr Štetiar <ynezz@true.cz>
2021-02-17treewide: rewrite ucode interpreterJo-Philipp Wich
Replace the former AST walking interpreter implementation with a single pass bytecode compiler and a corresponding virtual machine. The rewrite lays the groundwork for a couple of improvements with will be subsequently implemented: - Ability to precompile ucode sources into binary byte code - Strippable debug information - Reduced runtime memory usage Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-11-19treewide: rebrand to ucodeJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-02build: install extension libraries as wellJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-11lib: move math functions to new moduleJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-11lib: implement uci pluginJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-10build: test whether json_object_array_shrink() is availableJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-10lib: add ubus moduleJo-Philipp Wich
Also move shared library output files to the lib/ directory Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-02lib: introduce filesystem moduleJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-02eval, lib: add loadable module infrastructureJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-08-24treewide: remove unneeded libubox dependencyJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-08-21Initial commitJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>