Unbloated coding resources

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#41 Post by technosaurus »

Here are github projects to replace larger versions:
pulseaudio
systemd
logind
udev
libevent
alsa
x11
xserver
glibc over musl
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
RetroTechGuy
Posts: 2947
Joined: Tue 15 Dec 2009, 17:20
Location: USA

#42 Post by RetroTechGuy »

technosaurus wrote:Here are github projects to replace larger versions:
[...]
Thanks Techno... Gonna reply just so I can "pin" this to my list... ;-)
[url=http://murga-linux.com/puppy/viewtopic.php?t=58615]Add swapfile[/url]
[url=http://wellminded.net63.net/]WellMinded Search[/url]
[url=http://puppylinux.us/psearch.html]PuppyLinux.US Search[/url]

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#43 Post by musher0 »

Interesting.

But
1) how up-to-date are those projects?

2) how compatible are they with any Puppy?

3) how do you integrate them with any Puppy? One of those authors mention a
way to do a debian install of his project. That is neither fun nor funny. :(

BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#44 Post by wiak »

musher0 wrote: 3) how do you integrate them with any Puppy? One of those authors mention a
way to do a debian install of his project. That is neither fun nor funny. :(

BFN.
One of the good things about the DebianDogs being on Puppy forum is that they contain simple tools for extracting and creating debs. Nowadays I normally create my own packages in deb format, since it is so universal (and easy to change to dotpet format as explained next).

However, in most any DebianDog I can extract the deb (a simple filemanager right-click option) and then, once booted back into a Puppy system, run dir2pet, or similar on it, to produce a dotpet. Works fine for simple packages/programs anyway. For more complicated cases you may need to check you have all the correct package dependencies in Puppy prior to producing the dotpet, but that is usually not a difficult task.

I suspect there is a simple deb2pet package available on Pups too (though I can't remember) but sometimes it is better to extract and examine deb package first, to see if you need anything extra to make desired dotpet creation work. Of course, I realise many Pups will install debs anyway, but again success or failure may vary if the deb contents aren't extracted and checked first.

wiak

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#45 Post by technosaurus »

I've been working on a next generation version of puppy for a while that will incorporate many of the lightweight libraries but I am so unsatisfied with the X and C libraries, that I got sidetracked on reimplementing those first. Both will be single header libraries designed for static builds of multi call binaries. Once those are complete, I will put together the MCB with an Xserver, window manager, terminal, editor, browser, web server (for slitaz style configuration) and a few basic utilities. Each program will be a single c file that doesn't share any function names with the others so that all compilers will be able to do whole program optimization for the entire MCB. I haven't made most of the work public yet, but check out the github repositories that I have starred to get an idea... mostly single header libraries if there is one and only permissive licenses.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#46 Post by vovchik »

Dear technosaurus,

You are always doing useful and interesting things. Thanks. I learn from your code...

With kind regards,
vovchik

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#47 Post by technosaurus »

Many of the projects I have linked are single header C libraries, while others are one header file and one .c file. These work a bit different than the traditional C project.

Normally a compiler command line would look something like

$CC main.c -lmylib

For the 2-file projects (1 *.h and *.c file), the header is used just as in any other context, but it its possible to use the *.c file (or even its compiled object file) where one would normally link in a library. (Let me know if this description isn't clear enough)

Ex. $CC main.c mylib.c

The single header libraries are slightly different. You still use it as a regular header file, but it contains a conditionally compiled section that is the equivalent of the *.c file. This must be compiled once and only once by defining the appropriate macro in an appropriate place. You can either define the macro before its #include in the source or use the command line.

Ex. $CC -DMYLIB_IMPLEMENTATION main.c

Here is a basic template for single header c libraries

Code: Select all

//filename.h
//author, copyright
//license
//description, etc...

#ifndef FILENAME_H
#define FILENAME_H

//Define feature test macros
#define _GNU_SOURCE 1

//local includes
#include "my_other_header.h"

//global includes
#include <stdio.h>

//Define config macros
#define Y(...) __VA_ARGS__
#define N(...)
//Followed by config by config options
#define USE_FOO Y
#define USE_BAR N

//Pragmas?

//Constant macros
#define PI 3.14f

//function-like macros
#define X(...) __VA_ARGS__

//enums
enum {A,B,C};

//forward struct declarations
struct G;

//forward typedef declarations;
typedef struct G G;

//typedefs
typedef unsigned char u8;

//struct definitions
struct G {int a,b,c;};

//external variables
extern int extern_global_int;

//function prototypes

//externally visible static inline functions

#endif //FILENAME_H

///above here would go in header (*.h) file, below in C (*.c) file.

#ifdef FILENAME_IMPLEMENTATION
#ifndef FILENAME_IMPLEMENTED
#define  FILENAME_IMPLEMENTED

//Anything above that you don't want to be externally visible can  be here instead

//exported globals: To access, should have corresponding extern in *.h
int global_int; // Are you really sure you need this?

//static (local) variables
static int static_int;

//local function implementations
static inline int get0(void){return 0;}

//exported function implementations
int main_like(int argc, char **argv){
	int x=get0();
	return x;
}
#endif FILENAME_IMPLEMENTED
#endif //FILENAME_IMPLEMENTATION
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

lmemsm
Posts: 51
Joined: Wed 27 Jun 2012, 15:01

picogl

#48 Post by lmemsm »

technosaurus wrote:FWIW I never tracked down the (proprietary?) MorphOS sources either; however, there are a couple of forks with some improvements tinysdgl and picogl IIRC
Some members of the Syllable forum did a comparison of the various forks of tinygl and recommended picogl. I started with the source for it and added some features from other forks. I've been working on adding new features to the code to improve OpenGL compatibility as time allows. I can get Emilia pinball working with it. If anyone's interested, I'd love to compare notes on updating picogl and improving it.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

Re: picogl

#49 Post by technosaurus »

lmemsm wrote:If anyone's interested, I'd love to compare notes on updating picogl and improving it.
Do you have a github project page?
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

lmemsm
Posts: 51
Joined: Wed 27 Jun 2012, 15:01

Re: picogl

#50 Post by lmemsm »

technosaurus wrote:Do you have a github project page?
I do, but I really don't use it much. You'll find links to what I'm working on here for now:
http://www.distasis.com/cpp/lmports.htm

Haven't uploaded my picogl modifications yet, because I'm in the middle of making some further changes.

I'm trying to see if I can do anything to improve texture-mapping, but haven't had much luck so far. I did add some basic support for color blending. I'm also using it with GL_FEATURE_RENDER_BITS = 32 so that alpha blending works. I have SDL 2.x back-end support (as well as the SDL 1.x support which was already available) so I can use it with any systems that work with either version of SDL. Was just investigating an issue with RGB settings. If I run the gears demo program with picogl the colors look similar to white/yellow/cyan. The OpenGL glxgears demo has colors red/green/blue. I tried running the picogl gears example program with an OpenGL backend instead of picogl and the colors are still white/yellow/cyan. Am wondering if it's some kind of endian issue with color conversion. With all the different projects and lightweight operating systems that experimented with tinygl or picogl, I'm finding it hard to believe no one would have noticed an issue like that before. Has anyone else ever noticed this? Going to see if I can make the colors better match what I see with OpenGL and then will try to upload what I have to date.

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#51 Post by BarryK »

The developer of LittlevGL has put a "help wanted" flag on one of the issues, "need evdev mouse and keyboard":

https://github.com/littlevgl/lvgl/issues

I recently started to use LittlevGL, after technosaurus advised a list of contenders for GUI apps running on Linux framebuffer.

I narrowed it down to LittlevGL (LVGL), and found it to be very nice, capable of creating very small static apps, that I compiled with uClibc and musl.

Extremely efficient handling of fonts and images, with no external library deps, only libc/uclibc/musl. Or, SDL if you want to create desktop apps.

I did run into a limitation running on Linux, as LVGL is designed for embedded systems, with tiny RTOSs or no RTOS, and typically a keypad or touch-screen.

On Linux, without X (and SDL), the framebuffer can be used for display, and the mouse via evdev.

However, keyboard input via evdev is not functioning, hence the issue that I started on the author's github site. I started to suggest possible code for initializing evdev for both mouse, touchpad, and keyboard, but that's as far as I got.

If anyone feels inspired to take this up, please do!!!

Here is my last blog post, preliminary evaluation of LVGL:

http://bkhome.org/news/201808/littlevgl ... art-3.html

I have created a password-entry app with custom on-screen keyboard, quite easy to write, haven't posted to blog about it yet. So far it only works with the mouse, and requires hard-coded /dev/input/event0 -- hence my start to autodetect the evdev devices.
[url]https://bkhome.org/news/[/url]

lmemsm
Posts: 51
Joined: Wed 27 Jun 2012, 15:01

#52 Post by lmemsm »

BarryK wrote:I narrowed it down to LittlevGL (LVGL), and found it to be very nice, capable of creating very small static apps, that I compiled with uClibc and musl.

Extremely efficient handling of fonts and images, with no external library deps, only libc/uclibc/musl. Or, SDL if you want to create desktop apps.
Was reading your blog comments on LittlevGL a few days ago. Am always looking for a good lightweight cross-platform GUI. Was wondering how LVGL compares to using SDL with PDcurses for a GUI. Version 1.2.15 of SDL has framebuffer support. (Version 2.x only works in framebuffer with DirectFB. Keep wondering if an OpenGL backend might be an alternative on some systems though.) PDCurses has a SDL backend that lets you still use the graphics capabilities of SDL along with the text (TUI) capabilities of curses. There are ports of BSD libmenu and libform that work with PDCurses as well. Fonts can be bitmap or TrueType (using SDL2_ttf with SDL 1.x or 2.x). I'm guessing LVGL is probably much more compact than using multiple libraries. Was just wondering about how the capabilities (what kind of user interfaces you can create/support) compared. Am also curious about what you thought of the LVGL API. Is it easy to learn and work with? Thanks.

Was also wondering if any of the keyboard code from Android (which also uses the Linux kernel) might be useful for LVGL. The android_native_app_glue.c gives one example of how keyboard input could be handled and the system code behind it is available as Open Source from Google.

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#53 Post by BarryK »

lmemsm wrote:
BarryK wrote:I narrowed it down to LittlevGL (LVGL), and found it to be very nice, capable of creating very small static apps, that I compiled with uClibc and musl.

Extremely efficient handling of fonts and images, with no external library deps, only libc/uclibc/musl. Or, SDL if you want to create desktop apps.
Was reading your blog comments on LittlevGL a few days ago. Am always looking for a good lightweight cross-platform GUI. Was wondering how LVGL compares to using SDL with PDcurses for a GUI. Version 1.2.15 of SDL has framebuffer support. (Version 2.x only works in framebuffer with DirectFB. Keep wondering if an OpenGL backend might be an alternative on some systems though.) PDCurses has a SDL backend that lets you still use the graphics capabilities of SDL along with the text (TUI) capabilities of curses. There are ports of BSD libmenu and libform that work with PDCurses as well. Fonts can be bitmap or TrueType (using SDL2_ttf with SDL 1.x or 2.x). I'm guessing LVGL is probably much more compact than using multiple libraries. Was just wondering about how the capabilities (what kind of user interfaces you can create/support) compared. Am also curious about what you thought of the LVGL API. Is it easy to learn and work with? Thanks.

Was also wondering if any of the keyboard code from Android (which also uses the Linux kernel) might be useful for LVGL. The android_native_app_glue.c gives one example of how keyboard input could be handled and the system code behind it is available as Open Source from Google.
I don't know anything about PDCurses, but with SDL it would have to be much bigger final size.

With LGVL, I created just over 200KB static executable, that's with all the modules included, for every type of widget. Using a generic makefile that is pulling in everything:

Code: Select all

pntr_20x32_img.o show_36x32_img.o show_not_36x32_img.o lv_group.o lv_indev.o lv_obj.o lv_refr.o lv_style.o lv_vdb.o lv_hal_disp.o lv_hal_indev.o lv_hal_tick.o lv_bar.o lv_cb.o lv_ddlist.o lv_kb.o lv_line.o lv_mbox.o lv_roller.o lv_tabview.o lv_btn.o lv_chart.o lv_gauge.o lv_label.o lv_list.o lv_slider.o lv_ta.o lv_btnm.o lv_cont.o lv_img.o lv_led.o lv_lmeter.o lv_page.o lv_sw.o lv_win.o lv_font_dejavu_10.o lv_font_dejavu_20.o lv_font_dejavu_30.o lv_font_dejavu_40.o lv_font_dejavu_10_cyrillic.o lv_font_dejavu_20_cyrillic.o lv_font_dejavu_30_cyrillic.o lv_font_dejavu_40_cyrillic.o lv_font_dejavu_10_latin_sup.o lv_font_dejavu_20_latin_sup.o lv_font_dejavu_30_latin_sup.o lv_font_dejavu_40_latin_sup.o lv_font_symbol_10.o lv_font_symbol_20.o lv_font_symbol_30.o lv_font_symbol_40.o lv_font.o lv_circ.o lv_area.o lv_task.o lv_fs.o lv_anim.o lv_mem.o lv_ll.o lv_color.o lv_txt.o lv_ufs.o lv_trigo.o lv_math.o lv_theme_alien.o lv_theme.o lv_theme_default.o lv_theme_night.o lv_theme_templ.o lv_theme_zen.o lv_theme_material.o lv_draw_vbasic.o lv_draw.o lv_draw_rbasic.o fbdev.o monitor.o R61581.o SSD1963.o ST7565.o FT5406EE8.o keyboard.o mouse.o evdev.o XPT2046.o main.o
The LVGL docs say that complete executables may be only about 40 - 50KB.

Regarding the ease of programming, I was very pleasantly surprised. There is an online tool for converting images in C-arrays, that can be included in the program, which I have done in this program:

Code: Select all

#include "lvgl/lvgl.h"
#include "lv_drivers/display/fbdev.h"
#include "lv_drivers/indev/evdev.h"
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>

/*images*/
extern const lv_img_t pntr_img;
extern const lv_img_t show_img;
extern const lv_img_t show_not_img;
lv_obj_t *show_obj;
lv_obj_t *label3;

//Add a display for the LittlevGL using the frame buffer driver
void register_display(void)
{
	lv_disp_drv_t disp_drv;
	lv_disp_drv_init(&disp_drv);
	disp_drv.disp_flush = fbdev_flush;      //It flushes the internal graphical buffer to the frame buffer
	lv_disp_drv_register(&disp_drv);
}

static lv_res_t btn3_click_action(lv_obj_t * btn)
{
    uint8_t id = lv_obj_get_free_num(btn);
    printf("Button %d is released\n", id);
//	lv_img_set_src(show_obj, &show_not_img);
	lv_label_set_text(label3, "Hide");
    /* The button is released.
     * Make something here */
    return LV_RES_OK; /*Return OK if the button is not deleted*/
}

static lv_res_t ok_action_func(lv_obj_t * btn)
{
	exit(0);
}

int main(void)
{
    /*LittlevGL init*/
    lv_init();

    /*Linux frame buffer device init*/
    fbdev_init();

    // get a display
	register_display();
	
	// enable event input
	evdev_init();
	
	// get an input device like mouse
	lv_indev_drv_t indev_drv;
	lv_indev_drv_init(&indev_drv);
	indev_drv.type = LV_INDEV_TYPE_POINTER;
	indev_drv.read = evdev_read;
    lv_indev_t * mouse_indev = lv_indev_drv_register(&indev_drv);
	/*need an image for the mouse*/
    lv_obj_t * cursor_obj =  lv_img_create(lv_scr_act(), NULL); /*Create an image for the cursor */
    //lv_img_set_src(cursor_obj, SYMBOL_GPS);                 /*For simlicity add a built in symbol not an image*/
    lv_img_set_src(cursor_obj, &pntr_img);
    lv_indev_set_cursor(mouse_indev, cursor_obj); /* connect the object to the driver*/
	
	/*Create a title label*/
	lv_obj_t *label1 = lv_label_create(lv_scr_act(), NULL);
	lv_label_set_text(label1, "Title text here");
	lv_obj_align(label1, NULL, LV_ALIGN_IN_TOP_MID, 0, 5);
	
	/*create map for custom kbd*/
	/*ref: https://littlevgl.com/object-types/button-matrix-lv_btnm*/
	const char *map1[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\n",
		                  "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "\n",
		                  "a", "s", "d", "f", "g", "h", "j", "k", "l", "\n",
		                  "z", "x", "c", "v", "b", "n", "m", "Del", SYMBOL_OK, ""};
	
	/*create a keyboard*/
	lv_obj_t *kb = lv_kb_create(lv_scr_act(), NULL);
	lv_kb_set_cursor_manage(kb, true);
	/*create a custom kbd*/
	lv_kb_set_map(kb, map1);
	/*action when click ok button*/
	lv_kb_set_ok_action(kb, ok_action_func);

	/*Create a one lined text area with password mode*/
	lv_obj_t * ta2 = lv_ta_create(lv_scr_act(), NULL);
	lv_obj_set_size(ta2, 100, 20);
	lv_obj_align(ta2, label1, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
/*Apply the background style*/
	lv_ta_set_one_line(ta2, true);
	lv_ta_set_cursor_type(ta2, LV_CURSOR_LINE);
	lv_ta_set_pwd_mode(ta2, true);
	lv_ta_set_text(ta2, "");
	/*Assign the text area to the keyboard*/
	lv_kb_set_ta(kb, ta2);
	
	/*create a group for keyboard input*/
	lv_group_t *group2 = lv_group_create();
	lv_group_add_obj(group2, ta2);
	/*evdev to handle kb input*/
	lv_indev_drv_t kb_drv;
	lv_indev_drv_init(&kb_drv);
	kb_drv.type = LV_INDEV_TYPE_KEYPAD;
	kb_drv.read = evdev_read;
	/*assign kb to group*/
	lv_indev_t *kb_indev = lv_indev_drv_register(&kb_drv);
	lv_indev_set_group(kb_indev, group2);
	/*set focus on ta2*/
	lv_group_focus_obj(ta2);
	lv_group_focus_freeze(group2, true);
	
	/*button to show or hide password*/
	lv_obj_t *btn3 = lv_btn_create(lv_scr_act(), NULL);
	lv_cont_set_fit(btn3, true, true); /*Enable resizing horizontally and vertically*/
	lv_obj_align(btn3, ta2, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
	lv_obj_set_free_num(btn3, 3);   /*Set a unique number for the button*/
	lv_btn_set_action(btn3, LV_BTN_ACTION_CLICK, btn3_click_action);
	label3 = lv_label_create(btn3, NULL);
	lv_label_set_text(label3, "Show");
//	show_obj =  lv_img_create(btn3, NULL); /*Create an image for the button */
//	lv_img_set_src(show_obj, &show_img);

	/*Handle LitlevGL tasks (tickless mode)*/
    while(1)
	{
        lv_tick_inc(5);
        lv_task_handler();
        usleep(5000);
    }

    return 0;
}
...a work-in-progress, as I was trying to get keyboard to work. Mouse works. There is a default keyboard, but I created a custom one. Also created a custom image for the mouse pointer.

With just a bit of practice, I found the api very simple and logical.

Re buttons, images on buttons not yet supported. That is scheduled for version 5.2.
[url]https://bkhome.org/news/[/url]

lmemsm
Posts: 51
Joined: Wed 27 Jun 2012, 15:01

Re: Unbloated coding resources

#54 Post by lmemsm »

Some other options:

Possible OpenSSL/LibreSSL alternative: https://bearssl.org/

Pkgconf is a Pkgconfig alternative with no circular dependencies required: https://github.com/pkgconf/pkgconf

CDetect is a lightweight alternative to Autoconf/configure: http://cdetect.sourceforge.net/
I have a version with some added features at:
http://www.distasis.com/cpp/lmports.htm
Will upload an update with better cross-platform build support soon.

Recently created a list of C GUI libraries:
https://lmemsm.dreamwidth.org/8313.html
Options like nuklear and Otk seem very lightweight and might prove useful.

Best SVG library I've been able to find to date is:
https://github.com/memononen/nanosvg

Lighter versions of X Windows and X Windows alternatives:
nano-x
https://github.com/pelya/xserver-xsdl
https://github.com/idunham/tinyxlib

PicoBSD had some interesting alternative utilities:
https://github.com/freebsd/freebsd/tree ... d/tinyware

Lightweight Minix utilities before they switched over to the BSD standards:
https://www.minix-vmd.org/cgi-bin/raw/s ... ds/simple/

sbase makes a nice alternative to GNU coreutils, busybox and toybox
https://git.suckless.org/sbase/

NetBSD-curses: https://github.com/sabotage-linux/netbsd-curses

TinyCurses: https://github.com/tommyettinger/TinyCurses

I'm still working with PicoGL and hope I'll be able to add support for glTexSubImage2D command soon so it can be used with font atlases that require texture mapping. Took a while, but I think I have textures working at different power-of-two based sizes instead of hard-coded to 256x256.


I'm still in the process of searching for useful lightweight applications. Is there another thread for that or a good place to discuss the topic further? I've found some great lightweight alternatives, but I'm always looking for other options. Thanks.

lmemsm
Posts: 51
Joined: Wed 27 Jun 2012, 15:01

Re: Unbloated coding resources

#55 Post by lmemsm »

A few more I forgot to mention:

Possible replacement for GNU tar:
https://www.libarchive.org/

minised:
https://exactcode.com/opensource/minised/

There's also BSD gzip (part of NetBSD) which is a BSD licensed alternative to gzip. I've made a few modifications and added some format options to my version of it.

lmemsm
Posts: 51
Joined: Wed 27 Jun 2012, 15:01

Re: Unbloated coding resources

#56 Post by lmemsm »

A list with some more unbloated resources and utilities:
https://lmemsm.dreamwidth.org/10190.html

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#57 Post by technosaurus »

Fabrice has done it again:
https://bellard.org/quickjs/
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

Post Reply