@@ -71,6 +71,14 @@ def _ecsact_repo_impl(rctx):
71
71
_download_repo (rctx , rctx .attr .platform )
72
72
73
73
_HOST_BUILD_CONTENT = """
74
+ load("@rules_ecsact//ecsact:toolchain.bzl", "ecsact_toolchain")
75
+
76
+ package(default_visibility = ["//visibility:public"])
77
+
78
+ ecsact_toolchain(
79
+ name = "ecsact_toolchain",
80
+ target_tool_path = "{target_tool_path}",
81
+ )
74
82
"""
75
83
76
84
_CODEGEN_BUILD_CONTENT = """
@@ -109,8 +117,40 @@ ecsact_codegen_plugin(
109
117
)
110
118
"""
111
119
120
+ _FIND_ECSACT_SDK_PWSH = """
121
+ $EcsactSdkInfo = Get-AppPackage EcsactSdk
122
+ if($EcsactSdkInfo) {
123
+ echo $EcsactSdkInfo.InstallLocation
124
+ }
125
+ """
126
+
112
127
def _ecsact_host_repo_impl (rctx ):
113
- rctx .file ("BUILD.bazel" , _HOST_BUILD_CONTENT )
128
+ is_windows = rctx .os .name .startswith ("windows" )
129
+ exe_extension = ""
130
+ if is_windows :
131
+ exe_extension = ".exe"
132
+ ecsact_executable_name = "ecsact" + exe_extension
133
+
134
+ ecsact_path = rctx .which (ecsact_executable_name )
135
+
136
+ if ecsact_path == None and is_windows :
137
+ pwsh = rctx .which ("pwsh.exe" )
138
+ if pwsh == None :
139
+ fail ("Cannot find pwsh.exe" )
140
+ rctx .file ("FindEcsactSdk.ps1" , _FIND_ECSACT_SDK_PWSH )
141
+ exec_result = rctx .execute ([pwsh , "FindEcsactSdk.ps1" ])
142
+ ecsact_sdk_install_dir = exec_result .stdout
143
+ if ecsact_sdk_install_dir :
144
+ ecsact_sdk_install_dir = ecsact_sdk_install_dir .replace ("\\ " , "/" ).strip ()
145
+ ecsact_path = ecsact_sdk_install_dir + "/bin/ecsact.exe"
146
+
147
+ if ecsact_path == None :
148
+ rctx .file ("BUILD.bazel" , "" )
149
+ else :
150
+ rctx .file ("BUILD.bazel" , _HOST_BUILD_CONTENT .format (
151
+ target_tool_path = ecsact_path ,
152
+ ))
153
+
114
154
rctx .file ("codegen_plugins/BUILD.bazel" , _CODEGEN_BUILD_CONTENT )
115
155
116
156
ecsact_repository = repository_rule (
0 commit comments