Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve build-system for ease of use #4

Open
JayFoxRox opened this issue May 8, 2021 · 1 comment
Open

Improve build-system for ease of use #4

JayFoxRox opened this issue May 8, 2021 · 1 comment

Comments

@JayFoxRox
Copy link

JayFoxRox commented May 8, 2021

The build-system should be refactored. Ideally to CMake (in my opinion), or at least a helper script to do the steps from the README.

The steps are just too annoying for a small utility like this.
In particular, this step: "3. Set URHO3D_HOME and URHOX_HOME variable path in QtCreator"

  • It shouldn't be necessary to manually mix qmake and cmake.
  • The build-system should find system-wide installation of Urho3D, or there should be a helper to install it.
  • Urhox should probably be bundled with Spkgen or CMake should be used to find it, with a helper to download it.

Another option would be to keep the complicated build-system, but provide a webtool. Urho3D already has demos for the web using emscripten. There's also Qt for wasm, so deploying this way might be a good alternative to let people play with SPARK and spkgen.


Lastly, this also partially affects https://github.com/fredakilla/SPARK - I think the changes should be upstreamed, or the library should be made independent for exposure. It's the only easy-to-use version of SPARK that I found (installing system-wide is a critical feature to me).
SPARK seems to be a cool library, but the upstream build-system and lack of documentation probably hurt its usability; the confusing ecosystem (there's still a sourceforge page for it, which looks more "official") and tooling should be improved.

@JayFoxRox
Copy link
Author

I created an install script for Linux for myself, which deals with many of these weird assumptions and necessary patches.
It's barely tested and I kept touching it over time, so it might not work 100% out of the box.

Here is the script; consider this spkgen install script to be licensed under CC0 / public-domain:

#!/usr/bin/env bash

set -e
set -u

MAKEOPTS=-j4

function git() {
  /usr/bin/git "$@" || true
}

function mkdir() {
  /usr/bin/mkdir "$@" || true
}

git clone https://github.com/fredakilla/spkgen --depth=1
pushd spkgen

pushd 3rdparty

# Bundle minimalistic Urho3D dependency
git clone https://github.com/urho3d/Urho3D --depth=1
pushd Urho3D
mkdir BUILD
cd BUILD
# We need to disable wayland, to avoid a problem with SDL and gcc 10 or above
# Ideally we'd be using the system SDL (.. also GLEW, Freetype, Bullet, webp, ...)
cmake .. \
  -DVIDEO_WAYLAND=OFF \
  -DURHO3D_ANGELSCRIPT=OFF \
  -DURHO3D_LUA=OFF \
  -DURHO3D_NETWORK=OFF \
  -DURHO3D_DATABASE_ODBC=OFF \
  -DURHO3D_DATABASE_SQLITE=OFF \
  -DURHO3D_IK=OFF \
  -DURHO3D_NAVIGATION=OFF \
  -DURHO3D_URHO2D=OFF \
  -DURHO3D_PHYSICS=OFF \
  -DURHO3D_TRACY_PROFILING=OFF \
  -DURHO3D_D3D11=OFF \
  -DURHO3D_CLANG_TOOLS=OFF \
  -DURHO3D_LUAJIT=OFF \
  -DURHO3D_LUAJIT_AMALG=OFF \
  -DURHO3D_PCH=OFF \
  -DURHO3D_PLAYER=OFF \
  -DURHO3D_PROFILING=OFF \
  -DURHO3D_SAMPLES=OFF \
  -DURHO3D_TOOLS=OFF
make $MAKEOPTS
export URHO3D_HOME=$(pwd)
popd

# Bundle Urhox dependency
git clone https://github.com/fredakilla/Urhox.git --depth=1
pushd Urhox

# Fix bug where SystemUI redeclares a function from a header
sed -i 's/ClosestPowerOfTwo/ClosestPowerOfTwo_/g' Sources/Urhox/SystemUI/SystemUI.cpp

# Replace bundled SPARK with latest spark, to avoid compilation errors in Urhox
pushd Sources/ThirdParty
mv Spark Spark_old || true
git clone https://github.com/fredakilla/SPARK.git --depth=1 Spark

# Mimic the old directory structure
ln -s $(pwd)/Spark/spark/include Spark/include || true

popd

# Build Urhox now
mkdir output
cd output
cmake .. \
  -DCMAKE_CXX_FLAGS=-fcommon \
  -DURHO3D_HOME="$URHO3D_HOME"
make $MAKEOPTS
export URHOX_HOME=$(pwd)
popd

# Manually "initialize" our submodule (we'll use upstream, which works better than the intended one)
git clone https://github.com/paceholder/nodeeditor.git --depth=1
pushd nodeeditor
mkdir BUILD
cd BUILD
cmake .. \
  -DBUILD_TESTING=OFF \
  -DBUILD_EXAMPLES=OFF
make $MAKEOPTS
popd

popd

# Fix a bug where paths are hardcoded
sed -i 's/^URHO3D_HOME/URHO3D_HOME_/g' Spkgen.pro
sed -i 's/^URHOX_HOME/URHOX_HOME_/g' Spkgen.pro

# Fix a bug where some source file is missing
touch src/benchmark.h

# Build the actual project
qmake Spkgen.pro URHO3D_HOME="$URHO3D_HOME" URHOX_HOME="$URHOX_HOME" 
make $MAKEOPTS

# Copy the nodeeditor lib
mkdir -p bin/lib
cp ./3rdparty/nodeeditor/BUILD/lib/libnodes.so bin/lib/

# Copy the Urho3D data folders to Spkgen
cp -R $URHO3D_HOME/../bin/CoreData bin/
cp -R $URHO3D_HOME/../bin/Data bin/

# Set up a script to run Spkgen
echo "#!/usr/bin/env bash" > bin/run.sh
echo "SCRIPT_DIR=\"\$( cd \"\$( dirname \"\${BASH_SOURCE[0]}\" )\" &> /dev/null && pwd )\"" >> bin/run.sh
echo "LD_LIBRARY_PATH=\${SCRIPT_DIR}/lib \${SCRIPT_DIR}/Spkgen" >> bin/run.sh
chmod +x bin/run.sh

popd

(This does not workaround #5 yet though)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant