2022-06-24 10:05:39 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# `.cpp` files in src/lib will be automatically picked up and compiled into dynamic libraries.
|
2022-06-24 09:21:57 +02:00
|
|
|
echo "Building libs..."
|
|
|
|
mkdir -pv bin/lib
|
|
|
|
for lib in $(find ./src/lib -name "*.cpp"); do
|
2022-06-24 10:05:39 +02:00
|
|
|
COMPILE_COMMAND="c++ -shared -o $(sed -e 's/^.\/src/.\/bin/;s/cpp$/so/' <<< $lib) $lib"
|
|
|
|
echo $COMPILE_COMMAND
|
|
|
|
$COMPILE_COMMAND
|
2022-06-24 09:21:57 +02:00
|
|
|
done
|
|
|
|
|
2022-06-24 10:05:39 +02:00
|
|
|
|
2022-06-24 09:21:57 +02:00
|
|
|
# Commands for every program need to be given individually because we can't
|
|
|
|
# just add all shared libraries to all programs.
|
|
|
|
# Or can we? Idk, cba to find out.
|
2022-06-24 10:05:39 +02:00
|
|
|
|
|
|
|
# How to build a tool: Tell the compiler where to find shared libraries and
|
|
|
|
# which libraries to use.
|
|
|
|
# Example: shared libraries are in bin/lib => -Lbin/lib
|
|
|
|
# one of the libraries in that directory is libnbt.so
|
|
|
|
# => use with -lnbt (omit prefix lib and suffix .so)
|
|
|
|
# How to run a tool: specify the library path to use for the dynamic linker
|
|
|
|
# when running a program
|
|
|
|
# Example: LD_LIBRARY_PATH=bin/lib bin/tools/dumpnbt
|
|
|
|
echo "Building tools..."
|
|
|
|
mkdir -pv bin/tools
|
|
|
|
# add compile commands to this variable
|
|
|
|
COMPILE_COMMANDS="
|
|
|
|
set -v
|
2022-06-24 09:21:57 +02:00
|
|
|
c++ src/tools/dumpnbt.cpp -Lbin/lib -lnbt -o bin/tools/dumpnbt
|
2022-06-24 10:05:39 +02:00
|
|
|
"
|
|
|
|
sh <<< $COMPILE_COMMANDS
|