Skip to content

Commit 4d5ce70

Browse files
authored
Dependencies and rules refactoring for the C# driver deployment (#521)
## What is the goal of this PR? We prepare tools for the C# driver release, namely and clean all the old TODOs left from the initial PR. ## What are the changes implemented in this PR? Added: * nuget deployment URLs for referencing from the C# bazel rules. Updated: * Refactored the bazel rule for native C# library generation. Cleaned TODOs.
1 parent cb6c94e commit 4d5ce70

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

builder/swig/csharp.bzl

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

55

6-
# TODO: Generalise and move the same functions (used by java, python, csharp)
7-
# to a base file, add reusage where possible.
8-
96
load("@rules_dotnet//dotnet:defs.bzl", "csharp_library")
107
load("@rules_dotnet//dotnet/private:providers.bzl", "DotnetAssemblyCompileInfo", "DotnetAssemblyRuntimeInfo")
118

@@ -98,7 +95,7 @@ swig_csharp_wrapper = rule(
9895
allow_files = True,
9996
),
10097
"namespace": attr.string(
101-
doc = "C# namespace where to put the sources",
98+
doc = "C# namespace for the sources",
10299
mandatory = True,
103100
),
104101
"enable_cxx": attr.bool(
@@ -157,18 +154,16 @@ csharp_native_library = rule(
157154
)
158155

159156

160-
def swig_csharp(name, lib, nullable_context, target_frameworks, targeting_packs, shared_lib_name=None, tags=[], **kwargs):
157+
def swig_csharp(name, native_lib_name, lib, namespace, nullable_context, target_frameworks, targeting_packs, tags=[], **kwargs):
161158
swig_wrapper_name = "{}_swig".format(name)
162159
swig_csharp_wrapper(
163160
name = swig_wrapper_name,
164161
class_name = name,
165162
lib = lib,
163+
namespace = namespace,
166164
**kwargs,
167165
)
168166

169-
if not shared_lib_name:
170-
shared_lib_name = name
171-
172167
def swig_cc_binary(shared_lib_filename):
173168
# name doesn't accept select() either
174169
native.cc_binary(
@@ -183,22 +178,16 @@ def swig_csharp(name, lib, nullable_context, target_frameworks, targeting_packs,
183178
}),
184179
)
185180

186-
native_lib_name_root = "typedb_driver"
187-
native_lib_name = "{}_native".format(native_lib_name_root)
188-
189-
# TODO: On Mac, it's enough to pass native_lib_name_root (lib and .dylib are added by the rule)
190-
# Check if the same could work for Windows and Linux. Maybe we don't need to make
191-
# this complex code with selects and functions...
192-
swig_cc_binary("lib" + native_lib_name_root + ".dylib")
193-
swig_cc_binary("lib" + native_lib_name_root + ".so")
194-
swig_cc_binary(native_lib_name_root + ".dll")
181+
swig_cc_binary("lib" + native_lib_name + ".dylib")
182+
swig_cc_binary("lib" + native_lib_name + ".so")
183+
swig_cc_binary(native_lib_name + ".dll")
195184

196185
native.alias(
197186
name = native_lib_name,
198187
actual = select({
199-
"@vaticle_bazel_distribution//platform:is_mac": ("lib" + native_lib_name_root + ".dylib"),
200-
"@vaticle_bazel_distribution//platform:is_linux": ("lib" + native_lib_name_root + ".so"),
201-
"@vaticle_bazel_distribution//platform:is_windows": (native_lib_name_root + ".dll"),
188+
"@vaticle_bazel_distribution//platform:is_mac": ("lib" + native_lib_name + ".dylib"),
189+
"@vaticle_bazel_distribution//platform:is_linux": ("lib" + native_lib_name + ".so"),
190+
"@vaticle_bazel_distribution//platform:is_windows": (native_lib_name + ".dll"),
202191
})
203192
)
204193

@@ -221,6 +210,7 @@ def swig_csharp(name, lib, nullable_context, target_frameworks, targeting_packs,
221210
name = name,
222211
srcs = [":{}".format(csharp_source_name)],
223212
deps = [":{}".format(csharp_native_lib_name)],
213+
out = namespace,
224214
nullable = nullable_context,
225215
target_frameworks = target_frameworks,
226216
targeting_packs = targeting_packs,

distribution/deployment.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ deployment = {
5858
"release": "https://upload.pypi.org/legacy/",
5959
"snapshot": "https://python.cloudsmith.io/typedb/public-snapshot/",
6060
},
61+
"nuget" : {
62+
"release": "https://api.nuget.org/v3/index.json",
63+
"snapshot": "https://nuget.cloudsmith.io/typedb/public-snapshot/v3/index.json",
64+
},
6165
}
6266

6367
deployment_private = {

distribution/deps.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ def vaticle_bazel_distribution():
99
git_repository(
1010
name = "vaticle_bazel_distribution",
1111
remote = "https://github.com/vaticle/bazel-distribution",
12-
commit = "c473d17530dff5a4398d2de9c9fe966df9aca4ce" # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_bazel_distribution
12+
commit = "5e8c09ddbb20571c8a48651210494ac68fcf8ae7" # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_bazel_distribution
1313
)

0 commit comments

Comments
 (0)