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

docs: changes to buildlinux #1015

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
run: cd build && make -j2

- name: Run unit tests
run: cd build/library && ./unittest
run: cd build && ctest -VV
env:
DPP_UNIT_TEST_TOKEN: ${{secrets.DPP_UNIT_TEST_TOKEN}}
TEST_GUILD_ID: ${{secrets.TEST_GUILD_ID}}
Expand Down Expand Up @@ -133,8 +133,15 @@ jobs:
macos:
permissions:
contents: write
name: macOS x64
runs-on: macos-latest
name: macOS ${{matrix.cfg.arch}} (${{matrix.cfg.cpp-version}})
runs-on: ${{matrix.cfg.os}}
strategy:
fail-fast: false # Don't fail everything if one fails. We want to test each OS/Compiler individually
matrix:
# arm64 is a self-hosted runner on a Mac M2 Mini, ran inside a virtual machine by Archie Jaskowicz.
cfg:
- { arch: 'x64', concurrency: 3, os: macos-latest, cpp-version: clang++-14, cmake-flags: '', cpack: 'no' }
- { arch: 'arm64', concurrency: 2, os: [self-hosted, ARM64, macOS], cpp-version: clang++-15, cmake-flags: '', cpack: 'no' }
steps:
- name: Harden Runner
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
Expand All @@ -145,18 +152,21 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install homebrew packages
run: brew install cmake make libsodium opus openssl
run: brew install cmake make libsodium opus openssl pkg-config

- name: Generate CMake
run: mkdir build && cd build && cmake -DDPP_NO_VCPKG=ON -DCMAKE_BUILD_TYPE=Release -DDPP_CORO=ON -DAVX_TYPE=AVX0 ..
env:
DONT_RUN_VCPKG: true

- name: Build Project
run: cd build && make -j3
run: cd build && make -j${{ matrix.cfg.concurrency }}
env:
DONT_RUN_VCPKG: true

- name: Run offline unit tests
run: cd build && ctest -VV

windows: # Windows x64 and x86 build matrix
permissions:
contents: write
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ config.json
.misspell-fixer.ignore
compile_commands.json
src/dpp/dpp.rc
.DS_STORE
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ if (NOT DPP_NO_VCPKG AND EXISTS "${_VCPKG_ROOT_DIR}")
HOMEPAGE_URL "https://dpp.dev/"
DESCRIPTION "An incredibly lightweight C++ Discord library."
)

# Required before we add any subdirectories.
if (DPP_BUILD_TEST)
enable_testing(${CMAKE_CURRENT_SOURCE_DIR})
endif()

add_subdirectory(library-vcpkg)
else()
set(PROJECT_NAME "libdpp")
Expand All @@ -79,6 +85,12 @@ else()
HOMEPAGE_URL "https://dpp.dev/"
DESCRIPTION "An incredibly lightweight C++ Discord library."
)

# Required before we add any subdirectories.
if (DPP_BUILD_TEST)
enable_testing(${CMAKE_CURRENT_SOURCE_DIR})
endif()

add_subdirectory(library)
endif()

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ You can find more examples in our [example page](https://dpp.dev/example-program

The library runs ideally on **Linux**.

### Mac OS X and FreeBSD and OpenBSD
### Mac OS X, FreeBSD, and OpenBSD

The library is well-functional and stable on **Mac OS X**, **FreeBSD**, and **OpenBSD** too.
The library is well-functional and stable on **Mac OS X**, **FreeBSD**, and **OpenBSD** too!

### Raspberry Pi

Expand Down
6 changes: 4 additions & 2 deletions buildtools/emojis.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
namespace dpp {

/**
* The unicode emojis in this namespace are auto-generated from {$url}
* @brief Emoji unicodes.
*
* If you want to use this, you have to pull the header in separately. e.g.
* @note The unicode emojis in this namespace are auto-generated from https://raw.githubusercontent.com/ArkinSolomon/discord-emoji-converter/master/emojis.json
*
* @warning If you want to use this, you have to pull the header in separately. For example:
* ```cpp
* #include <dpp/dpp.h>
* #include <dpp/unicode_emoji.h>
Expand Down
12 changes: 6 additions & 6 deletions docpages/INDEX.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ You can find further releases in other architectures and formats or the source c
### Linux
The library runs ideally on **Linux**.

### Mac OS X and FreeBSD
The library is well-functional and stable on **Mac OS X** and **FreeBSD** too.
### Mac OS X, FreeBSD, and OpenBSD
The library is well-functional and stable on **Mac OS X**, **FreeBSD**, and **OpenBSD** too!

### Raspberry Pi
For running your bot on a **Raspberry Pi**, we offer a prebuilt .deb package for ARM64, ARM6, and ARM7 so that you do not have to wait for it to compile.
Expand All @@ -63,10 +63,10 @@ The library should work fine on other operating systems as well, and if you run
## Getting started
* [GitHub Repository](https://github.com/brainboxdotcc/DPP)
* [Discord Server](https://discord.gg/dpp)
* \ref frequently-asked-questions "Frequently Asked Questions"
* \ref installing "Installing D++"
* \ref example-programs "Example Programs"
* \ref glossary-of-common-discord-terms "Commonly used terms"
* \ref frequently-asked-questions
* \ref installing
* \ref example-programs
* \ref glossary-of-common-discord-terms

## Architecture
* \ref clusters-shards-guilds
Expand Down
28 changes: 24 additions & 4 deletions docpages/building/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

\note You might not need to build a copy of the library for Linux - precompiled deb files for 64 bit and 32 bit Debian and Ubuntu are provided in the GitHub version releases. Unless you are on a different Linux distribution which does not support the installation of deb files, or wish to submit fixes and enhancements to the library itself you should have an easier time installing the precompiled version instead.

## 1. Build Source Code

## 1. Copy & Build Source code
```bash
git clone https://github.com/brainboxdotcc/DPP
cd DPP/
cmake -B ./build
cmake --build ./build -j8
```
Expand All @@ -23,7 +24,7 @@ sudo make install
If you want to install the library, its dependencies, and header files to a different directory, specify this directory when running `cmake`:

```bash
cmake .. -DCMAKE_INSTALL_PREFIX=/path/to/install
cmake -B ./build -DCMAKE_INSTALL_PREFIX=/path/to/install
```

Then once the build is complete, run `make install` to install to the location you specified.
Expand All @@ -36,12 +37,31 @@ Once installed to the `/usr/local` directory, you can make use of the library in
g++ -std=c++17 mydppbot.cpp -o dppbot -ldpp
```

If you are on **Arch Linux**:

- You need to give proper permission to `libdpp.so` and `libdpp.so.10.0.29`
```bash
sudo chmod 644 /usr/local/lib/libdpp.so && sudo chmod +x /usr/local/lib/dpp.so
sudo chmod 644 /usr/local/lib/libdpp.so.10.0.29 && sudo chmod +x /usr/local/lib/dpp.so.10.0.29
```

- You need to specify the location for `libdpp.so` when compilling:

```bash
g++ -std=c++17 -I/usr/local/include mydppbot.cpp -o dppbot /usr/local/lib/libdpp.so -Wl,-rpath,/usr/local/lib
```

The important flags in this command-line are:

* `-std=c++17` - Required to compile the headers
* `-ldpp` - Link to libdpp.so
* `-L/usr/local/lib` - Required to tell the linker where libdpp is located
* `-I/usr/local/include` - Required to tell the linker where dpp headers are located
* `mydppbot.cpp` - Your source code
* `dppbot` - The name of the executable to make
* `-ldpp` - Link to libdpp.so
* `/usr/local/lib/libdpp.so` - Required to specifies the path to the shared library
* `-Wl` - Required to pass options directly to the linker
* `-rpath,/usr/local/lib` - Required to specifies the runtime library search path

\include{doc} install_prebuilt_footer.dox

Expand Down
6 changes: 4 additions & 2 deletions docpages/building/osx.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ Before compiling make sure you have all the tools installed.
## 2. Install External Dependencies

```bash
brew install openssl
brew install openssl pkgconfig
```

\note Usually, you do not need pkgconfig. However, it seems that it throws errors about openssl without.

For voice support, additional dependencies are required:

```bash
Expand Down Expand Up @@ -43,7 +45,7 @@ If you want to install the library, its dependencies, and header files to a diff
cmake .. -DCMAKE_INSTALL_PREFIX=/path/to/install
```

Then once the build is complete, run `make install` to install to the location you specified.
Then once the build is complete, run `sudo make install` to install to the location you specified.

## 6. Using the Library

Expand Down
5 changes: 2 additions & 3 deletions docpages/example_code/clearing_slashcommands.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <dpp/dpp.h>

int main()
{
int main() {
dpp::cluster bot("token");

bot.on_log(dpp::utility::cout_logger());
Expand All @@ -12,7 +11,7 @@ int main()
if (dpp::run_once<struct clear_bot_commands>()) {
/* Now, we're going to wipe our commands */
bot.global_bulk_command_delete();
/* This one requires a guild id, otherwise it won't what guild's commands it needs to wipe! */
/* This one requires a guild id, otherwise it won't know what guild's commands it needs to wipe! */
bot.guild_bulk_command_delete(857692897221033129);
}

Expand Down
2 changes: 1 addition & 1 deletion docpages/example_programs/the_basics/firstbot.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ The `event.reply` function (dpp::slashcommand_t::reply) replies to a slash comma

To make the bot start, we must call the dpp::cluster::start method, e.g. in our program by using `bot.start(dpp::st_wait)`.

We also add a line to tell the library to output all its log information to the console, `bot.on_log(dpp::utility::cout_logger());` - if you wanted to do something more advanced, you can replace this parameter with a lambda just like all other events.
We also add a line to tell the library to output all its log information to the console, use `bot.on_log(dpp::utility::cout_logger());` (dpp::utility::cout_logger) - if you wanted to do something more advanced, you can replace this parameter with a lambda just like all other events.

The parameter which we set to false indicates if the function should return once all shards are created. Passing dpp::st_wait here tells the program you do not need to do anything once `bot.start` is called.

Expand Down
4 changes: 3 additions & 1 deletion docpages/install/install-arch-aur.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ or use your favourite package manager:

```bash
# example with `yay` (without root)
yay -Sy dpp
yay -Syu dpp
```

\note The package is currently outdated. We are looking for a new maintainer. For now, please use `dpp-git` or build it from \ref buildlinux "source".

This will do the following three things:

- Clone the D++ AUR repository to a directory called `dpp`
Expand Down
6 changes: 2 additions & 4 deletions include/dpp/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -1368,11 +1368,9 @@ class DPP_EXPORT cluster {
* @param method Method, e.g. GET, POST
* @param postdata Post data (usually JSON encoded)
* @param callback Function to call when the HTTP call completes. The callback parameter will contain amongst other things, the decoded json.
* @param filename List of filenames to post for POST requests (for uploading files)
* @param filecontent List of file content to post for POST requests (for uploading files)
* @param filemimetypes List of mime types for each file to post for POST requests (for uploading files)
* @param file_data List of files to post for POST requests (for uploading files)
*/
void post_rest_multipart(const std::string &endpoint, const std::string &major_parameters, const std::string &parameters, http_method method, const std::string &postdata, json_encode_t callback, const std::vector<std::string> &filename = {}, const std::vector<std::string>& filecontent = {}, const std::vector<std::string>& filemimetypes = {});
void post_rest_multipart(const std::string &endpoint, const std::string &major_parameters, const std::string &parameters, http_method method, const std::string &postdata, json_encode_t callback, const std::vector<message_file_data> &file_data = {});

/**
* @brief Make a HTTP(S) request. For use when wanting asynchronous access to HTTP APIs outside of Discord.
Expand Down
16 changes: 12 additions & 4 deletions include/dpp/discordvoiceclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,10 @@ class DPP_EXPORT discord_voice_client : public websocket_client
snowflake channel_id;

/**
* @brief The audio type to be sent. The default type is recorded audio.
* @brief The audio type to be sent.
*
* @note On Windows, the default type is overlap audio.
* On all other platforms, it is recorded audio.
*
* If the audio is recorded, the sending of audio packets is throttled.
* Otherwise, if the audio is live, the sending is not throttled.
Expand Down Expand Up @@ -594,10 +597,15 @@ class DPP_EXPORT discord_voice_client : public websocket_client
*/
enum send_audio_type_t
{
satype_recorded_audio,
satype_live_audio,
satype_recorded_audio,
satype_live_audio,
satype_overlap_audio
} send_audio_type = satype_recorded_audio;
} send_audio_type =
#ifdef _WIN32
satype_overlap_audio;
#else
satype_recorded_audio;
#endif

/**
* @brief Sets the gain for the specified user.
Expand Down
6 changes: 3 additions & 3 deletions include/dpp/emoji.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ enum emoji_flags : uint8_t {
/**
* @brief Managed (introduced by application)
*/
e_managed = 0b00000010,
e_managed = 0b00000010,

/**
* @brief Animated emoji.
*/
e_animated = 0b00000100,
e_animated = 0b00000100,

/**
* @brief Available (false if the guild doesn't meet boosting criteria, etc)
*/
e_available = 0b00001000,
e_available = 0b00001000,
};

/**
Expand Down
5 changes: 4 additions & 1 deletion include/dpp/isa/avx.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ namespace dpp {
}

protected:
alignas(16) float values[byte_blocks_per_register]{};///< Array for storing the values to be loaded/stored.
/**
* @brief Array for storing the values to be loaded/stored.
*/
alignas(16) float values[byte_blocks_per_register]{};

/**
* @brief Stores values from a 128-bit AVX vector to a storage location.
Expand Down
5 changes: 4 additions & 1 deletion include/dpp/isa/avx2.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ namespace dpp {
}

protected:
alignas(32) float values[byte_blocks_per_register]{};///< Array for storing the values to be loaded/stored.
/**
* @brief Array for storing the values to be loaded/stored.
*/
alignas(32) float values[byte_blocks_per_register]{};

/**
* @brief Stores values from a 256-bit AVX2 vector to a storage location.
Expand Down
5 changes: 4 additions & 1 deletion include/dpp/isa/avx512.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ namespace dpp {
}

protected:
alignas(64) float values[byte_blocks_per_register]{};///< Array for storing the values to be loaded/stored.
/**
* @brief Array for storing the values to be loaded/stored.
*/
alignas(64) float values[byte_blocks_per_register]{};

/**
* @brief Stores values from a 512-bit AVX512 vector to a storage location.
Expand Down
Loading
Loading