Skip to content

Commit

Permalink
build k8s version as debug when project is built in debug, and releas…
Browse files Browse the repository at this point in the history
…e when project is built with --release
  • Loading branch information
DominicBurkart committed Nov 4, 2020
1 parent 42fb92a commit caa1a09
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
4 changes: 2 additions & 2 deletions turbolift_internals/src/build_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::path::{Path, PathBuf};
use std::process::Command;
use std::str::FromStr;

use crate::utils::symlink_dir;
use crate::utils::{symlink_dir, RELEASE_FLAG};

pub fn edit_cargo_file(
original_project_source_dir: &Path,
Expand Down Expand Up @@ -105,7 +105,7 @@ pub fn lint(proj_path: &Path) -> anyhow::Result<()> {
pub fn make_executable(proj_path: &Path, dest: Option<&Path>) -> anyhow::Result<()> {
let status = Command::new("cargo")
.current_dir(proj_path)
.args("build --release".split(' '))
.args(format!("build {}", RELEASE_FLAG).as_str().trim().split(' '))
.status()?;

if !status.success() {
Expand Down
12 changes: 9 additions & 3 deletions turbolift_internals/src/kubernetes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use url::Url;
use crate::distributed_platform::{
ArgsString, DistributionPlatform, DistributionResult, JsonResponse,
};
use crate::utils::RELEASE_FLAG;

const TURBOLIFT_K8S_NAMESPACE: &str = "default";
const LOCAL_REGISTRY_URL: &str = "http://localhost:32000";
Expand Down Expand Up @@ -287,9 +288,14 @@ RUN cat {} | tar xvf -
WORKDIR {}
# build and run release
RUN RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo build
CMD RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo run localhost:5000",
tar_file_name, tar_file_name, tar_file_name, function_name
RUN RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo build {}
CMD RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo run {} localhost:5000",
tar_file_name,
tar_file_name,
tar_file_name,
function_name,
RELEASE_FLAG,
RELEASE_FLAG
);
std::fs::write(&dockerfile_path, docker_file)?;
std::fs::write(&tar_path, project_tar)?;
Expand Down
15 changes: 15 additions & 0 deletions turbolift_internals/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,18 @@ pub use std::os::unix::fs::symlink as symlink_dir;

#[cfg(target_family = "windows")]
pub use std::os::windows::fs::symlink_dir;

#[cfg(not(debug_assertions))]
pub const IS_RELEASE: bool = true;

#[cfg(debug_assertions)]
pub const IS_RELEASE: bool = false;

/// is --release if built with release flag, otherwise empty string
pub const RELEASE_FLAG: &str = {
if IS_RELEASE {
"--release"
} else {
""
}
};

0 comments on commit caa1a09

Please sign in to comment.