linux - rust 程序的特定功能仅适用于 Windows
问题描述
这让我很困惑。该程序在具有所需功能的 Windows 和 linux 上都可以正常编译。但是,Linux 上的行为(启用该功能!)与在 Windows 上禁用该功能相同。现在,我浏览了代码(我不是自己写的),据我所知,代码没有特殊的依赖关系或任何原因导致这不起作用。该程序的其他所有内容都可以正常工作!我将留下该功能被编入其中的文件的链接,如果您愿意,您可以浏览存储库的其余部分。我还将粘贴用于编译它的脚本以及我们用作库的另一个程序。我不希望这里的任何人通过所有代码并清楚地告诉我到底哪里出了问题, https://github.com/Putnam3145/auxmos/blob/master/src/reaction/hooks.rs
#!/bin/bash
# REPO MAINTAINERS: KEEP CHANGES TO THIS IN SYNC WITH /tools/LinuxOneShot/SetupProgram/PreCompile.sh
# No ~mso
set -e
set -x
#load dep exports
#need to switch to game dir for Dockerfile weirdness
original_dir=$PWD
cd "$1"
sed -i '1s/^/#define PRELOAD_RSC 0\n/' ./code/_compile_options.dm
. dependencies.sh
cd "$original_dir"
#find out what we have (+e is important for this)
set +e
has_git="$(command -v git)"
has_cargo="$(command -v ~/.cargo/bin/cargo)"
has_sudo="$(command -v sudo)"
has_grep="$(command -v grep)"
has_youtubedl="$(command -v youtube-dl)"
has_pip3="$(command -v pip3)"
set -e
# install cargo if needed
if ! [ -x "$has_cargo" ]; then
echo "Installing rust..."
curl https://sh.rustup.rs -sSf | sh -s -- -y
. ~/.profile
fi
# apt packages, libssl needed by rust-g but not included in TGS barebones install
if ! ( [ -x "$has_git" ] && [ -x "$has_grep" ] && [ -f "/usr/lib/i386-linux-gnu/libssl.so" ] ); then
echo "Installing apt dependencies..."
if ! [ -x "$has_sudo" ]; then
dpkg --add-architecture i386
apt-get update
apt-get install -y git libssl-dev:i386
rm -rf /var/lib/apt/lists/*
else
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y git libssl-dev:i386
sudo rm -rf /var/lib/apt/lists/*
fi
fi
dpkg --add-architecture i386
apt-get update
apt-get install -y lib32z1 pkg-config libssl-dev:i386 libssl-dev libssl1.1:i386
# update rust-g
if [ ! -d "rust-g" ]; then
echo "Cloning rust-g..."
git clone https://github.com/tgstation/rust-g
cd rust-g
~/.cargo/bin/rustup target add i686-unknown-linux-gnu
else
echo "Fetching rust-g..."
cd rust-g
git fetch
~/.cargo/bin/rustup target add i686-unknown-linux-gnu
fi
echo "Deploying rust-g..."
git checkout "$RUST_G_VERSION"
env PKG_CONFIG_ALLOW_CROSS=1 ~/.cargo/bin/cargo build --release --target=i686-unknown-linux-gnu
mv -f target/i686-unknown-linux-gnu/release/librust_g.so "$1/librust_g.so"
cd ..
# Auxtools dependencies
apt-get install -y build-essential g++-multilib libc6-i386 libstdc++6:i386
# Update auxmos
if [ ! -d "auxmos" ]; then
echo "Cloning auxmos..."
git clone https://github.com/Putnam3145/auxmos
cd auxmos
~/.cargo/bin/rustup target add i686-unknown-linux-gnu
else
echo "Fetching auxmos..."
cd auxmos
git fetch
~/.cargo/bin/rustup target add i686-unknown-linux-gnu
fi
echo "Deploying auxmos..."
git checkout "$AUXMOS_VERSION"
env PKG_CONFIG_ALLOW_CROSS=1 ~/.cargo/bin/cargo rustc --target=i686-unknown-linux-gnu --release --features reaction_hooks,plasma_fire_hook,trit_fire_hook,fusion_hook,generic_fire_hook -- -C target-cpu=native
mv -f target/i686-unknown-linux-gnu/release/libauxmos.so "$1/libauxmos.so"
cd ..
# install or update youtube-dl when not present, or if it is present with pip3,
# which we assume was used to install it
if ! [ -x "$has_youtubedl" ]; then
echo "Installing youtube-dl with pip3..."
if ! [ -x "$has_sudo" ]; then
apt-get install -y python3 python3-pip
else
sudo apt-get install -y python3 python3-pip
fi
pip3 install youtube-dl
elif [ -x "$has_pip3" ]; then
echo "Ensuring youtube-dl is up-to-date with pip3..."
pip3 install youtube-dl -U
fi
# compile tgui
echo "Compiling tgui..."
cd "$1"
chmod +x tools/bootstrap/node # Workaround for https://github.com/tgstation/tgstation-server/issues/1167
env TG_BOOTSTRAP_CACHE="$original_dir" TG_BOOTSTRAP_NODE_LINUX=1 CBT_BUILD_MODE="TGS" tools/bootstrap/node tools/build/build.js
所以,为了进一步解释,这个程序本质上是我们的游戏服务器使用的一个外部库,它运行在 BYOND 引擎上,这个库本质上是通过使用钩子来处理一项计算成本高的任务(管理大气模拟)(我不明白所有说实话。)我们正在寻找的具体功能是让程序正确处理大气反应(火),实际发生的是它不处理它们,所以永远不会发生火灾。如果我没有为程序指定任何 --features 并在 Windows 上使用它,则行为与此相同。
解决方案
推荐阅读
- r - 使用 as.Date 和 as_date 将 `dttm` 转换为 `date` 格式会在 R 中给出不同的结果
- json - 尽管文件存在于上述目录中,为什么我没有收到此类文件或目录错误?
- java - 全局运行 Maven 插件
- dialogflow-es - 在 agentId 的平台响应中找不到 RichResponse 或 SystemIntent:
- vuetify.js - 使用 Vuetify 2 的父 v-data-table 中可扩展子组件的问题
- javascript - 如何将正则表达式 Python 转换为正则表达式 javascript
- c - 生成 10 个介于 -1.5 和 1.5 之间的随机数并将它们写入 ran.dat 文件
- mysql - 按 MySQL 中两个选择的差异排序
- c++ - 如何在 C++ 代码之上使用标准 Xcode GUI
- java - 需要实体中电子邮件属性的特定域