Can't make the AddPathToSourceSearch function working ?

39 views
Skip to first unread message

Julien SOYSOUVANH

unread,
May 13, 2019, 3:48:24 AM5/13/19
to Runtime-Compiled C++
Hello Douglas,

I've been using your library for the past few weeks, and it is working great!
However, I am trying to achieve something and can't seem to get it working.

I am using the RCC++ library with the auto-compile mode off.
I basically have a button on my window which triggers the compileAll function whenever it is clicked.
However, It doesn't seem to discover any file (source nor header), and just keep printing "Error - could not find any files to build in any projects".
I double checked the directories I specified with AddIncludeDir and AddPathToSourceSearch, and they are OK. Am I misunderstanding the usage of
these two functions ?

I make a quick work-around by adding every source file using the AddToRuntimeFileList function, but it is recompiling everything
each time I hit the compile button... and I would like to avoid having to recompile files which haven't changed.
Is there something I am doing wrong or something I didn't understand ?

Thank you in advance!

Doug Binks

unread,
May 13, 2019, 10:40:59 AM5/13/19
to Runtime-Compiled C++
Compile-all will compile all files which are registered as runtime compiled files. It does not check for changes.

If you have auto-compile off, then runtime file tracking of changes will not be on. To achieve what I think you want to do, have auto-compile on but only run IRuntimeObjectSystem::GetFileChangeNotifier()->Update() when you want to recompile the files.

You shouldn't need to add your files using AddToRuntimeFileList () unless you are doing something advanced. You should have at least one Runtime Modifiable Class and you can use Runtime Source Dependencies or Runtime modifiable header files for any code which that needs to be linked to but which isn't in a Library.


AddIncludeDir() simply sets up include directories in which the compiler, when called, will search for headers. It does not 'register' headers as being tracked for runtime compilation. 

AddPathToSourceSearch() is used to help the runtime compilation system find files registered. It does not add files in that path to the list of runtime compiled files.




Doug Binks

unread,
May 13, 2019, 10:43:33 AM5/13/19
to Runtime-Compiled C++
Forgot to thank you for liking the library!

I'd love to add more documentation and examples but can't afford enough time for this. If you'd like to help contribute to me being able to do so I have recently set up a Patreon.

Julien SOYSOUVANH

unread,
May 14, 2019, 3:26:15 AM5/14/19
to Runtime-Compiled C++
Thank you very much for your fast answer!

I am trying to accomplish what you told me but I am definitely doing something wrong.
I switched auto-compile on, and am calling IRuntimeObjectSystem::GetFileChangeNotifier()->Update() each frame (for now, when I will get this working I will call that only when necessary). It doesn't seem to do anything.
I think the main problem is that my .cpp and .h files are not spotted by the library. All the files I want to compile are located in a completely different folder than the RCCPP lib. I however added the right folders using AddIncludeDir and AddPathToSourceSearch respectively.

Am I still missing something?

Thank you again!!

Doug Binks

unread,
May 14, 2019, 5:57:09 AM5/14/19
to Runtime-Compiled C++
This will be difficult to answer without more information. Do you have your source code available to look at online somewhere?

Some basic questions:
  1. What operating system and compiler are you using for this work?
  2. Your code should have at least one REGISTERCLASS or REGISTERSINGLETON macro in use to register a class with RCC++, does it?
  3. If you are using Linux have you set the compile path using the define COMPILE_PATH="$(PWD)/"; as per the Integrating to your own codebase documentation?
  4. If you are using MSVC on Windows have you set the  "/FC" compile option to get full filenames as per the Integrating to your own codebase documentation?
Also do take a look at the full Wiki documentation, and the ConsoleExample project which is a good starting point.

Julien SOYSOUVANH

unread,
May 15, 2019, 5:28:51 PM5/15/19
to Runtime-Compiled C++
I finally was able to progress a bit while testing a lot of different things :)

I could successfully register a class to the HotReload system using the REGISTERCLASS macro.
I could successfully use both runtime modifiable headers and runtime source dependencies, and trigger compilation when I wanted to.
However, I can't make it work when headers and source are outside of the project directory, even when I am adding paths using AddIncludeDir and AddPathToSourceSearch.
What I am trying to accomplish is to have a user directory somewhere in the PC, and being able to compile its contained code using RCCPP.
Also, I read from the wiki that we can't add new source files at runtime. Is there a way to overcome this if we know the exact file path and class using the AddToRuntimeFileList method?

I'll make a small github project if you need more information about this.

Thank you again for your help.

Julien SOYSOUVANH

unread,
May 15, 2019, 5:50:39 PM5/15/19
to Runtime-Compiled C++
Sorry for the double post:
I thought I had understood how it was working but it doesn't detect runtime headers and source files anymore, even inside the project directory... I will definitely make a simple repro tomorrow and share it with you!

Julien SOYSOUVANH

unread,
May 16, 2019, 4:14:18 AM5/16/19
to Runtime-Compiled C++
Hello again Douglas,

I've played with the library again today and made a repro here : https://github.com/Angelysse/RCCPPRepro

I could make some things work, but still encounter some problems.
From what I understood, I must have on the executable side a REGISTERCLASS() macro, or I won't be able to initiate the tracking.
Then, I must (?) include in this initial file all files that require tracking ?
What I've done is a bit tricky and I am not sure it is the right thing to do, but I have included in the initial class another registered class, which is a .cpp... which itself would include all user files (headers).
Then, those headers have the runtime source dependency macro which would trigger recompilation.
But I have a problem : when I change a .cpp file, the runtime tracker triggers well, but it says there is nothing to recompile... I think looking at what I have written will be far better than any blurry explanation I can write in here, so let me know!

Thank you

Doug Binks

unread,
May 16, 2019, 2:00:06 PM5/16/19
to Runtime-Compiled C++
I've taken a look at your repo.

In order to get the visual studio project to compile I needed to change the absolute paths you have in your projects to relative ones. This wasn't an RCC++ issue just that where I downloaded the code to is in a different place to yours.

I then removed all the projects except Editor (your code), RuntimeCompiler_VS2010 and RuntimeObjectSystem. I don't think this was required but you don't need the rest.

The project then ran and changing any of the files Dummy.cpp, Test1.cpp and Test2.cpp worked for me, compiles were made and loaded at runtime.

You have also got some files which were not added to the project, namely Dummy2.cpp and UserTest1.cpp. Dummy2.cpp was included by Dummy.cpp but I that won't work.

Runtime Compiled C++ is mainly intended to work with files which are initially compiled through a normal compile process, and if you want to track files added afterwards you need to use AddToRuntimeFileList().

I did find a bug in AddToRuntimeFileList() - it needs to be passed files in OS canonical case. I found the following worked after removing the line to include Dummy2.cpp from Dummy.cpp:

path dummy2 = pathToUserInclude / "Dummy2.cpp";
FileSystemUtils::Path pathOSCase = dummy2.string();
pathOSCase.ToOSCanonicalCase();
m_ros->AddToRuntimeFileList( pathOSCase.c_str() );


Note that I used FileSystemUtils::Path here not C++17 path for ToOSCanonicalCase(). I'll fix this issue soon.

Be aware this is an advanced use of RCC++. Normally you should use RCC++ with files which are already compiled but where you want to change them.

The main idea of RCC++ is that the files you want to be runtime compiled should be ones where you have an object derived from IObject with REGISTERCLASS or REGISTERSINGLETON. Using RUNTIME_COMPILER_SOURCEDEPENDENCY or RUNTIME_MODIFIABLE_INCLUDE is a way to extend the files which are be linked to.

I hope this makes sense.







Julien SOYSOUVANH

unread,
May 16, 2019, 3:09:19 PM5/16/19
to Runtime-Compiled C++
Hello Douglas,

Thank you very much for your fast answer and your time.

I've tried to use the ToOSCanonicalCase() and it worked well! I am aware the library is not intended to work that way, but I am actually trying to develop a basic engine with a hot reload functionality which looks like UE4's. From the engine side I already take care of objects serialization, deserialization and construction, so I am basically just using the runtime compilation and dll swapping.
In the Engine, I am already keeping track of the user's scripts, and the user can create scripts from the engine interface, that's why it is more convenient for me to use the AddToRuntimeFileList function.

However, I don't want to force the user to include all its headers inside a file which contains the REGISTERCLASS() macro.
I have an idea and I will give it a try tomorrow:
I will create a basic file like Dummy.cpp which will only declare a class inheriting from IObject and call the REGISTERCLASS macro at engine launch (just before RCCPP init).
At init, this file would be registered and allow to use runtime hotreload.
Then, each time the user click the compile button, I would rewrite this file by adding all includes to user's headers. Compilation should then spot the Dummy.cpp file modification as well as other file modifications, and recompile only modified files. It sounds a bit crazy but I think it can work!
I'll keep you updated with my tries tomorrow.

Julien SOYSOUVANH

unread,
May 18, 2019, 12:24:13 PM5/18/19
to Runtime-Compiled C++
Hello Douglas,

I followed what I said and it is working.
I generate a file before each recompilation, which include all runtime headers as well as declaring a source dependency to all source files.
Headers also have a runtime source dependency to their respective source file.
When I call the update method, I regenerate the first file if needed (so that new classes get registered to the compilation process) and everything is linked properly whatever the file (header/source) I modified.
I'm pretty sure I'm not using the lib the way it was intended for, but for what I wanted to achieve it works!

Thank you again

Doug Binks

unread,
May 18, 2019, 1:38:45 PM5/18/19
to Runtime-Compiled C++
Glad you managed to get things to work!

Doug Binks

unread,
May 21, 2019, 11:39:06 AM5/21/19
to Runtime-Compiled C++
Reply all
Reply to author
Forward
0 new messages