[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 git clone https://git.kappach.at/${{ github.repository}} parsee
cd parsee cd parsee
alias musl-gcc="musl-gcc -Wl,-Bstatic -L ${PREFIX}/lib" alias musl-gcc="musl-gcc -Wl,-Bstatic -L ${PREFIX}/lib"
export TAB=$(printf '\t') ./configure -s -i
echo "all: adminify aya b64 config noavatars" > tools/Makefile make CC=musl-gcc CYTO_INC=${PREFIX}/include CYTO_LIB=${PREFIX}/lib
echo "%: %.c" >> tools/Makefile make PREFIX=bins
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 ls bins
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
- name: Create a final archive - name: Create a final archive
run: | run: |
cd parsee 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 "NAM=parsee-$(uname)-$(uname -m)" >> $GITHUB_ENV
echo "DIR=$PWD/bins" >> $GITHUB_ENV echo "DIR=$PWD/bins" >> $GITHUB_ENV
- name: Upload it all(as a ZIP of a .TGZ) - 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 ## BUILDING
```sh ```sh
$ make # This generates a 'parsee' executable. $ cc configure.c -o configure
$ cd tools # If you want to build more tools $ ./configure # use -s if you want static Parsee+OpenSSL, use -s -l if LMDB is needed
$ make && cd .. $ make
$ make ayadoc # If you want to build HTML documentation $ make [PREFIX=...] install # run as root if on a protected dir like /usr
$ make [PREFIX=(install path)] install # To install Parsee.
``` ```
If there are any Cytoplasm-related build failures, you may want to check the Makefile to 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 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"); char *repo = cmd_stdout("git remote get-url origin");
size_t size, i; size_t size, i;
ssize_t nread; ssize_t nread;
bool with_static = false, with_lmdb = false;
int opt;
str_array_t *sources, *images, *utils, *aya; str_array_t *sources, *images, *utils, *aya;
if (strchr(repo, '\n')) if (strchr(repo, '\n'))
@ -419,6 +421,19 @@ main_build(int argc, char *argv[])
*(strchr(repo, '\n')) = '\0'; *(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"); makefile = fopen("Makefile", "w");
fprintf(makefile, "# Autogenerated POSIX Makefile\n"); fprintf(makefile, "# Autogenerated POSIX Makefile\n");
@ -440,10 +455,20 @@ main_build(int argc, char *argv[])
write_images(makefile, images); write_images(makefile, images);
fprintf(makefile, "\n\t"); 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_objects(makefile, sources);
write_images(makefile, images); 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 */ /* Write rules for every source */
@ -467,7 +492,7 @@ main_build(int argc, char *argv[])
str_array_free(s); str_array_free(s);
fprintf(makefile, "\t$(CC) -c -Isrc -Isrc/include -I$(CYTO_INC) "); 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, "-DNAME=\"\\\"$(NAME)\\\"\" ");
fprintf(makefile, "-DCODE=\"\\\"$(CODE)\\\"\" "); fprintf(makefile, "-DCODE=\"\\\"$(CODE)\\\"\" ");
fprintf(makefile, "-DREPOSITORY=\"\\\"%s\\\"\" ", repo); fprintf(makefile, "-DREPOSITORY=\"\\\"%s\\\"\" ", repo);
@ -523,7 +548,20 @@ main_build(int argc, char *argv[])
fprintf(makefile, "%s: %s\n", obj, src); fprintf(makefile, "%s: %s\n", obj, src);
{ {
fprintf(makefile, "\t@mkdir -p tools/out\n"); 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); free(ofl);