-
Notifications
You must be signed in to change notification settings - Fork 118
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
Compile check tests in CI #575
Compile check tests in CI #575
Conversation
Should close #570 if merged |
Co-authored-by: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>
just make an extra script file that registers new launcher functions as global in the base suirrel files, that way you don't need to tamper with the compiler |
Yeah that could work, however:
|
wouldn't the compiler / json / mod to load added functions be updated anyways every time a new signature is added? Unless the standalone compiler is being built in the same workflow as the launcher |
What if we pass launcher functions as arg in CI file to action? So that way if a new launcher function is added, on the corresponding mods PR, all the author has to do is to add the function name to the CI file. So it would be something like - name: Compile Scripts
uses: ASpoonPlaysGames/squirrel-re-compiler@v1
with:
mods-directory: "${{ github.workspace }}/mods"
launcher-functions: "NSMakeHTTPRequest,my_other_custom_function,etc" # <--- this part |
Alternatively @RoyalBlue1 suggested adding a JSON file with all the custom functions in this NorthstarMods repo and just putting it in |
Or embedding the JSON file into the CI config. |
Sure, but we would have to enforce that this gets updated properly alongside any launcher PRs. (perhaps we could do some code commenting in launcher or something that we scan for in a workflow, and then just enforce it in code reviews?) |
Not sure if it that's even necessary. If the launcher added function is not added to the CI file (or JSON file or whatever) the mods PR CI will just fail and prevent the PR from being merged. At which point we can tell the author what to do to fix it. |
What about function signatures? Just the names isn't enough |
Yeah we would need function signatures, not just names. IIRC, the cpp code in launcher (and therefore squirrelstandalone) likes three strings (function name, return type, parameters), used to create the functions, as well as VM(s) to put the function in. Example of func registration on cpp side: (empty string is the help text, not rly needed for compiling) g_pSquirrel<ScriptContext::SERVER>->AddFuncRegistration(
"void",
"NSBroadcastMessage",
"int fromPlayerIndex, int toPlayerIndex, string text, bool isTeam, bool isDead, int messageType",
"",
SQ_BroadcastMessage); // void function NSBroadcastMessage( int fromPlayerIndex, int toPlayerIndex, string text, bool isTeam, bool isDead, int messageType )
SQRESULT SQ_BroadcastMessage(HSquirrelVM* sqvm)
{
return SQRESULT_NULL;
} So as an example you could have some json like this to represent a function which would then be added (as a stub, it'll never actually get ran) for compiling {
"name": "DoThing",
"parameters": "string thing, int otherThing",
"returnType": "array<bool>",
"contexts": [ "UI", "CLIENT", "SERVER" ]
} This would then be used to create a function like this: (obviously using variables not string literals) g_pSquirrel<ScriptContext::SERVER>->AddFuncRegistration(
"array<bool>",
"DoThing",
"string thing, int otherThing",
"",
SQ_StubFunc); SQRESULT SQ_StubFunc(HSquirrelVM* sqvm)
{
return SQRESULT_NULL;
} |
there is in northstar functions arg3 is always 1 but i needed to set it for when i'm doing the other native functions so that could be removed as well |
I think the best way to go about this would be to have 2 separate files, one for native functions that goes into The one which you specify the path for could use a simpler setup, only requiring the args needed for this (hoping to make keeping it updated easier with less confusion about the args)
whereas the one in |
we could also just have default values the same as ns so it behaves like ns but if you specify something it uses that |
Yeah that's what i meant, but i worded it badly. Splitting it into two files (one for native, one for NS) I think is the best move in that regard though |
o no |
should be working now |
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.
Left 2 comments. Otherwise looks fine to me. We probably wanna add some docs somewhere describing what nativefuncs.json
does. Not sure what the best approach is. README.md
in .github
folder?
Co-authored-by: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>
…ames/NorthstarMods into compile-check-tests
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 from my end ^^
Uses ASpoonPlaysGames/squirrel-re-compiler (which uses RoyalBlue1/StandaloneR2Squirrel) to gather together scripts and try to compile them.
This currently would break if more functions are added via launcher, as it won't know that they exist. We should have a json file or something somewhere where the action can gather a list of function signatures added by native, alongside their VMs to avoid this problem
EDIT: this is resolved now using
.github/nativefuncs.json
Closes #570