Skip to content

Commit 4d42a46

Browse files
Fix/package (#4)
* fix bazel package structure * adapt readme * deactivate vtt for now
1 parent 321989d commit 4d42a46

File tree

4 files changed

+131
-117
lines changed

4 files changed

+131
-117
lines changed
File renamed without changes.

rules/cfg5/README.md

Lines changed: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ cfg5_generate_rt(<a href="#cfg5_generate_rt-name">name</a>, <a href="#cfg5_gener
5757
Wraps the cfg5_generate_rt with the private_is_windows select statement in place
5858

5959

60-
**PARAMETERS**
60+
**ATTRIBUTES**
6161

6262

6363
| Name | Description | Default Value |
@@ -84,7 +84,7 @@ cfg5_generate_rt_workspace(<a href="#cfg5_generate_rt_workspace-name">name</a>,
8484
Wraps the cfg5_generate_rt_workspace with the private_is_windows select statement in place
8585

8686

87-
**PARAMETERS**
87+
**ATTRIBUTES**
8888

8989

9090
| Name | Description | Default Value |
@@ -111,7 +111,7 @@ cfg5_generate_vtt(<a href="#cfg5_generate_vtt-name">name</a>, <a href="#cfg5_gen
111111
Wraps the cfg5_generate_vtt with the private_is_windows select statement in place
112112

113113

114-
**PARAMETERS**
114+
**ATTRIBUTES**
115115

116116

117117
| Name | Description | Default Value |
@@ -138,7 +138,7 @@ cfg5_generate_vtt_workspace(<a href="#cfg5_generate_vtt_workspace-name">name</a>
138138
Wraps the cfg5_generate_vtt_workspace with the private_is_windows select statement in place
139139

140140

141-
**PARAMETERS**
141+
**ATTRIBUTES**
142142

143143

144144
| Name | Description | Default Value |
@@ -155,20 +155,7 @@ A cfg5_generate_vtt_workspace_def rule that contains the actual implementation
155155
# Example usage
156156
The following showcases an example on how to use a rule and toolchain in your Bazel project environment.
157157

158-
## Fetching the rule
159-
160-
In a `WORKSPACE` or `MODULE.bazel` file add an `http_archive` rule to fetch the rule and toolchain:
161-
162-
```python
163-
http_archive(
164-
name = "vector_bazel_rules",
165-
sha256 = "1234567891234567891234567891234567891234567891234567891234567891",
166-
url = "https://github.com/vectorgrp/bazel-rules/archive/refs/tags/<tag_version>",
167-
)
168-
```
169-
Adapt `<tag_version>` to fetch a distinct release.
170-
171-
## Instantiate the rule
158+
## Instantiate a rule
172159

173160
In a `BUILD.bazel` file refer to the rule as follows:
174161

@@ -198,26 +185,52 @@ cfg5_generate_rt_workspace(
198185
)
199186
```
200187

201-
## Configure the toolchain
188+
## Configure a toolchain
202189

203190
In a `BUILD.bazel` file refer to the toolchain & platform configuration as follows:
204191

192+
### Execution under Linux
193+
205194
```python
206-
cfg5_toolchain(
207-
name = "cfg5_linux_impl",
208-
cfg5_files = "@ecu1sip//:DaVinci_Configurator_5",
209-
cfg5cli_path = "@ecu1sip//:DaVinciConfigurator/Core/DVCfgCmd",
210-
)
195+
cfg5_toolchain(
196+
name = "cfg5_linux_impl",
197+
cfg5_files = "@sip//:DaVinci_Configurator_5", # External dependency to the Microsar Classic product
198+
cfg5cli_path = "@sip//:DaVinciConfigurator/Core/DVCfgCmd", # External dependency to the DaVinci Configurator 5 CLI tool
199+
)
200+
201+
toolchain(
202+
name = "cfg5_linux",
203+
exec_compatible_with = [
204+
"@platforms//os:linux",
205+
],
206+
target_compatible_with = [
207+
"@platforms//os:linux",
208+
],
209+
toolchain = ":cfg5_linux_impl",
210+
toolchain_type = "@vector_bazel_rules//rules/cfg5:toolchain_type",
211+
)
212+
```
211213

212-
toolchain(
213-
name = "cfg5_linux",
214-
exec_compatible_with = [
215-
"@platforms//os:linux",
216-
],
217-
target_compatible_with = [
218-
"@platforms//os:linux",
219-
],
220-
toolchain = ":cfg5_linux_impl",
221-
toolchain_type = "@vector_bazel_rules//rules/cfg5:toolchain_type",
222-
)
214+
### Execution under Windows
215+
216+
```python
217+
cfg5_toolchain(
218+
name = "cfg5_windows_impl",
219+
cfg5_files = "@sip//:DaVinci_Configurator_5", # External dependency to the Microsar Classic product
220+
cfg5_path = "@sip//:DaVinciConfigurator/Core/DaVinciCFG.exe", # External dependency to the DaVinci Configurator 5 GUI tool
221+
cfg5cli_path = "@sip//:DaVinciConfigurator/Core/DVCfgCmd.exe", # External dependency to the DaVinci Configurator 5 CLI tool
222+
)
223+
224+
toolchain(
225+
name = "cfg5_windows",
226+
exec_compatible_with = [
227+
"@platforms//os:windows",
228+
],
229+
target_compatible_with = [
230+
"@platforms//os:windows",
231+
],
232+
toolchain = ":cfg5_windows_impl",
233+
toolchain_type = "@vector_bazel_rules//rules/cfg5:toolchain_type",
234+
)
223235
```
236+

rules/cfg5/rules.bzl

Lines changed: 77 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2222
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2323

24-
"""Rule to start Config 5 from Bazel"""
24+
"""Rules to use DaVinci Configurator 5 from Bazel"""
2525

2626
load("//rules/common:create_davinci_tool_workspace.bzl", "create_davinci_tool_workspace")
27-
load("//rules/vtt:toolchains.bzl", "generate_tools_vtt")
27+
#load("//rules/vtt:toolchains.bzl", "generate_tools_vtt")
2828

2929
_CFG5_GENERATE_TEMPLATE_WINDOWS = """
3030
start-process -WorkingDirectory {dpa_folder} -PassThru -NoNewWindow -RedirectStandardOutput {dpa_folder}/daVinciCfg5.log -Wait {cfg5cli_path} -ArgumentList '-p {dpa_path} -g {genargs} --verbose'
@@ -134,9 +134,9 @@ def _cfg5_generate_workspace_impl(ctx, additional_genargs, tools = []):
134134
inputs.extend(ctx.attr.sip.files.to_list())
135135
return _cfg5_generate(ctx, dpa_path, dpa_folder, dpa_copy, inputs, template, True, additional_genargs, tools)
136136

137-
def _cfg5_generate_vtt_workspace_impl(ctx):
138-
tools = generate_tools_vtt(ctx)
139-
return _cfg5_generate_workspace_impl(ctx, ["--genType=VTT", "--buildVTTProject"], tools)
137+
# def _cfg5_generate_vtt_workspace_impl(ctx):
138+
# tools = generate_tools_vtt(ctx)
139+
# return _cfg5_generate_workspace_impl(ctx, ["--genType=VTT", "--buildVTTProject"], tools)
140140

141141
cfg5_generate_workspace_attrs = {
142142
"dpa_file": attr.label(allow_single_file = [".dpa"], doc = "Dpa project file to start the cfg5 with"),
@@ -148,35 +148,35 @@ cfg5_generate_workspace_attrs = {
148148
"config_folders": attr.string_list(doc = "(Optional) List of config folders that the path will be checked for in each file to create a nested Config folder structure, default is [\"Config\"]", default = ["Config"]),
149149
}
150150

151-
cfg5_generate_vtt_workspace_def = rule(
152-
implementation = _cfg5_generate_vtt_workspace_impl,
153-
attrs = cfg5_generate_workspace_attrs,
154-
doc = """
155-
Creates a separate cfg5 workspace containing all the given config files and run the cfg5 in this created directory inside the bazel-bin.
156-
This rule is wrapped with private_is_windows attribute to separate between OS differences.
157-
Used specifically for the vtt use case, as this adds the correct vtt flags to the Cfg5 call automatically.
158-
""",
159-
toolchains = ["//rules/cfg5:toolchain_type", "//rules/vtt:toolchain_type"],
160-
)
161-
162-
def cfg5_generate_vtt_workspace(name, **kwargs):
163-
"""Wraps the cfg5_generate_vtt_workspace with the private_is_windows select statement in place
164-
165-
Args:
166-
name: The unique name of this target
167-
**kwargs: All of the attrs of the cfg5_generate_vtt_workspace rule
168-
169-
Returns:
170-
A cfg5_generate_vtt_workspace_def rule that contains the actual implementation
171-
"""
172-
cfg5_generate_vtt_workspace_def(
173-
name = name,
174-
private_is_windows = select({
175-
"@bazel_tools//src/conditions:host_windows": True,
176-
"//conditions:default": False,
177-
}),
178-
**kwargs
179-
)
151+
# cfg5_generate_vtt_workspace_def = rule(
152+
# implementation = _cfg5_generate_vtt_workspace_impl,
153+
# attrs = cfg5_generate_workspace_attrs,
154+
# doc = """
155+
# Creates a separate cfg5 workspace containing all the given config files and run the cfg5 in this created directory inside the bazel-bin.
156+
# This rule is wrapped with private_is_windows attribute to separate between OS differences.
157+
# Used specifically for the vtt use case, as this adds the correct vtt flags to the Cfg5 call automatically.
158+
# """,
159+
# toolchains = ["//rules/cfg5:toolchain_type", "//rules/vtt:toolchain_type"],
160+
# )
161+
162+
# def cfg5_generate_vtt_workspace(name, **kwargs):
163+
# """Wraps the cfg5_generate_vtt_workspace with the private_is_windows select statement in place
164+
165+
# Args:
166+
# name: The unique name of this target
167+
# **kwargs: All of the attrs of the cfg5_generate_vtt_workspace rule
168+
169+
# Returns:
170+
# A cfg5_generate_vtt_workspace_def rule that contains the actual implementation
171+
# """
172+
# cfg5_generate_vtt_workspace_def(
173+
# name = name,
174+
# private_is_windows = select({
175+
# "@bazel_tools//src/conditions:host_windows": True,
176+
# "//conditions:default": False,
177+
# }),
178+
# **kwargs
179+
# )
180180

181181
def _cfg5_generate_rt_workspace_impl(ctx):
182182
return _cfg5_generate_workspace_impl(ctx, ["--genType=REAL"])
@@ -211,23 +211,23 @@ def cfg5_generate_rt_workspace(name, **kwargs):
211211
**kwargs
212212
)
213213

214-
def _cfg5_generate_vtt_impl(ctx):
215-
info_vtt = ctx.toolchains["//rules/vtt:toolchain_type"]
214+
# def _cfg5_generate_vtt_impl(ctx):
215+
# info_vtt = ctx.toolchains["//rules/vtt:toolchain_type"]
216216

217-
if not ctx.attr.private_is_windows and not info_vtt.vtt_cmd_path and not info_vtt.vtt_cmd_label:
218-
fail("vttcmd_path is not set in the 'vtt_toolchain', but is necessary for the generation under Linux.")
219-
inputs = depset(ctx.files.input_arxmls, transitive = [ctx.attr.dpa_linux.files])
220-
dpa_path = ctx.file.dpa_windows.basename
221-
dpa_folder = ctx.file.dpa_windows.dirname
222-
dpa_file = ctx.file.dpa_linux
223-
template = _CFG5_GENERATE_TEMPLATE_LINUX
224-
if ctx.attr.private_is_windows:
225-
dpa_file = ctx.file.dpa_windows
226-
template = _CFG5_GENERATE_TEMPLATE_WINDOWS
217+
# if not ctx.attr.private_is_windows and not info_vtt.vtt_cmd_path and not info_vtt.vtt_cmd_label:
218+
# fail("vttcmd_path is not set in the 'vtt_toolchain', but is necessary for the generation under Linux.")
219+
# inputs = depset(ctx.files.input_arxmls, transitive = [ctx.attr.dpa_linux.files])
220+
# dpa_path = ctx.file.dpa_windows.basename
221+
# dpa_folder = ctx.file.dpa_windows.dirname
222+
# dpa_file = ctx.file.dpa_linux
223+
# template = _CFG5_GENERATE_TEMPLATE_LINUX
224+
# if ctx.attr.private_is_windows:
225+
# dpa_file = ctx.file.dpa_windows
226+
# template = _CFG5_GENERATE_TEMPLATE_WINDOWS
227227

228-
tools = generate_tools_vtt(ctx)
228+
# tools = generate_tools_vtt(ctx)
229229

230-
return _cfg5_generate(ctx, dpa_path, dpa_folder, dpa_file, inputs, template, False, ["--genType=VTT", "--buildVTTProject"], tools)
230+
# return _cfg5_generate(ctx, dpa_path, dpa_folder, dpa_file, inputs, template, False, ["--genType=VTT", "--buildVTTProject"], tools)
231231

232232
def _cfg5_generate_rt_impl(ctx):
233233
inputs = depset(ctx.files.input_arxmls, transitive = [ctx.attr.dpa_linux.files])
@@ -250,35 +250,35 @@ cfg5_generate_attrs = {
250250
"private_is_windows": attr.bool(mandatory = True, doc = "Set automatically to the correct OS value"),
251251
}
252252

253-
cfg5_generate_vtt_def = rule(
254-
implementation = _cfg5_generate_vtt_impl,
255-
attrs = cfg5_generate_attrs,
256-
doc = """
257-
Run the cfg5 directly in the project.
258-
This rule is wrapped with private_is_windows attribute to separate between OS differences.
259-
Used specifically for the vtt use case, as this adds the correct vtt flags to the Cfg5 call automatically.
260-
""",
261-
toolchains = ["//rules/cfg5:toolchain_type", "//rules/vtt:toolchain_type"],
262-
)
263-
264-
def cfg5_generate_vtt(name, **kwargs):
265-
"""Wraps the cfg5_generate_vtt with the private_is_windows select statement in place
266-
267-
Args:
268-
name: The unique name of this target
269-
**kwargs: All of the attrs of the cfg5_generate_vtt rule
270-
271-
Returns:
272-
A cfg5_generate_vtt_def rule that contains the actual implementation
273-
"""
274-
cfg5_generate_vtt_def(
275-
name = name,
276-
private_is_windows = select({
277-
"@bazel_tools//src/conditions:host_windows": True,
278-
"//conditions:default": False,
279-
}),
280-
**kwargs
281-
)
253+
# cfg5_generate_vtt_def = rule(
254+
# implementation = _cfg5_generate_vtt_impl,
255+
# attrs = cfg5_generate_attrs,
256+
# doc = """
257+
# Run the cfg5 directly in the project.
258+
# This rule is wrapped with private_is_windows attribute to separate between OS differences.
259+
# Used specifically for the vtt use case, as this adds the correct vtt flags to the Cfg5 call automatically.
260+
# """,
261+
# toolchains = ["//rules/cfg5:toolchain_type", "//rules/vtt:toolchain_type"],
262+
# )
263+
264+
# def cfg5_generate_vtt(name, **kwargs):
265+
# """Wraps the cfg5_generate_vtt with the private_is_windows select statement in place
266+
267+
# Args:
268+
# name: The unique name of this target
269+
# **kwargs: All of the attrs of the cfg5_generate_vtt rule
270+
271+
# Returns:
272+
# A cfg5_generate_vtt_def rule that contains the actual implementation
273+
# """
274+
# cfg5_generate_vtt_def(
275+
# name = name,
276+
# private_is_windows = select({
277+
# "@bazel_tools//src/conditions:host_windows": True,
278+
# "//conditions:default": False,
279+
# }),
280+
# **kwargs
281+
# )
282282

283283
cfg5_generate_rt_def = rule(
284284
implementation = _cfg5_generate_rt_impl,

defs.bzl renamed to rules/defs.bzl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,17 @@
2323

2424
"""Vector-Bazel-Rules
2525
"""
26-
load("//rules/cfg5:rules.bzl", _cfg5_generate_rt = "cfg5_generate_rt", _cfg5_generate_rt_workspace = "cfg5_generate_rt_workspace", _cfg5_generate_vtt = "cfg5_generate_vtt", _cfg5_generate_vtt_workspace = "cfg5_generate_vtt_workspace", _start_cfg5_windows = "start_cfg5_windows")
26+
load("//rules/cfg5:rules.bzl", _cfg5_generate_rt = "cfg5_generate_rt", _cfg5_generate_rt_workspace = "cfg5_generate_rt_workspace",
27+
#_cfg5_generate_vtt = "cfg5_generate_vtt", _cfg5_generate_vtt_workspace = "cfg5_generate_vtt_workspace",
28+
_start_cfg5_windows = "start_cfg5_windows")
2729
load("//rules/cfg5:toolchains.bzl", _cfg5_toolchain = "cfg5_toolchain")
2830

2931
# DaVinci Configurator 5 rules
3032
start_cfg5_windows = _start_cfg5_windows
31-
cfg5_generate_vtt_workspace = _cfg5_generate_vtt_workspace
33+
#cfg5_generate_vtt_workspace = _cfg5_generate_vtt_workspace
3234
cfg5_generate_rt_workspace = _cfg5_generate_rt_workspace
33-
cfg5_generate_vtt = _cfg5_generate_vtt
35+
#cfg5_generate_vtt = _cfg5_generate_vtt
3436
cfg5_generate_rt = _cfg5_generate_rt
3537

3638
# Toolchain rules
37-
cfg5_toolchain = _cfg5_toolchain
38-
39+
cfg5_toolchain = _cfg5_toolchain

0 commit comments

Comments
 (0)