1
Fork 0

Add initial files

This commit is contained in:
Joshua Goins 2023-12-21 20:18:42 -05:00
commit 9acab0626a
5 changed files with 92 additions and 0 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
.clang-format
/*build*
/sdk

16
CMakeLists.txt Normal file
View file

@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.10)
project(steamwrap)
set(CMAKE_CXX_STANDARD 17)
add_library(Steamworks IMPORTED SHARED)
set_target_properties(Steamworks PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${STEAMWORKS_INCLUDE_DIR}
IMPORTED_LOCATION ${STEAMWORKS_LIBRARIES})
add_executable(steamwrap main.cpp)
target_link_libraries(steamwrap PRIVATE Steamworks)
set_target_properties(steamwrap
PROPERTIES
BUILD_RPATH "$ORIGIN"
)

19
LICENSE Normal file
View file

@ -0,0 +1,19 @@
Copyright (c) 2023 Joshua Goins
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

18
README.md Normal file
View file

@ -0,0 +1,18 @@
# steamwrap
Used for [Astra](https://git.sr.ht/~redstrate/astra) to initialize and communicate with the Steam API.
Due to restrictions on how the Steamworks SDK is distributed, I have to build it locally. Astra downloads a binary version of steamwrap from a distribution server during Flatpak build alongside the redistributable.
## Building
Remember that newer glibc/++ won't work when it's inside the Steam Linux Runtime, so I recommend using distrobox to build steamwrap:
```shell
$ distrobox create --name test --init --image debian:10 --additional-packages "systemd libpam-systemd" # Debian 10 is the base of Steam Linux Runtime 2.0
$ distrobox enter test
$ mkdir build
$ cd build
$ cmake -DSTEAMWORKS_LIBRARIES=<location of steam sdk>/redistributable_bin/linux64/libsteam_api.so -DSTEAMWORKS_INCLUDE_DIR=<location of steam sdk>/public/ ..
$ make
```

36
main.cpp Normal file
View file

@ -0,0 +1,36 @@
#include <iostream>
#include <steam/steam_api.h>
#include <cstdlib>
int main(int argc, char *argv[]) {
putenv("SteamAppId=39210");
putenv("SteamGameId=39210");
std::cout << "Previous LD_LIBRARY_PATH:" << getenv("LD_LIBRARY_PATH") << std::endl;
std::string newEnv = std::string("PREVIOUS_LD_LIBRARY_PATH=") + getenv("LD_LIBRARY_PATH");
putenv(const_cast<char*>(newEnv.c_str()));
putenv("LD_LIBRARY_PATH=");
if (!SteamAPI_Init()) {
throw std::runtime_error("Failed to initialize steam api!");
}
std::cout << "Initialized Steam API..." << std::endl;
std::string args;
for (int i = 1; i < argc; i++) {
args += std::string(argv[i]) + " ";
}
std::cout << args.c_str() << std::endl;
system(args.c_str());
SteamAPI_Shutdown();
std::cout << "Shutdown!" << std::endl;
return 0;
}