Skip to content

Commit

Permalink
apt-get -> conda
Browse files Browse the repository at this point in the history
Get almost all dependencies from anaconda rather than
apt-get. I think this will make it easier to build an anaconda package.
  • Loading branch information
garymm committed Feb 14, 2024
1 parent e5e7a31 commit bbbe3f4
Show file tree
Hide file tree
Showing 19 changed files with 166 additions and 146 deletions.
13 changes: 1 addition & 12 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
FROM ubuntu:22.04

RUN apt-get update -y && \
apt-get install -y capnproto cmake curl g++ gettext git libc6-dev libcapnp-dev libcurl4-gnutls-dev libfreetype6-dev libgl1-mesa-dev libgmp-dev libjpeg-dev libjsoncpp-dev libluajit-5.1-dev libogg-dev libopenal-dev libpng-dev libsdl2-dev libsqlite3-dev libvorbis-dev libxi-dev libzmq3-dev libzstd-dev mold ninja-build zlib1g-dev

ENV CONDA_DIR /opt/conda
ENV PATH "${CONDA_DIR}/bin:${PATH}"
RUN echo ". /opt/conda/etc/profile.d/conda.sh" >> ${HOME}/.bashrc \
&& echo ". /opt/conda/etc/profile.d/conda.sh" >> /etc/profile \
&& echo "conda activate base" >> ${HOME}/.bashrc \
&& echo "conda activate base" >> /etc/profile

RUN curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" && \
bash Miniforge3-$(uname)-$(uname -m).sh -b -p ${CONDA_DIR} && \
rm Miniforge3-$(uname)-$(uname -m).sh
apt-get install -y g++ git libgl1-mesa-dev mold
6 changes: 5 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@
"vadimcn.vscode-lldb"
]
}
}
},
"features": {
"ghcr.io/rocker-org/devcontainer-features/miniforge:1": {}
},
"postCreateCommand": "bash -c 'mamba init && mamba env create'"
}
9 changes: 9 additions & 0 deletions .github/workflows/cpp_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ jobs:
source ./util/ci/common.sh
install_linux_deps $CLANG_TIDY
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: '3.11'
mamba-version: "*"
channels: conda-forge,nodefaults
activate-environment: minetest
environment-file: environment.yml

- name: Run clang-tidy
shell: bash -l {0}
run: |
./util/ci/clang-tidy.sh
70 changes: 62 additions & 8 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,17 @@ jobs:
source ./util/ci/common.sh
install_linux_deps g++-7
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: '3.11'
mamba-version: "*"
channels: conda-forge,nodefaults
activate-environment: minetest
environment-file: environment.yml

- name: Build
# Needed so conda environment is active
shell: bash -l {0}
run: |
./util/ci/build.sh
env:
Expand All @@ -64,7 +74,17 @@ jobs:
source ./util/ci/common.sh
install_linux_deps g++-12 libluajit-5.1-dev
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: '3.11'
mamba-version: "*"
channels: conda-forge,nodefaults
activate-environment: minetest
environment-file: environment.yml

- name: Build
# Needed so conda environment is active
shell: bash -l {0}
run: |
./util/ci/build.sh
env:
Expand All @@ -85,12 +105,23 @@ jobs:
source ./util/ci/common.sh
install_linux_deps clang-7 valgrind
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: '3.11'
mamba-version: "*"
channels: conda-forge,nodefaults
activate-environment: minetest
environment-file: environment.yml

- name: Build
# Needed so conda environment is active
shell: bash -l {0}
run: |
./util/ci/build.sh
env:
CC: clang-7
CXX: clang++-7
CMAKE_FLAGS: "-DENABLE_CURSES=FALSE"

- name: Unittest
run: |
Expand All @@ -110,7 +141,17 @@ jobs:
source ./util/ci/common.sh
install_linux_deps clang-14 gdb
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: '3.11'
mamba-version: "*"
channels: conda-forge,nodefaults
activate-environment: minetest
environment-file: environment.yml

- name: Build
# Needed so conda environment is active
shell: bash -l {0}
run: |
./util/ci/build.sh
env:
Expand All @@ -134,13 +175,6 @@ jobs:
source ./util/ci/common.sh
install_linux_deps clang-14
- name: Build
run: |
./util/ci/build.sh
env:
CC: clang-14
CXX: clang++-14

- uses: conda-incubator/setup-miniconda@v3
with:
python-version: '3.11'
Expand All @@ -149,6 +183,15 @@ jobs:
activate-environment: minetest
environment-file: environment.yml

- name: Build
# Needed so conda environment is active
shell: bash -l {0}
run: |
./util/ci/build.sh
env:
CC: clang-14
CXX: clang++-14

- name: Run pytest
# Needed so conda environment is active
shell: bash -l {0}
Expand All @@ -174,17 +217,28 @@ jobs:
source ./util/ci/common.sh
install_linux_deps clang-9
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: '3.11'
mamba-version: "*"
channels: conda-forge,nodefaults
activate-environment: minetest
environment-file: environment.yml

- name: Build prometheus-cpp
shell: bash -l {0}
run: |
./util/ci/build_prometheus_cpp.sh
- name: Build
# Needed so conda environment is active
shell: bash -l {0}
run: |
./util/ci/build.sh
env:
CC: clang-9
CXX: clang++-9
CMAKE_FLAGS: "-DENABLE_PROMETHEUS=1 -DBUILD_CLIENT=0"
CMAKE_FLAGS: "-DENABLE_PROMETHEUS=1 -DBUILD_CLIENT=0 -DENABLE_CURSES=FALSE"

- name: Test
run: |
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/lua.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,18 @@ jobs:
- name: Install deps
run: |
source ./util/ci/common.sh
install_linux_deps clang-10 gdb libluajit-5.1-dev
install_linux_deps clang-10 gdb
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: '3.11'
mamba-version: "*"
channels: conda-forge,nodefaults
activate-environment: minetest
environment-file: environment.yml

- name: Build
shell: bash -l {0}
run: |
./util/ci/build.sh
env:
Expand Down
26 changes: 12 additions & 14 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,22 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3

- uses: conda-incubator/setup-miniconda@v3
with:
python-version: '3.11'
mamba-version: "*"
channels: conda-forge,nodefaults
activate-environment: minetest
environment-file: environment.yml

- name: Install deps
run: |
source ./util/ci/common.sh
install_macos_deps
- name: Build
shell: bash -l {0}
run: |
cmake -B build -S . \
-DCMAKE_FIND_FRAMEWORK=LAST \
Expand All @@ -41,24 +51,12 @@ jobs:
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_HEADLESS=FALSE \
-GNinja \
-DSDL2_DIR= \
-DINSTALL_DEVTEST=TRUE \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1
-DICONV_LIBRARY="${CONDA_PREFIX}/lib/libiconv.dylib" \
-DCMAKE_INSTALL_RPATH="${CONDA_PREFIX}/lib"
cmake --build build
cmake --install build
- name: Test
run: |
./build/macos/minetest.app/Contents/MacOS/minetest --run-unittests
# Zipping the built .app preserves permissions on the contained files,
# which the GitHub artifact pipeline would otherwise strip away.
- name: CPack
run: |
cd build
cpack -G ZIP -B macos
- uses: actions/upload-artifact@v3
with:
name: minetest-macos
path: ./build/macos/*.zip
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
[submodule "lib/zmqpp"]
path = lib/zmqpp
url = https://github.com/zeromq/zmqpp.git
[submodule "games/minetest_game"]
path = games/minetest_game
url = https://github.com/minetest/minetest_game.git
[submodule "lib/SDL"]
path = lib/SDL
url = https://github.com/libsdl-org/SDL.git
[submodule "lib/irrlichtmt"]
path = lib/irrlichtmt
url = https://github.com/Astera-org/irrlicht
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
},
"[jsonc]": {
"editor.formatOnSave": true
}
},
"cmake.cmakePath": "/opt/conda/envs/minetest/bin/cmake"
}
2 changes: 0 additions & 2 deletions cmake/Modules/FindZmq.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
mark_as_advanced(ZMQ_LIBRARY ZMQ_INCLUDE_DIR)

find_path(ZMQ_INCLUDE_DIR NAMES zmq.h)
message(STATUS ${ZMQ_INCLUDE_DIR})

find_library(ZMQ_LIBRARY NAMES zmq)
message(STATUS ${ZMQ_LIBRARY})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Zmq DEFAULT_MSG ZMQ_LIBRARY ZMQ_INCLUDE_DIR)
38 changes: 2 additions & 36 deletions cmake/Modules/FindZmqpp.cmake
Original file line number Diff line number Diff line change
@@ -1,41 +1,7 @@
option(ENABLE_SYSTEM_ZMQPP "Use ZMQPP from system" TRUE)
mark_as_advanced(ZMQPP_LIBRARY ZMQPP_INCLUDE_DIR)
set(USE_SYSTEM_ZMQPP FALSE)

message(${CMAKE_SOURCE_DIR})
find_library(ZMQPP_LIBRARY NAMES zmqpp REQUIRED)
find_path(ZMQPP_INCLUDE_DIR NAMES zmqpp.hpp PATH_SUFFIXES zmqpp REQUIRED)


if(ENABLE_SYSTEM_ZMQPP)
find_library(ZMQPP_LIBRARY NAMES zmqpp)
find_path(ZMQPP_INCLUDE_DIR NAMES zmqpp.hpp PATH_SUFFIXES zmqpp)

if(ZMQPP_LIBRARY AND ZMQPP_INCLUDE_DIR)
message (STATUS "Using ZMQPP provided by system.")
set(USE_SYSTEM_ZMQPP TRUE)
else()
message (STATUS "Detecting ZMQPP from system failed.")
endif()

endif()

if(NOT USE_SYSTEM_ZMQPP)
message(STATUS "Using ZMQPP submodule")
find_path(ZMQPP_INCLUDE_DIR NAMES zmqpp/zmqpp.hpp
PATHS
${CMAKE_SOURCE_DIR}/lib/zmqpp/src/
PATH_SUFFIXES zmqpp)

find_library(ZMQPP_LIBRARY NAMES zmqpp
PATHS ${CMAKE_SOURCE_DIR}/lib/zmqpp/build)

message(${ZMQPP_INCLUDE_DIR})
message(${ZMQPP_LIBRARY})

if(ZMQPP_LIBRARY AND ZMQPP_INCLUDE_DIR)
message(STATUS "Using ZMQPP provided by the submodule.")
else()
message(FATAL_ERROR "ZMQPP submodule detection failed, please navigate to lib/zmqpp, initialize the submodule with \"git submodule update --init\", and then use \"make\" to build zmqpp")
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Zmqpp DEFAULT_MSG ZMQPP_LIBRARY ZMQPP_INCLUDE_DIR)
14 changes: 10 additions & 4 deletions doc/compiling/macos.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Compiling on MacOS

Note: the conda environment.yml file currently doesn't work on arm64,
and that's what's tested on the CI (which uses x86-64).
So these instructions should work aren't tested.

## Requirements

- [Homebrew](https://brew.sh/)
Expand All @@ -8,7 +12,7 @@
Install dependencies with homebrew:

```
brew install cmake capnp freetype gettext gmp hiredis jpeg jsoncpp leveldb libogg libpng libvorbis luajit zstd gettext zeromq zmqpp ninja
brew install cmake capnp freetype gettext gmp hiredis jpeg jsoncpp leveldb libogg libpng libvorbis luajit zstd gettext sdl2 zeromq zmqpp ninja
```

## Download
Expand All @@ -22,7 +26,8 @@ cd minetest

## Build

If `conda` is installed, it's a good idea to `conda deactivate` to make sure no conda env (not even base) is active, else it may lead to errors with `iconv` during linking.
Note the `-DICONV_LIBRARY` should only be set if a conda environment is active
(even an empty conda environment seems to have libiconv which conflicts with system iconv).

```bash
cmake -B build -S . \
Expand All @@ -34,11 +39,12 @@ cmake -B build -S . \
-DENABLE_GETTEXT=TRUE \
-DINSTALL_DEVTEST=TRUE \
-DINSTALL_MINETEST_GAME=TRUE \
-DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations"
-DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations" \
-DICONV_LIBRARY="${CONDA_PREFIX}/lib/libiconv.dylib"
cmake --build build
cmake --install build

# M1 Macs w/ MacOS >= BigSur
# arm64 Macs w/ MacOS >= BigSur
codesign --force --deep -s - build/macos/minetest.app
```

Expand Down
Loading

0 comments on commit bbbe3f4

Please sign in to comment.