build: remove generated artifacts and unsafe scripts

This commit is contained in:
2026-08-12 16:23:45 +09:00
parent 368e6adcd4
commit c41a1b4227
11 changed files with 131 additions and 111510 deletions

65
.gitignore vendored
View File

@@ -1,59 +1,10 @@
strans
strans-xim
/*.o
/strans
/tests/*.o
/tests/unit_test
/xim/*.o
/xim/strans-xim
/xim/xim_test
/gtk/im-strans.so
/bench/bench
# Prerequisites
*.d
# Object files
*.o
*.ko
*.obj
*.elf
# Linker output
*.ilk
*.exp
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
*.su
*.idb
*.pdb
# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
# debug information files
*.dwo
/bench/perf.data*

View File

@@ -1,4 +1,4 @@
FROM archlinux:base
FROM archlinux:base@sha256:b0deabeb3d283da2c7f7dbf0eea051b7b2cd0554e0b737cc457fd21683bdcdd1
RUN pacman -Syu --noconfirm --needed \
diffutils \

View File

@@ -5,6 +5,8 @@ PKG_LIBS = $(shell pkg-config --libs dbus-1 wayland-client xkbcommon)
CFLAGS = -Wall -Wextra -O2 -g $(PKG_CFLAGS)
PROG = strans
DOCKER_IMAGE = strans-build
DOCKER_RUN = docker run --rm --user "$$(id -u):$$(id -g)" \
-v "$(CURDIR):/src" $(DOCKER_IMAGE)
SRCS = $(wildcard *.c)
OBJS = $(SRCS:.c=.o)
@@ -37,16 +39,20 @@ gtk:
bench:
$(MAKE) -C bench/
docker: Dockerfile
docker-image: Dockerfile
docker build -t $(DOCKER_IMAGE) - < Dockerfile
docker run --rm --user "$$(id -u):$$(id -g)" \
-v "$(CURDIR):/src" $(DOCKER_IMAGE) \
sh -c 'make clean && make all'
docker-check: docker
docker run --rm --user "$$(id -u):$$(id -g)" \
-e TESTARGS="$(TESTARGS)" -v "$(CURDIR):/src" \
$(DOCKER_IMAGE) make check
docker-build:
$(DOCKER_RUN) make all
docker-check:
$(DOCKER_RUN) make check TESTARGS="$(TESTARGS)"
docker-bench:
$(DOCKER_RUN) make bench
docker: docker-image
$(MAKE) docker-build
check: verify-map test
$(MAKE) -C xim check
@@ -61,4 +67,5 @@ verify-map:
python3 -B tests/mkemoji_test.py
python3 -B tests/skk2ktrans_test.py
.PHONY: all check test verify-map clean xim gtk bench docker docker-check
.PHONY: all check test verify-map clean xim gtk bench docker docker-image \
docker-build docker-check docker-bench

View File

@@ -1,23 +1,43 @@
#!/bin/sh
pkill strans
pkill strans-xim
sleep 1
set -eu
cd "$(dirname "$0")"
strans_pid=
perf_pid=
cleanup()
{
trap - 0 1 2 15
if test -n "$perf_pid"; then
kill -INT "$perf_pid" 2>/dev/null || true
wait "$perf_pid" 2>/dev/null || true
fi
if test -n "$strans_pid"; then
kill "$strans_pid" 2>/dev/null || true
wait "$strans_pid" 2>/dev/null || true
fi
}
trap cleanup 0 1 2 15
./strans map font &
strans_pid=$!
sleep 1
kill -0 "$strans_pid"
# warm up glyph cache
./bench/bench bench/bench.keys 100
echo "cache warmed up"
STRANS_PID=$(pgrep -x strans)
perf record -g -o bench/perf.data -p "$STRANS_PID" &
PERF_PID=$!
perf record -g -o bench/perf.data -p "$strans_pid" &
perf_pid=$!
sleep 1
kill -0 "$perf_pid"
./bench/bench bench/bench.keys 100
kill -INT $PERF_PID
wait $PERF_PID 2>/dev/null
pkill strans
kill -INT "$perf_pid"
wait "$perf_pid" 2>/dev/null || true
perf_pid=

View File

@@ -1,4 +1,7 @@
#define _POSIX_C_SOURCE 200809L
#include <errno.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -13,7 +16,7 @@ struct Key {
};
static Key *keys;
static int nkeys;
static size_t nkeys;
static int fd;
static void
@@ -26,13 +29,19 @@ die(char *msg)
static void
addkey(int k, int mod)
{
static int cap;
static size_t cap;
Key *p;
if(nkeys >= cap){
if(cap > SIZE_MAX / 2 / sizeof(Key)){
fprintf(stderr, "too many keys\n");
exit(1);
}
cap = cap ? cap * 2 : 256;
keys = realloc(keys, cap * sizeof(Key));
if(!keys)
p = realloc(keys, cap * sizeof(Key));
if(!p)
die("realloc");
keys = p;
}
keys[nkeys].k = k;
keys[nkeys].mod = mod;
@@ -74,6 +83,28 @@ loadkeys(char *file)
}
}
fclose(f);
if(nkeys == 0){
fprintf(stderr, "%s: no keys\n", file);
exit(1);
}
}
static uint64_t
iterations(char *s)
{
uintmax_t n;
char *end;
if(*s == '\0' || *s == '-')
goto Bad;
errno = 0;
n = strtoumax(s, &end, 10);
if(errno != 0 || *end != '\0' || n == 0 || n > UINT64_MAX)
goto Bad;
return n;
Bad:
fprintf(stderr, "invalid iteration count: %s\n", s);
exit(1);
}
static void
@@ -115,31 +146,38 @@ now(void)
int
main(int argc, char **argv)
{
int i, j, niter;
size_t j;
uint64_t i, niter, total;
double t0, t1, dt;
if(argc < 2){
if(argc != 2 && argc != 3){
fprintf(stderr, "usage: bench file [niter]\n");
exit(1);
}
loadkeys(argv[1]);
niter = argc > 2 ? atoi(argv[2]) : 1000;
niter = argc == 3 ? iterations(argv[2]) : 1000;
if(nkeys > UINT64_MAX || niter > UINT64_MAX / nkeys){
fprintf(stderr, "iteration count overflows key total\n");
exit(1);
}
total = niter * nkeys;
dial();
t0 = now();
for(i = 0; i < niter; i++)
for(j = 0; j < nkeys; j++){
sendkey(keys[j].k, keys[j].mod);
if(readresp() < 0){
fprintf(stderr, "failed at iter %d key %d\n", i, j);
fprintf(stderr, "failed at iter %" PRIu64 " key %zu\n", i, j);
exit(1);
}
}
t1 = now();
dt = t1 - t0;
printf("%d iters x %d keys = %d keys\n", niter, nkeys, niter * nkeys);
printf("%" PRIu64 " iters x %zu keys = %" PRIu64 " keys\n",
niter, nkeys, total);
printf("%.3f ms total, %.3f us/key, %.3f us/iter\n",
dt * 1000, dt * 1e6 / (niter * nkeys), dt * 1e6 / niter);
dt * 1000, dt * 1e6 / total, dt * 1e6 / niter);
close(fd);
return 0;
}

Binary file not shown.

Binary file not shown.

View File

@@ -1,28 +0,0 @@
 
,
. 。
< 《
> 》
/
?
;
:
\ 、
| ・
`
~ 〜
!
@
#
$ ¥
&
*
(
)
-
+
=
[ 「
] 」
{ 『
} 』

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

31
run.sh
View File

@@ -1,8 +1,35 @@
#!/bin/sh
set -eu
cd "$(dirname "$0")"
pkill strans
sleep 1
strans_pid=
xim_pid=
cleanup()
{
trap - 0 1 2 15
if test -n "$xim_pid"; then
kill "$xim_pid" 2>/dev/null || true
wait "$xim_pid" 2>/dev/null || true
fi
if test -n "$strans_pid"; then
kill "$strans_pid" 2>/dev/null || true
wait "$strans_pid" 2>/dev/null || true
fi
}
trap cleanup 0 1 2 15
./strans map font &
strans_pid=$!
sleep 1
kill -0 "$strans_pid"
xim/strans-xim &
xim_pid=$!
while kill -0 "$strans_pid" 2>/dev/null && kill -0 "$xim_pid" 2>/dev/null; do
sleep 1
done