tinverse / tsm

A Typed Hierarchical State Machine Framework in C++

Home Page:https://tinverse.github.io/tsm/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Comments about dependencies

DJuego opened this issue · comments

Hi! Thank you for your contribution! I am interested in state-of-art IA topic for robots and games AND I am a great fan of cross platform, minimal (or no) dependencies and header-only gems in modern c++. So your project excites me! :-}

Sadly, I miss links in README to the dependencies (Gflags, Glog, Gtest). Sadly it seems mandatory to use them. And it seems necessary to compile/build them. That is a concern for me. I usually work in Windows 10 x64 (msvc 15.9.7). Of course. I hope that tsm works also in the recent versions of the other two great compilers of c++ (gcc and Clang) and *nix system.

I suspect tsm is in a preliminary state ("0.1.0") but I will keep an eye on your work regularly. I actually found your project in a search on behavior trees. ;-)

DJuego

I don't have a windows system. However, what issue are you facing with windows? Could you send me the output?

Thanks for using tsm! I've created a branch feature/configure_dependencies you can try out. You should be able to configure with "cmake BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=${HOME}/local <path_to_source_dir>" from the build folder. I'm not ready to merge this into master until you/someone tests out the branch.

Thank you for your fast reply!

Ideally, I prefer a pure header-only library. For me, this means that simply including the entt.hpp header should be enough to include the library as a whole and use it. So, not cmake. Obviously the tests could be build optionally.

However, with tsm-feature-configure_dependencies:

#include <tsm/src/tsm.h>

void main()
{

}

I get (Visual Studio 2017 x64):

1>------ Rebuild All started: Project: tsm_msvc2017, Configuration: Debug x64 ------
1>main.cpp
1>p:\mis-proyectos\personal\tsm\inc\tsm\src\uniqueid.h(7): error C3615: constexpr function 'tsm::counter_inc' cannot result in a constant expression
1>p:\mis-proyectos\personal\tsm\inc\tsm\src\uniqueid.h(7): note: failure was because type 'tsm::counter_inc::<lambda_b5e2635d32ab89691d28703f26c345e2>' is not a literal type
1>p:\mis-proyectos\personal\tsm\inc\tsm\src\tsm_log.h(2): fatal error C1083: Cannot open include file: 'tsm_config.h': No such file or directory
1>Done building project "tsm_msvc2017.vcxproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

Anyway, i will test the CMake build procedure...

DJuego

My first try with CMake 3.13.3 was unsucessful.

I got:

Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.17134.
Could NOT find GFlags (missing: GFLAGS_INCLUDE_DIR GFLAGS_LIBRARY) 
Could NOT find Glog (missing: GLOG_INCLUDE_DIR GLOG_LIBRARY) 
Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY) 
CMake Error at cmake/superbuild/dependencies.cmake:54 (message):
  source code directory path length is too long (77 > 50).Please move the tsm
  source code directory to a directory with a shorter path.
Call Stack (most recent call first):
  CMakeLists.txt:41 (include)
Configuring incomplete, errors occurred!
See also "P:/Compilados/x32-x64/TRABAJO_MSVC2017_x64/BehaviorTree.CPP/builds/debug/CMakeFiles/CMakeOutput.log".

I had never had an error like that with Cmake.
All right. I will shorten the path ...

DJuego

With Default options:
USE_GLOG OFF
BUILD_TESTS ON

I got:

Tiempo transcurrido 00:00:06.52

Module path:P:/Compilados/x32-x64/tsm/cmakeP:/Compilados/x32-x64/tsm/cmake/modulesP:/Compilados/x32-x64/tsm/cmake/superbuildP:/Compilados/x32-x64/tsm/../CMake
Could NOT find GFlags (missing: GFLAGS_INCLUDE_DIR GFLAGS_LIBRARY) 
CMake Error at P:/Desarrollo/cmake/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find Glog (missing: GLOG_INCLUDE_DIR GLOG_LIBRARY)
Call Stack (most recent call first):
  P:/Desarrollo/cmake/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  cmake/FindGlog.cmake:39 (find_package_handle_standard_args)
  CMakeLists.txt:59 (find_package)


Configuring incomplete, errors occurred!
See also "P:/Compilados/x32-x64/tsm/builds/debug/CMakeFiles/CMakeOutput.log".

Now i will try:

USE_GLOG OFF
BUILD_TESTS OFF

Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.17134.
Could NOT find GFlags (missing: GFLAGS_LIBRARY) 
Could NOT find Glog (missing: GLOG_LIBRARY) 
Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY) 
Module path:P:/Compilados/x32-x64/tsm/cmakeP:/Compilados/x32-x64/tsm/cmake/modulesP:/Compilados/x32-x64/tsm/cmake/superbuildP:/Compilados/x32-x64/tsm/../CMake
CMAKE_INSTALL_PREFIX: P:/Compilados/x32-x64/tsm/builds/debug/Windows
Found Doxygen: P:/Desarrollo/Documentador/doxygen/x64/bin/doxygen.exe (found version "1.8.15") found components:  doxygen dot 
Configuring done

Success!

However, i opened the generated .sln project (msvc 2017 solution), I built and then i got a new bunch of errors... Fortunately, it seems related to documentation and dot.

2>Generating docs for compound tsm::IHsmDef...
2>Generating docs for compound tsm::InternalTransitionT...
2>Generating docs for compound tsm::MethodNotImplementedException...
2>CUSTOMBUILD : error : Problems running dot: exit code=-1, command='dot', arguments='"P:/Compilados/x32-x64/tsm/builds/debug/docs/html/_orthogonal_state_machine_8h__dep__incl.dot" -Tpng -o "P:/Compilados/x32-x64/tsm/builds/debug/docs/html/_orthogonal_state_machine_8h__dep__incl.png"'
2>CUSTOMBUILD : error : Problems running dot: exit code=-1, command='dot', arguments='"P:/Compilados/x32-x64/tsm/builds/debug/docs/html/_event_queue_8h__dep__incl.dot" -Tpng -o "P:/Compilados/x32-x64/tsm/builds/debug/docs/html/_event_queue_8h__dep__incl.png"'
2>CUSTOMBUILD : error : Problems running dot: exit code=-1, command='dot', arguments='"P:/Compilados/x32-x64/tsm/builds/debug/docs/html/_orthogonal_state_machine_8h__incl.dot" -Tpng -o "P:/Compilados/x32-x64/tsm/builds/debug/docs/html/_orthogonal_state_machine_8h__incl.png"'
2>CUSTOMBUILD : error : Problems running dot: exit code=-1, command='dot', arguments='"P:/Compilados/x32-x64/tsm/builds/debug/docs/html/_async_execution_policy_8h__incl.dot" -Tpng -o "P:/Compilados/x32-x64/tsm/builds/debug/docs/html/_async_execution_policy_8h__incl.png"'
[...]

DJuego

It should generate documentation only if you have doxygen installed. Can you comment out the option to generate documentation in the root CmakeLists.txt and try again?

Yes. Success. Really i have doxygen, but not installed. Habitually, i have to specify the path in the CMake parameters... But don´t worry for now

Good. Success. it has generated the tsm_config.h with content: /* #undef USE_GLOG */

:-DDD

I included it in the proyect. I test:

#include <tsm/src/tsm.h>

int main()
{
	return 0;
}.

I got:

1>------ Build started: Project: tsm_msvc2017, Configuration: Debug x64 ------
1>main.cpp
1>p:\mis-proyectos\personal\tsm\inc\tsm\src\uniqueid.h(7): error C3615: constexpr function 'tsm::counter_inc' cannot result in a constant expression
1>p:\mis-proyectos\personal\tsm\inc\tsm\src\uniqueid.h(7): note: failure was because type 'tsm::counter_inc::<lambda_b5e2635d32ab89691d28703f26c345e2>' is not a literal type
1>p:\mis-proyectos\personal\tsm\inc\tsm\src\eventqueue.h(27): warning C4521: 'tsm::dummy_mutex': multiple copy constructors specified
1>Done building project "tsm_msvc2017.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

DJuego

I believe at this time msvc does not support lamba functions in constexpr functions. Can you check that by writing a simple test?

Unfortunately, my c++ skills are too limited. :-( However i have circumvented the problem with the flag ISO C++17 Standard (/std:c++17). tsm has the tag c-plus-plus-17, but maybe you should make it more explicit.

Now i got :

1>------ Build started: Project: tsm_msvc2017, Configuration: Release x64 ------
1>main.cpp
1>p:\mis-proyectos\personal\tsm\inc\tsm\src\eventqueue.h(27): warning C4521: 'tsm::dummy_mutex': multiple copy constructors specified
1>Generating code
1>All 8 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
1>Finished generating code
1>tsm_msvc2017.vcxproj -> P:\Mis-Proyectos\Personal\tsm\prj\tsm_msvc2017\x64\Release\tsm_msvc2017.exe
1>Done building project "tsm_msvc2017.vcxproj".
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Of course there is no guarantee that it will run correctly. Perhaps you can produce a minimal and complete sample test code?

Thanks

DJuego

Of course there is no guarantee that it will run correctly. Perhaps you can produce a minimal and
complete sample test code?

So I think we definitely need to get the unit tests (BUILD_TESTS option) working on windows. I've made some changes in the feature/configure_dependencies. Can you update and test again? If the binary ./bin/tsm_test is created, just run it.

I have updated to new tsm-feature-configure_dependencies. Unfortunately, it does not work.

With Default options:
USE_GLOG OFF
BUILD_TESTS ON

I have attached the output log and CMakeOutput.log.
CMakeOutput.log
log.txt

DJuego

I'm setting up a windows vm and looking into it.

I've pushed a commit to the feature branch. It will build the tests and run them. That way you know it's working. However, linking to glog libraries is broken. Hope it's useful.

Thank you for your efforts!

And congratulations! It works! Apparently all tests passed.

test_tsm_debug

However i miss a x64 configuration. Now it only has a x86 configuration (win32) in tests.

There are things that I wish would be different. My personal preference is that it should not be necessary to build anything in order to use the library, and zero-dependencies. Simply we should just drop the library into the code. No special installation steps should be needed. See, for example, https://digint.ch/tinyfsm.

But it is your library, and it is likely that you have good technical reasons to make that decision.

Thank you again @dibsonmuad !

DJuego

I don't force any configuration to be 32-bit. I remember why I stayed away from windows :). GTest usually has a lot of trouble as well. The main issue was that gtest v1.8.0 was breaking on msvc 2017. I had to rev up the version to v1.8.1.

I've seen tinyfsm. It is really great! I needed hierarchical and orthogonal statechart support which is why I wrote this. I also plan to make the event queue distributed.

Decided to use the Catch2 header-only cpp unit testing library to eliminate gtest dependency. Glog dependency will be eliminated by defining "null" LOG and DLOG macros. If the developer wants to use glog, they can include it in their program where these macros resolve to Glog types. Thanks @DJuego! Opening two separate issues to track these. Closing this one.