diff --git a/cli/build_go.bat b/cli/build_go.bat new file mode 100644 index 0000000000000..d47dc0b9b0e19 --- /dev/null +++ b/cli/build_go.bat @@ -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% diff --git a/cli/build_turbo.bat b/cli/build_turbo.bat new file mode 100644 index 0000000000000..399111a1aa40a --- /dev/null +++ b/cli/build_turbo.bat @@ -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 diff --git a/crates/turborepo/build.rs b/crates/turborepo/build.rs index 8e6cfd07c5ffb..bf57a1077ac43 100644 --- a/crates/turborepo/build.rs +++ b/crates/turborepo/build.rs @@ -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"); @@ -14,8 +13,6 @@ 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" @@ -23,7 +20,19 @@ fn build_local_go_binary(profile: String) -> PathBuf { "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())