-
Notifications
You must be signed in to change notification settings - Fork 16
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
Split source / output #13
base: master
Are you sure you want to change the base?
Conversation
I haven't tested running it, but I think its a good idea. 👍 My only thought from looking at it is that we could maybe merge the splitout sample with the other one, or at least put them both in a samples folder. |
@zicklag Excellent.. I would be more than happy to merge it into the existing sample.. I just didn't want to go ahead and do that unless I had some kind of indication from you guys that it would be acceptable to do so. I'll manually make the changes and let you know when that's done.. thanks. |
Also you might want to wait to hear from @ncannasse. Its his repo, I've just contributed. 😃 |
@zicklag ... cool, @ncannasse with your permission I would like to do as @zicklag suggested :-) |
@zicklag ... while I have you here maybe you can answer something for me? What is the plan with regards to handling bindings for multiple c++ classes in the same project. The idl file in the sample is called point.idl presumably because the only thing it handles presently is the Point class but if I wanted to add a class (different header and implementation file) would I just append it to the same .idl file? And if so I suspect I will have to handle it somehow in the makefile? Perhaps make is a bit light for a larger workload if that's the case? Perhaps the work presently being done by make should be handled by a webidl executable? I'm not sure what the long term goals are for this project but it looks like something that I would like to make more industrial use of than just a few samples... |
@zicklag well that was easier than I expected. I've gone ahead and updated my fork with the changes necessary to compile multiple c++ targets and generate the bindings. For now I updated the splitout example.
From a user perspective:
The makefile isn't terrible but I think it could still become troublesome having to make changes in two places.. I'll put some more thought into that. splitout/Splitout.hx:17: Result = 11,13 len=17.029386365926403
libpoint.js:8 This is Context!
libpoint.js:8 This is test! |
Sounds cool! I'm a little busy, but I'll let you know if I try it. |
Hey there ! I'm glad there's interest in this project. ATM I have already many (=too much) repositories to monitor so i'm not sure I can invest a lot of time on webidl. So if @zicklag wants to be added as a contributor and keep developing it, I will gladly give the corresponding rights :) I'm planning to use webidl for bullet HL support, as long as it doesn't break things here it's fine for me. |
@ncannasse .. Hi Nick.. very good news, congratulations @zicklag you have been promoted!. I'll go ahead and make the changes you suggested. Thank you both. |
@ncannasse That would be great, thanks! |
Hi @zicklag .. as per our discussion I have gone ahead and merged the samples as follows:
I've additionally taken the liberty of changing the naming a little based on our discussions:
When generating output the following naming is used:
I guess you are the new maintainer? If so could you please test at your convenience and let me know if any changes are needed or not. If not I am happy for you to merge this as it is. I will have further enhancements to contribute later this week. @ncannasse .. Nick, you said something important above "so long as we don't break anything".. can you be specific about what that means? What can I test against to ensure that nothing is broken and / or if there are breaking changes what can I use to document against to keep you current? Also I plan to update the readme to reflect these changes but since it includes a URL which is not yet merged to master I haven't pushed that yet. Thanks |
@WolfieWerewolf I'll check it out as soon as I can. 🙂 As far as what we can't break, it's bullet bindings for HashLink. Edit: Also about the Readme URL, I think you can just put that in there, and when the PR is merged it will be valid right? |
@zicklag ... excellent thanks.. I'll test against that shortly. There will likely need to be some changes to those bindings to make use of this PR.. if so I'll create a related PR for that project. |
@zicklag .. mate.. I haven't tried to compile this yet but it looks to me like the Haxe Bullet bindings include a fork of the webidl that it was using at the time and doesn't reference this project? |
That's not the repo I was talking about here. The one I'm talking about is the one that HashLink itself comes with: https://github.com/HaxeFoundation/hashlink/tree/master/libs/bullet. BTW I've got a PR for Armory3D's Haxebullet to update it. That is part of the Kha integration I mentioned in the other issue. ;) armory3d/haxebullet#27 |
oops.. my bad. I'm sorry I'm not following there's a lot going on. Do you still want me to verify against the bullet stuff in hashlink (using the correct URL this time)... sorry for my confusion.. I am just getting caught up with all the dependencies etc.. |
No problem. You could test it if you want. It should still work fine because I think it pretty much just uses the generated bullet.cpp file from WebIDL and our changes have been mostly to the JavaScript generation and the export locations, which aren't used by that repo directly anyway. Still could be good to test. I think the |
Ok good info thanks.. I will test just to be sure.. I did make some changes to the way the configuration is handled though.. I moved the static config out of the Module to a json file so that might need some tweaking.. thanks for the info |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK here's my review. If you don't agree with a review just tell me, I'm not completely set on all of the comments. 🙂
BTW it did work. 😉
samples/simple/SimpleModule.hx
Outdated
|
||
class SimpleModule { | ||
|
||
static var json = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking we can simplify this block like so:
static var json = { | |
static var json = haxe.Json.parse(sys.io.File.getContent("./webidl.json")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The GitHub auto-commit thing won't remove the 4 lines below, so we'll need to do that manually.
@@ -0,0 +1,16 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming this file wasn't meant to be in here as you added .vscode
to the .gitignore
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct.. I should not have pushed that.
@@ -0,0 +1,9 @@ | |||
<!doctype html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this index.html
and the one in webRoot
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I like to not edit anything in webRoot directly and treat it all as generated.. You'll notice that the new build copies the index.html from the source root (which is still the project root) every time you compile.. so changes should be made in sources not in webRoot (output).
add(""); | ||
add(StringTools.trim(opts.includeCode)); | ||
for(l in sys.io.File.getBytes(if(sys.FileSystem.exists(opts.out+ "/" + sFile)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this block of code very difficult to read. This is a bit cleaner:
var path = null;
for(sFile in opts.sourceFiles){
add("");
path = FileSystem.exists(opts.out + "/" + sFile) ? opts.out + "/" + sFile : sFile;
for(l in sys.io.File.getContent(path).split("\n")){
if(StringTools.startsWith(l, "#include")){
add(StringTools.trim(l));
}
}
}
Also for large projects would this be a performance concern, going through all of the source files that could represent a large library? I don't know how long that takes, it probably isn't a problem, but I thought I'd bring it up. Maybe we should test it with a bunch of files or add a autoIncludeIncludes
( 😉 ) flag or something like that to the webidl.json
( maybe with a better name like detectIncludes
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.. I'm coming from Kotlin and I've been embracing it's functional side so I've become used to long functions.. however you want it man is fine with me.
@@ -399,7 +399,7 @@ template<typename T> pref<T> *_alloc_const( const T *value ) { | |||
if( p.substr(0, 2) == "-O" ) | |||
hasOpt = true; | |||
if( !hasOpt ) | |||
params.push("-O2"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think O2
is probably a good default. I'm not really set on it if you have a good reason, but I think O2
made sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And that is also an oversight on my part (good catch).. I dropped down to -O0 so I could more easily read the output.. you are correct this should be optimised.
@@ -412,26 +412,32 @@ template<typename T> pref<T> *_alloc_const( const T *value ) { | |||
var outFiles = []; | |||
sources.push(lib+".cpp"); | |||
for( cfile in sources ) { | |||
var out = cfile.substr(0, -4) + ".bc"; | |||
var args = params.concat(["-c", cfile, "-o", out]); | |||
var sourcePath = if(sys.FileSystem.exists(opts.out+ "/" + cfile)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be missing something, but why are we looking in the output directory as a possible location for a source file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it is the only place where the lib_project.cpp is going to ever exist; it's generated.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, in that case I would just update the if statement to be single lined:
var sourcePath = sys.FileSystem.exists(opts.out + "/" + cfile) ? opts.out + "/" + cfile : cfile;
]); | ||
var output = "SOURCES = " + outFiles.join(" ") + "\n"; | ||
output += "all:\n"; | ||
output += "\t"+emcc+" $(SOURCES) " + args.join(" "); | ||
sys.io.File.saveContent(tmp, output); | ||
command("make", ["-f", tmp]); | ||
sys.FileSystem.deleteFile(tmp); | ||
sys.io.File.copy("index.html", opts.out+"/index.html"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that this explains the two index.html
files. If we have the favicon already in the webRoot folder when it builds I don't see any reason that we can't have the index.html
file in there as well and leave out this copy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.. I don't mind either way..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to preserve the sources separate from the output dir concept, which I think is good, we could create like a "bundled" directory maybe and add that to the webidl.json
options? Every file or folder in like a bundledResources
option would be copied right into the output directory.
Edit: BTW I put this comment on the wrong review so I moved it and hid the old one.
Co-Authored-By: WolfieWerewolf <[email protected]>
Mate.. that was an excellent code review.. thank you.. |
No problem. That was actually the first time I've ever reviewed a PR to a repo that I maintain. |
Nice.. I do appreciate it because no matter how much I look at code I'll always miss something.. like the .vscode thing... I'll go through this again with our comments, make the necessary changes and push that up.. likely tomorrow mate.. thanks again. |
Hi guys.. I am very impressed with the work you have done here; I wish I had known about it sooner. Once I got up and running (thanks to @zicklag) I thought I might be able to help out by contributing a few small changes.
It should be possible to simply execute "make js" and have everything dump into webRoot. If you run something like live-server or the python simple server in there you should get the running wasm.
I have tested this on Linux Mint which seems entirely compatible with Ubuntu based on the tested / help that @zicklag provided. I don't have access to OSX / MacOS or Windows unfortunately.
If you are happy with this great, if there are changes you would like, I am happy to make them, if you don't like any of this then that's ok too ;-) I just wanted to see if I could help out.
Thanks for your consideration.
Kind Regards
Wolfie