From 9de347df21013dd76696d0d8c2327195250c5388 Mon Sep 17 00:00:00 2001 From: dsisnero Date: Wed, 11 Oct 2023 11:07:28 -0600 Subject: [PATCH 1/2] add MsvcEnv.with_env command to enable Visual Studio Command Environment This enables a Visual Studio Command Environment when run on windows so that "nmake" is on PATH --- shard.yml | 5 +++++ src/ext/build_ext.cr | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/shard.yml b/shard.yml index 48a5626..d843b94 100644 --- a/shard.yml +++ b/shard.yml @@ -4,6 +4,11 @@ version: 3.1.2 authors: - Konstantin Makarchev +development_dependencies: + msvc_env: + github: dsisnero/msvc_env + version: ~> 0.7.1 + scripts: postinstall: crystal src/ext/build_ext.cr diff --git a/src/ext/build_ext.cr b/src/ext/build_ext.cr index 2e36dcb..4966218 100644 --- a/src/ext/build_ext.cr +++ b/src/ext/build_ext.cr @@ -39,5 +39,14 @@ cmake_args = [ cmake_args << "Unix Makefiles" {% end %} + +{% if flag?(:win32) %} +require "msvc_env/env" +MsvcEnv.with_env do cmd("cmake", cmake_args, lexbor_build_path) cmd("cmake", ["--build", ".", "--config", "Release", "-j", {System.cpu_count, 4}.min.to_s], lexbor_build_path) +end +{% else %} +cmd("cmake", cmake_args, lexbor_build_path) +cmd("cmake", ["--build", ".", "--config", "Release", "-j", {System.cpu_count, 4}.min.to_s], lexbor_build_path) +{% end %} From 498916546f3e9cf71ff3c38696b41cf637d10e03 Mon Sep 17 00:00:00 2001 From: dsisnero Date: Wed, 11 Oct 2023 11:47:52 -0600 Subject: [PATCH 2/2] Update shard.yml to make sure it downloads msvc_env --- shard.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shard.yml b/shard.yml index d843b94..de2e9a4 100644 --- a/shard.yml +++ b/shard.yml @@ -4,7 +4,7 @@ version: 3.1.2 authors: - Konstantin Makarchev -development_dependencies: +dependencies: msvc_env: github: dsisnero/msvc_env version: ~> 0.7.1