Skip to content

Commit

Permalink
feat(turborepo): Scripts to build a debug version on windows (#5007)
Browse files Browse the repository at this point in the history
Co-authored-by: Greg Soltis <Greg Soltis>
  • Loading branch information
Greg Soltis authored Jun 22, 2023
1 parent 98d898b commit 33f2d25
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
17 changes: 17 additions & 0 deletions cli/build_go.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cd ..\crates\turborepo-ffi
cargo build --target x86_64-pc-windows-gnu --target-dir .\target
if %errorlevel% neq 0 exit /b %errorlevel%
copy .\target\x86_64-pc-windows-gnu\debug\libturborepo_ffi.a ..\..\cli\internal\ffi\libturborepo_ffi_windows_amd64.a
copy .\bindings.h ..\..\cli\internal\ffi\bindings.h

cd ..\..\cli

protoc -I..\crates\ ..\crates\turborepo-ffi\messages.proto --go_out=.\internal\
if %errorlevel% neq 0 exit /b %errorlevel%

protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative internal\turbodprotocol\turbod.proto
if %errorlevel% neq 0 exit /b %errorlevel%

SET CGO_ENABLED=1
go build -tags=rust -o go-turbo.exe .\cmd\turbo
if %errorlevel% neq 0 exit /b %errorlevel%
6 changes: 6 additions & 0 deletions cli/build_turbo.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cd ..\crates\turborepo
cargo build --target x86_64-pc-windows-gnu
if %errorlevel% neq 0 exit /b %errorlevel%

copy ..\..\target\x86_64-pc-windows-gnu\debug\turbo.exe ..\..\target\debug\turbo.exe
cd ..\..\cli
17 changes: 13 additions & 4 deletions crates/turborepo/build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::{env, fs, path::PathBuf, process::Command};

fn main() {
println!("cargo:rerun-if-changed=../../cli");
let profile = env::var("PROFILE").unwrap();
let is_ci_release =
&profile == "release" && matches!(env::var("RELEASE_TURBO_CLI"), Ok(v) if v == "true");
Expand All @@ -14,16 +13,26 @@ fn main() {
fn build_local_go_binary(profile: String) -> PathBuf {
let cli_path = cli_path();
let target = build_target::target().unwrap();
let mut cmd = Command::new("make");
cmd.current_dir(&cli_path);

let go_binary_name = if target.os == build_target::Os::Windows {
"go-turbo.exe"
} else {
"go-turbo"
};

cmd.arg(go_binary_name);
#[cfg(not(windows))]
let mut cmd = {
let mut cmd = Command::new("make");
cmd.current_dir(&cli_path);
cmd.arg(go_binary_name);
cmd
};
#[cfg(windows)]
let mut cmd = {
let mut cmd = Command::new(cli_path.join("build_go.bat"));
cmd.current_dir(&cli_path);
cmd
};

assert!(
cmd.stdout(std::process::Stdio::inherit())
Expand Down

0 comments on commit 33f2d25

Please sign in to comment.