Comments (1)
I continued to investigate the problem and found the root cause, which occurs only on Windows systems. It is produced by the following code, originating from the file magritte_bzl.src
:
# Copies a file to another file. If the destination directory does not exist
# it will be created. (Windows version)
def _copy_action_windows(ctx, input_file, output_file):
bat = ctx.actions.declare_file(ctx.label.name + "_cmd.bat")
# ... rest of the code
# Implementation function for rule below.
def _magritte_resources_folder_impl(ctx):
# ... rest of the code
for file in ctx.files.runtime_data:
# ...
if ctx.attr.is_windows:
_copy_action_windows(ctx, file, output_file)
The error was occurring due to multiple actions trying to write to the same .bat
file (bat = ctx.actions.declare_file(ctx.label.name + "_cmd.bat")
) within the loop of def _magritte_resources_folder_impl(ctx)
. This was causing a conflict in the build process with Bazel, as it expects actions to have distinct outputs.
I've identified two solutions to resolve this problem and created two separate pull requests for them:
Solution 1: Direct Command Execution (Pull Request #18 )
Instead of writing to a .bat
file, you can execute the necessary commands directly using cmd.exe
. This solution removes the shared .bat
file, allowing actions to be executed independently without conflict.
cmd_part1 = "(if not exist \"%s\" mkdir \"%s\")" % (destination_folder, destination_folder)
cmd_part2 = " && @copy /Y \"%s\" \"%s\"" % (file_to_copy, destination_folder)
cmd = cmd_part1 + cmd_part2
ctx.actions.run(
inputs=[input_file],
outputs=[output_file],
executable="cmd.exe",
arguments=["/C", cmd],
use_default_shell_env=True,
)
Solution 2: Unique .bat
Filename Using a Hash (Pull Request #19 )
You can modify the .bat
filename to include a hash of the source path. By creating a unique filename for each action, this solution ensures that actions can be executed concurrently without any conflicting writes to the same file.
bat = ctx.actions.declare_file("%s-%s-cmd.bat" % (ctx.label.name, hash(src.path)))
Either solution should resolve the conflict and allow the Bazel build to proceed smoothly. Feel free to review the pull requests for more details.
Best regards,
from magritte.
Related Issues (9)
- Docker build args HOT 1
- Magritte vs Mediapipe HOT 1
- Magritte on Windows HOT 1
- iOS App HOT 1
- python example
- bazel run in the docker container HOT 1
- Magritte
- could u support ios ? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magritte.