-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix/re adding files #341
Conversation
…red, instead of throwing an exception
…dded, ignore adding them
What I do not like about this is that it allows adding two files with the same name but different contents without any error or warning. Such behaviour can be ok in an user wrapper layer but not in the tool itself. |
I don't understand. My assumption is that this should only have an impact if a file (the same physical file on disk) is added once again. Is my assumption therefore wrong, that the file_name which is the key for the _source_files dictionary in library is a fully qualified path name? If so, I will have to find a different way to discern if the file 'exactly the same file' is already in the library. Furthermore, it is totally valid vhdl to write to files with the same name, but different content. This might be very ugly and should be avoided by all means, but sometimes one has to integrate code of third parties and one does not have a choice :-/ |
The file name key is the full absolute path. The problem occurs when the contents of the file is changed between the two additions which can happen when files are carelessly programmatically created. |
I can see three ways to resolve this:
|
I was thinking along the same lines. I'll implement a version using the hash, would that work for you? |
Hi @kraigher @LarsAsplund In project.py:add_source_file I've added following print line
This generates following output
So I'm confident my suggested solution should work just fine. |
The problem occurs when the contents of the file is changed between the two additions. It can happen when files are carelessly programmatically created between two calls to add_source_files. |
Oh, I see! Hash it is then. |
You can use the file_content_hash funciton which is already used in project.py to compute a hash. |
restructured so to only have one return statement
Funny, when I test adding a library 'lib' and 'Lib' the KeyError is thrown. |
Could you be more specific and provide details? |
There is a testcase failing: I tried to run the tests locally, but somehow the setup for running the tests seems to be a little more complex than just installing pytest and pylint. I'm a python noob, so I'm sorry for the inconvenience I'm possibly creating. |
…cept can be triggerd due to two different exceptions
I've found out what went wrong. Fix is on the way. |
@kraigher There are some linting errors and apt-get stuff that fail in the ci, they do not have anything to do with me, do they? The library testcase now runs, the only test failing is the test concerning adding a file twice, which of course is allowed now. Are there any further actions required from my side? |
I am quite busy now but I will have a look at this during this weekend or next week. |
No worries, I appreciate your help. I can only imagine what a lot of work this is next to the daily regular work you do. I myself implemented a compile order generator for vhdl, verilog and system verilog which we have been using the last ten years. Though the tool could only create the order and invoke compilation and therefore covered less topics than vunit I know what it is like to have a side project, on which many colleagues rely, next to regular work. |
I added this feature now with a different implementation. It is possible to add duplicate files with identical content without error. There is a warning log message though. |
Hi. I am trying out this feature. It looks like the allow_replacement argument in the add_library() function is only applied at the project class, and not the ui class. The add_library() in the ui class calls the function with the same name in the project class. Can this be fixed ? |
@krishnan-gopal This issue/feature was related to adding duplicate files not duplicate libraries. The allow_replacement flag in the Project is just dead code and should be removed. After implementing this issue it is now possible to add the same file path twice if it has identical contents in both occations. |
Hi, this changes make the handling of adding libraries and sourcefiles less restrictive. Adding of these multiple times results in ignoring the request rather than throwing an exception.
The diff shows mostly white space changes due to the python indentation