[MOD/CI/BUILD] Static builds, via the native tools

This commit is contained in:
LDA 2024-09-12 22:17:35 +02:00
commit 92d33fa641
3 changed files with 50 additions and 26 deletions

View file

@ -59,26 +59,13 @@ jobs:
git clone https://git.kappach.at/${{ github.repository}} parsee
cd parsee
alias musl-gcc="musl-gcc -Wl,-Bstatic -L ${PREFIX}/lib"
export TAB=$(printf '\t')
echo "all: adminify aya b64 config noavatars" > tools/Makefile
echo "%: %.c" >> tools/Makefile
echo "${TAB}musl-gcc -I ../usr/include -static -o ../\$@.\$(shell uname -m) $< -lm -lpthread -lssl -lCytoplasm -lssl -lcrypto -llmdb -flto -fdata-sections -ffunction-sections -s -Wl,-gc-sections -lCytoplasm" >> tools/Makefile
cat tools/Makefile
cd tools
make
cd ..
make CC=musl-gcc CYTO_INC=${PREFIX}/include CYTO_LIB=${PREFIX}/lib 2> /dev/null || true
musl-gcc -static -o "parsee.$(uname -m)" $(find build/ -name '*.o') -lm -lpthread -lssl -lCytoplasm -lssl -lcrypto -llmdb -flto -fdata-sections -ffunction-sections -s -Wl,-gc-sections -lCytoplasm
ls $PREFIX
./configure -s -i
make CC=musl-gcc CYTO_INC=${PREFIX}/include CYTO_LIB=${PREFIX}/lib
make PREFIX=bins
ls bins
- name: Create a final archive
run: |
cd parsee
mkdir bins
ls "${PREFIX}"
ls .
cp $(find . -maxdepth 1 -name "*.$(uname -m)") bins
tar -czvf "$(uname)-$(uname -m).tar.gz" bins
cp "$(uname)-$(uname -m).tar.gz" ..
echo "NAM=parsee-$(uname)-$(uname -m)" >> $GITHUB_ENV
echo "DIR=$PWD/bins" >> $GITHUB_ENV
- name: Upload it all(as a ZIP of a .TGZ)

View file

@ -26,11 +26,10 @@ a bridge may be a good way to start.
## BUILDING
```sh
$ make # This generates a 'parsee' executable.
$ cd tools # If you want to build more tools
$ make && cd ..
$ make ayadoc # If you want to build HTML documentation
$ make [PREFIX=(install path)] install # To install Parsee.
$ cc configure.c -o configure
$ ./configure # use -s if you want static Parsee+OpenSSL, use -s -l if LMDB is needed
$ make
$ make [PREFIX=...] install # run as root if on a protected dir like /usr
```
If there are any Cytoplasm-related build failures, you may want to check the Makefile to
change a few variables (you can set `CYTO_INC` and `CYTO_LIB` for Cytoplasm's include and

View file

@ -412,6 +412,8 @@ main_build(int argc, char *argv[])
char *repo = cmd_stdout("git remote get-url origin");
size_t size, i;
ssize_t nread;
bool with_static = false, with_lmdb = false;
int opt;
str_array_t *sources, *images, *utils, *aya;
if (strchr(repo, '\n'))
@ -419,6 +421,19 @@ main_build(int argc, char *argv[])
*(strchr(repo, '\n')) = '\0';
}
while ((opt = getopt(argc, argv, "sl")) != -1)
{
switch (opt)
{
case 's':
with_static = true;
break;
case 'l':
with_lmdb = with_static;
with_static = true;
break;
}
}
makefile = fopen("Makefile", "w");
fprintf(makefile, "# Autogenerated POSIX Makefile\n");
@ -440,10 +455,20 @@ main_build(int argc, char *argv[])
write_images(makefile, images);
fprintf(makefile, "\n\t");
{
fprintf(makefile, "$(CC) -L $(CYTO_LIB) -lCytoplasm $(LDFLAGS)");
fprintf(makefile, "$(CC) -o $(BINARY)");
if (with_static)
{
fprintf(makefile, " -static");
}
fprintf(makefile, " -L $(CYTO_LIB)");
write_objects(makefile, sources);
write_images(makefile, images);
fprintf(makefile, " -o $(BINARY)\n");
if (with_static)
{
fprintf(makefile, " -lm -lpthread -lssl -lCytoplasm -lssl -lcrypto");
if (with_lmdb) fprintf(makefile, " -llmdb");
}
fprintf(makefile, " -lCytoplasm $(LDFLAGS)\n");
}
/* Write rules for every source */
@ -467,7 +492,7 @@ main_build(int argc, char *argv[])
str_array_free(s);
fprintf(makefile, "\t$(CC) -c -Isrc -Isrc/include -I$(CYTO_INC) ");
fprintf(makefile, "-DVERSION=\"\\\"$(VERDION)\\\"\" ");
fprintf(makefile, "-DVERSION=\"\\\"$(VERSION)\\\"\" ");
fprintf(makefile, "-DNAME=\"\\\"$(NAME)\\\"\" ");
fprintf(makefile, "-DCODE=\"\\\"$(CODE)\\\"\" ");
fprintf(makefile, "-DREPOSITORY=\"\\\"%s\\\"\" ", repo);
@ -523,7 +548,20 @@ main_build(int argc, char *argv[])
fprintf(makefile, "%s: %s\n", obj, src);
{
fprintf(makefile, "\t@mkdir -p tools/out\n");
fprintf(makefile, "\t$(CC) $(CFLAGS) -lCytoplasm $< -o $@\n");
fprintf(makefile, "\t$(CC) -o $@");
if (with_static)
{
fprintf(makefile, " -static");
}
fprintf(makefile, " $<");
fprintf(makefile, " -L $(CYTO_LIB)");
if (with_static)
{
fprintf(makefile, " -lm -lpthread -lssl");
fprintf(makefile, " -lCytoplasm -lssl -lcrypto");
if (with_lmdb) fprintf(makefile, " -llmdb");
}
fprintf(makefile, " -lCytoplasm $(CFLAGS)\n");
}
free(ofl);