From da319e71ece547f59c3c1f71a9f30e372a9eee60 Mon Sep 17 00:00:00 2001
From: Ben Wallis <atomyc@gmail.com>
Date: Sat, 26 Jun 2021 16:43:39 +0100
Subject: [PATCH] Added default-publish feature and updated build scripts.

---
 .gitlab/CI/build.gitlab-ci.yml | 12 +++++++++---
 .gitlab/CI/check.gitlab-ci.yml |  4 +++-
 voxygen/Cargo.toml             |  7 ++++++-
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/.gitlab/CI/build.gitlab-ci.yml b/.gitlab/CI/build.gitlab-ci.yml
index fa6cf2ce33..e0eddc8959 100644
--- a/.gitlab/CI/build.gitlab-ci.yml
+++ b/.gitlab/CI/build.gitlab-ci.yml
@@ -61,7 +61,9 @@ coverage:
   script:
     - ln -s /dockercache/target target
     - rm -r target/release/incremental/veloren_* || echo "all good" # TMP FIX FOR 2021-03-22-nightly
-    - VELOREN_USERDATA_STRATEGY=executable cargo build --release
+    - export VELOREN_USERDATA_STRATEGY=executable
+    - cargo build --release -p veloren-voxygen --no-default-features --features default-publish
+    - cargo build --release -p veloren-server-cli
     - cp -r target/release/veloren-server-cli $CI_PROJECT_DIR
     - cp -r target/release/veloren-voxygen $CI_PROJECT_DIR
   artifacts:
@@ -79,7 +81,9 @@ coverage:
     - update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
     - ln -s /dockercache/target target
     - rm -r target/release/incremental/veloren_* || echo "all good" # TMP FIX FOR 2021-03-22-nightly
-    - VELOREN_USERDATA_STRATEGY=executable cargo build --target=x86_64-pc-windows-gnu --release
+    - export VELOREN_USERDATA_STRATEGY=executable
+    - cargo build --target=x86_64-pc-windows-gnu --release -p veloren-voxygen --no-default-features --features default-publish
+    - cargo build --target=x86_64-pc-windows-gnu --release -p veloren-server-cli
     - cp -r target/x86_64-pc-windows-gnu/release/veloren-server-cli.exe $CI_PROJECT_DIR
     - cp -r target/x86_64-pc-windows-gnu/release/veloren-voxygen.exe $CI_PROJECT_DIR
     - cp /usr/lib/gcc/x86_64-w64-mingw32/7.3-posix/libgcc_s_seh-1.dll $CI_PROJECT_DIR
@@ -107,7 +111,9 @@ coverage:
     - export RUSTFLAGS="-D warnings"
   script:
     - export MACOSX_DEPLOYMENT_TARGET="10.13"
-    - VELOREN_USERDATA_STRATEGY=executable cargo build --release
+    - export VELOREN_USERDATA_STRATEGY=executable
+    - cargo build --release -p veloren-voxygen --no-default-features --features default-publish
+    - cargo build --release -p veloren-server-cli
     - cp -r target/release/veloren-server-cli $CI_PROJECT_DIR
     - cp -r target/release/veloren-voxygen $CI_PROJECT_DIR
   artifacts:
diff --git a/.gitlab/CI/check.gitlab-ci.yml b/.gitlab/CI/check.gitlab-ci.yml
index 51f306d8e8..2f5b0a1490 100644
--- a/.gitlab/CI/check.gitlab-ci.yml
+++ b/.gitlab/CI/check.gitlab-ci.yml
@@ -6,7 +6,9 @@ code-quality:
   script:
     - ln -s /dockercache/target target
     - rm -r target/debug/incremental/* || echo "all good" # TMP FIX FOR 2021-03-22-nightly
-    - cargo clippy --all-targets --locked  --features="bin_csv,bin_graphviz,bin_bot,asset_tweak" -- -D warnings
+    - cargo clippy --all-targets --locked --features="bin_csv,bin_graphviz,bin_bot,asset_tweak" -- -D warnings
+    # Ensure that the veloren-voxygen default-publish feature builds as it excludes some default features
+    - cargo clippy -p veloren-voxygen --locked --no-default-features --features="default-publish" -- -D warnings
     - cargo fmt --all -- --check
 
 security:
diff --git a/voxygen/Cargo.toml b/voxygen/Cargo.toml
index dfc7fcb121..c24e505d36 100644
--- a/voxygen/Cargo.toml
+++ b/voxygen/Cargo.toml
@@ -28,7 +28,12 @@ simd = ["vek/platform_intrinsics"]
 tracy = ["profiling", "profiling/profile-with-tracy", "common-frontend/tracy"]
 plugins = ["client/plugins"]
 
-default = ["singleplayer", "native-dialog", "plugins", "simd"]
+# We don't ship egui with published release builds so a separate feature is required that excludes it.
+# This feature has been added ahead of the egui merge to allow time for Flatpak, AUR and Nix to be updated
+# to ensure there isn't any period of time where we're shipping the egui-ui feature enabled by default.
+# This comment will be updated after MR 2253 merges.
+default-publish = ["singleplayer", "native-dialog", "plugins", "simd"]
+default = ["default-publish"]
 
 [dependencies]
 client = {package = "veloren-client", path = "../client"}