Skip to content
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

Improve CSP Generation #336

Open
rbugajewski opened this issue Jan 28, 2020 · 5 comments
Open

Improve CSP Generation #336

rbugajewski opened this issue Jan 28, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@rbugajewski
Copy link
Collaborator

When using CSP, the drogon_ctl command creates its build artifacts in the same directory as the *.csp files. This is quite annoying, because it pollutes a directory that is supposed to be part of the source files. For example when I have a template called About.csp, I get the following files as a result:

  • About.cc
  • About.h
  • About.so
  • About.so.dSYM/

As these files aren’t meant to be user-editable, I would greatly prefer to have them reside in a completely different directory.

@an-tao
Copy link
Member

an-tao commented Jan 28, 2020

@rbugajewski If you use drogon_ctl to create a project(drogon_ctl create project ...), you will find some lines in the CMakeLists.txt file as follows:

file(GLOB SCP_LIST ${CMAKE_CURRENT_SOURCE_DIR}/views/*.csp)
foreach(cspFile ${SCP_LIST})
    message(STATUS "cspFile:" ${cspFile})
    get_filename_component(classname ${cspFile} NAME_WE)
    message(STATUS "view classname:" ${classname})
    ADD_CUSTOM_COMMAND(OUTPUT ${classname}.h ${classname}.cc
            COMMAND drogon_ctl
            ARGS create view ${cspFile}
            DEPENDS ${cspFile}
            VERBATIM )
    set(VIEWSRC ${VIEWSRC} ${classname}.cc)
endforeach()

This means that you do not need to manually create the source files for views. These files are created automatically by cmake in the building directory.
I don't know if this will help you, but I will add extra parameters to this command to support creating source files in the target directory

@rbugajewski
Copy link
Collaborator Author

@an-tao Thanks for your answer, in fact I’ve already set it up this way. Maybe this is related to the load_dynamic_views configuration variable (that is really nice during development) and I wrongly assumed this would be because of drogon_ctl?

@an-tao
Copy link
Member

an-tao commented Jan 28, 2020

Oh, I get it. If load_dynamic_views is enabled, drogon will automatically create source files in the path where the csp files are located and compile them. I haven't thought about it carefully, sorry. I will find a solution.

@an-tao an-tao added the enhancement New feature or request label Jan 28, 2020
@an-tao
Copy link
Member

an-tao commented Jan 28, 2020

@rbugajewski I added a new option dynamic_views_output_path to the configuration file, and now drogon search scp files recursively in the dynamic view pathes.
Please check, thanks.

@rbugajewski
Copy link
Collaborator Author

I just checked out and smoke tested the dev branch. As an example it is now possible to have a navigation layout in views/components/Navigation.csp separated from the “main content” templates and to reference the navigation layout in a main view with <%view Navigation %>.

Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants