WIP: next #1
|
@ -37,17 +37,20 @@ CCFLAGS := -static -Os \
|
|||
-fvisibility=hidden \
|
||||
-Bsymbolic \
|
||||
-Wl,--exclude-libs,ALL \
|
||||
-fno-ident
|
||||
-fno-ident \
|
||||
-Wall
|
||||
#-fuse-ld=gold \
|
||||
-fno-exceptions
|
||||
#-Wl,--icf=all \
|
||||
|
||||
STRIPFLAGS := -s --strip-unneeded -R .comment -R .gnu.version -R .comment -R .note -R .note.gnu.build-id -R .note.ABI-tag
|
||||
|
||||
src := $(wildcard *.c)
|
||||
programs := $(basename $(src))
|
||||
c_src := $(wildcard *.c)
|
||||
programs := $(basename $(c_src))
|
||||
bins := $(addprefix out/, $(programs))
|
||||
unstripped_bins := $(addsuffix _unstripped, $(bins))
|
||||
run_programs := $(addprefix run_, $(programs))
|
||||
rs_src := $(wildcard ../src/*.rs) ../Cargo.lock
|
||||
|
||||
all: $(bins)
|
||||
|
||||
|
@ -56,9 +59,9 @@ clean:
|
|||
rm include/servicepoint.h || true
|
||||
cargo clean
|
||||
|
||||
PHONY: all clean analyze-size
|
||||
PHONY: all clean sizes $(run_programs)
|
||||
|
||||
$(unstripped_bins): out/%_unstripped: %.c $(SERVICEPOINT_HEADER_OUT)/servicepoint.h
|
||||
$(unstripped_bins): out/%_unstripped: %.c $(SERVICEPOINT_HEADER_OUT)/servicepoint.h $(RUST_TARGET_DIR)/libservicepoint_binding_c.a
|
||||
mkdir -p out || true
|
||||
${CC} $^ \
|
||||
-I $(SERVICEPOINT_HEADER_OUT) \
|
||||
|
@ -69,14 +72,22 @@ $(unstripped_bins): out/%_unstripped: %.c $(SERVICEPOINT_HEADER_OUT)/servicepoin
|
|||
$(bins): out/%: out/%_unstripped
|
||||
strip $(STRIPFLAGS) $^ -o $@
|
||||
|
||||
$(SERVICEPOINT_HEADER_OUT)/servicepoint.h: FORCE
|
||||
$(SERVICEPOINT_HEADER_OUT)/servicepoint.h $(RUST_TARGET_DIR)/libservicepoint_binding_c.a: $(rs_src)
|
||||
mkdir -p include || true
|
||||
# generate servicepoint header and binary to link against
|
||||
${CARGO} rustc $(CARGOFLAGS) -- $(RUSTFLAGS)
|
||||
|
||||
analyze-size: out/example_unstripped
|
||||
nm --print-size --size-sort --reverse-sort --radix=d --demangle out/example_unstripped \
|
||||
| awk '{size=$$2+0; print size "\t" $$4}' \
|
||||
| less
|
||||
$(run_programs): run_%: out/% FORCE
|
||||
./$<
|
||||
|
||||
sizes: $(bins)
|
||||
ls -lB out
|
||||
|
||||
#analyze-size: out/example_unstripped
|
||||
# nm --print-size --size-sort --reverse-sort --radix=d --demangle out/example_unstripped \
|
||||
# | awk '{size=$$2+0; print size "\t" $$4}' \
|
||||
# | less
|
||||
|
||||
|
||||
|
||||
FORCE: ;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#include <stdio.h>
|
||||
#include "servicepoint.h"
|
||||
|
||||
int main(void) {
|
||||
|
@ -8,7 +7,7 @@ int main(void) {
|
|||
|
||||
sp_udp_send_command(connection, sp_command_clear());
|
||||
|
||||
CharGrid *grid = sp_char_grid_new(5,2);
|
||||
CharGrid *grid = sp_char_grid_new(5, 2);
|
||||
if (grid == NULL)
|
||||
return 1;
|
||||
|
||||
|
|
29
example/brightness_tester.c
Normal file
29
example/brightness_tester.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include "servicepoint.h"
|
||||
|
||||
int main(void) {
|
||||
// UdpConnection *connection = sp_udp_open_ipv4(172, 23, 42, 29, 2342);
|
||||
UdpConnection *connection = sp_udp_open_ipv4(127, 0, 0, 1, 2342);
|
||||
if (connection == NULL)
|
||||
return -1;
|
||||
|
||||
Bitmap *all_on = sp_bitmap_new_max_sized();
|
||||
sp_bitmap_fill(all_on, true);
|
||||
TypedCommand *cmd = sp_command_bitmap(0, 0, all_on, COMPRESSION_CODE_UNCOMPRESSED);
|
||||
if (cmd == NULL)
|
||||
return -1;
|
||||
|
||||
sp_udp_send_command(connection, cmd);
|
||||
|
||||
BrightnessGrid *grid = sp_brightness_grid_new(TILE_WIDTH, TILE_HEIGHT);
|
||||
|
||||
ByteSlice slice = sp_brightness_grid_unsafe_data_ref(grid);
|
||||
for (size_t index = 0; index < slice.length; index++) {
|
||||
slice.start[index] = (uint8_t) (index % ((size_t) Brightness_MAX));
|
||||
}
|
||||
|
||||
TypedCommand *command = sp_command_brightness_grid(0, 0, grid);
|
||||
sp_udp_send_command(connection, command);
|
||||
|
||||
sp_udp_free(connection);
|
||||
return 0;
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
#include <stdio.h>
|
||||
#include "servicepoint.h"
|
||||
|
||||
int main(void) {
|
||||
|
|
Loading…
Reference in a new issue