pcb-rnd knowledge pool

 

Packaging state for pcb-rnd scripting

script_pkg by Tibor 'Igor2' Palinkas on 2018-11-16

Tags: roadmap, scripting, packaging, fungw, awk, libmawk

node source

 

 

Abstract: Before pcb-rnd scripting can really take off, we need to get OS packaged versions of pcb-rnd have scripting available. For that we need a few dependencies also packaged by the same OS. This pool node keeps track on the progress.

 

1. Roadmap: dependencies

Dependency of packages and goals

2. Current state

  genht fungw libmawk estutter
Debian 1.0.0 not yet 1.0.0 ?
Fedora 1.0.1 not yet 1.0.2 ?
Manjaro not yet not yet not yet ?
Openbsd not yet not yet not yet ?

Key:

3. What needs packaging

Must have: fungw

Release state: 1.0.0 released . For packaging, please read the packager's doc .

The ultimate goal is having fungw packaged. Fungw has two parts: a core (trunk/libfungw), that is also shipped with pcb-rnd; this is responsible for providing the function call dispatching and argument type conversions in a language agnostic way. The other part is language bindings (trunk/libfungwbind) to specific scripting languages.

The core is small and relatively static. It has a well defined, limited scope. It can be implemented and left in "finished state" for long. The binding part is bigger and is more dynamic: new script languages come, new versions of existing languages appear, and we need more bindings.

The core part is pure c89, with only one dependency: genht. That together with the small size made it easy to include it in pcb-rnd as src_3rd/. The binding part, however, has extensive dependencies: it depends on at least as many external packages as many bindings we have.

However, the binding part is dynamic in two senses. First, the user does not need to have all bindings built. If the user wants to script applications (such as pcb-rnd) only in lua and tcl, it's enough to build the lua and the tcl bindings. Each binding is a separate little .so file, also a puplug plugin (for those apps that want to load them through puplug).

The second sense it is dynamic is derived from the first: once fungw core is installed and the application (e.g. pcb-rnd) is compiled, it is possible to change the language bindings. Most notably: new bindings may appear without having to recompile fungw core or the applications using fungw.

This means packaging fungw needs to be done in many small packages:

Must have: genht

Release state: stable: 1.0.1

Genht is a tiny, public domain hash table implementation. Fungw uses it to maintain tables of registered engines, objects and functions. Packaging genht is super-simple, as it has only a very few files installed and absolutely no dependency (it's plain c89/c99).

Shall have: libmawk

Release state: stable: 1.0.2

Awk is a real simple scripting language. The original syntax, pre-gnu-extensions, is real small. Any user who have seen 2 or 3 scripting languages already can learn awk in half a day. And I mean learn it A..Z: unlike with modern languages, it's not an infinitely large domain of paradigms, syntax sugar, different new incompatible versions and 3rd party libs. It does not have its own package manager for awk scripts.

Another property that is very relevant to us: imagine what it would look like to script in C. Imagine a new, C scripting language, where you have functions and variables and printf, but you don't need to worry about memory allocation, types, type conversions. The awk syntax is very close to that. For those who are also developer of pcb-rnd, this means learning C89 and awk together is much cheaper than learning C89 and python or learning C89 and lua, etc.

Finally, libmawk, the awk implementation we use for embedded scripting, has no external dependencies. It's plain C89, doesn't even depend on genht. It is as portable as a script language can get. Unlike with python or perl, you won't need to spend long hours on dependency hunting, autotools version matching and worry about whether not having gcc would make a difference.

Thus the policy in pcb-rnd is that any official example for scripting first happens in awk. Which makes it essential to ship a scriptable pcb-rnd with libmawk available.

Packaging libmawk should be relatively easy: it is small, with no dependencies and not too many files installed.

Optional: estutter

Release state: stable: 1.0.0

Lisp scripting has a long tradition in the CAD/EDA world. Therefor I decided to make sure fungw has support for some lisp dialect.

Unfortunately it is extremely hard to find popular lisp/scheme implementations with suitable API (e.g. that allows dynamic loading/unloading multiple scripts). After doing some research and (way too many) testing, I concluded the only sustainable way is to have support for non-popular implementations that at least have suitable API.

We now have support for two such implementations: funlisp and estutter.

From the two, estutter is the bigger (about 9k sloc total), and the more universal. Estutter is a dialect that incorporates elements from both common lisp and scheme. It supports multiple paradigms and a lot of fancy things, including OOP, closures, tail recursion optimization, some CLOS, and a SETF architecture.

To suit the needs for users coming from commercial EDA, we should have estutter packaged to offer lisp/scheme scripting.