How to run a python script as pre-build step?
Hello everybody,
I stuck with an issue that I can't get fixed.
Given:
- I use the "Pre-Compile {Command,OutputFilePath, Working Dir}" settings for the solution and the project.
- I've an exectuable Python-script, that runs directly on "Linux" and "Windows" ... means without adding absolute path of Python$(HostExe) - the script will generate some header file from json (I do need python for the conversion, because in ECMA-Script it would probably take too long to implement.)
Observation:
- The file "%(ProjectDir)/Tools/myscript.py ..." is not executed, even there is no build error from the IDE, except the error that results from the missing header-file that is not generated.
Questions:
- Do I need to wrap the script call in Java-Script? However this is a sort of pita because of complicated quoting and passing arguments around ...
Thanks for your help, Axel.
-
So I can resolve my post with the following remarks:
Python needs to be in the System-Path
- for Windows it needs to be set explicitely,
- on Linux it is most probably already there
Run the script in the Pre-Compile-Command with:
python$(HostEXE) $(ProjectDir)/Tools/myscript.py <more args w/ macros beeing expanded>
This works fine on Linux and Windows.
-
Next question: since pre-compile is executed before each source file, that is going to be compiled, is there something like a user defined prebuild execution step? That means that I'm looking for a step, that is executed "once", e.g the Makefile syntax would look like:
my_generated_file.h: my_input_file.json
python Tool/myscript.py $< $@ -
The command doesn't need to be applied to all source files, it can be set on just one file. There is an example of something similar at https://rowley.zendesk.com/hc/en-us/community/posts/205387253--get-the-current-Subversion-version-number-
Please sign in to leave a comment.
Comments
3 comments