Skip to content
Snippets Groups Projects
Commit 25c056b6 authored by Lars Bilke's avatar Lars Bilke Committed by Lars Bilke
Browse files

[CMake] Added CMake target web.

Building the target installs node packages, imports from Contentful and
builds the site via gulp and hugo.
parent ca829946
No related branches found
No related tags found
No related merge requests found
...@@ -40,6 +40,7 @@ include(scripts/cmake/test/Test.cmake) ...@@ -40,6 +40,7 @@ include(scripts/cmake/test/Test.cmake)
if(OGS_COVERAGE AND NOT IS_SUBPROJECT) if(OGS_COVERAGE AND NOT IS_SUBPROJECT)
include(scripts/cmake/Coverage.cmake) include(scripts/cmake/Coverage.cmake)
endif() endif()
include(scripts/cmake/Web.cmake)
#################### ####################
### More Options ### ### More Options ###
......
...@@ -64,8 +64,14 @@ if(CCACHE_FOUND) ...@@ -64,8 +64,14 @@ if(CCACHE_FOUND)
endif() endif()
endif(CCACHE_FOUND) endif(CCACHE_FOUND)
# Tools for web
find_program(VTKJS_CONVERTER vtkDataConverter find_program(VTKJS_CONVERTER vtkDataConverter
PATHS ${CMAKE_SOURCE_DIR}/web/node_modules/.bin) PATHS ${CMAKE_SOURCE_DIR}/web/node_modules/.bin)
find_program(HUGO hugo)
find_program(NPM npm)
find_program(YARN yarn)
find_program(PIP pip)
find_package(PythonInterp)
###################### ######################
### Find libraries ### ### Find libraries ###
......
if(NOT NPM OR NOT PIP OR NOT PYTHON_EXECUTABLE)
return()
endif()
if(YARN)
set(PACKAGE_MANAGER ${YARN})
else()
set(PACKAGE_MANAGER "${NPM} install")
endif()
add_custom_target(web-install
COMMAND ${PACKAGE_MANAGER}
COMMAND ${PIP} install -r requirements.txt
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/web
BYPRODUCTS ${CMAKE_SOURCE_DIR}/web/node_modules
)
add_custom_target(web-import
COMMAND ${PYTHON_EXECUTABLE} import.py
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/web/import
DEPENDS web-install
)
add_custom_target(web
COMMAND ${NPM} run build
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/web
DEPENDS web-install web-import
)
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
- Install Node packages with `npm install` (or via `yarn`), *OPTIONAL* for SCSS and Javascript - Install Node packages with `npm install` (or via `yarn`), *OPTIONAL* for SCSS and Javascript
- Install Python packages with `pip install -r requirements.txt`, *OPTIONAL* for getting content from [Contentful](https://app.contentful.com/spaces/4nuqzxntzxks) - Install Python packages with `pip install -r requirements.txt`, *OPTIONAL* for getting content from [Contentful](https://app.contentful.com/spaces/4nuqzxntzxks)
Alternatively you can simply run `make web` inside your build directory to install everything and build the site (this requires that `python`, `pip` and `npm` was found by CMake).
## Start servers and watchers ## Start servers and watchers
hugo server hugo server
...@@ -14,7 +16,7 @@ If you want to modify css or javascript run `gulp` in another terminal: ...@@ -14,7 +16,7 @@ If you want to modify css or javascript run `gulp` in another terminal:
## Build site ## Build site
(cd import; python import.py) # Optional for fetching content from Contentful (cd import; python import.py) # Optional for fetching content from Contentful, needs credentials setup, rename `secret_example.py` to `secret.py`
npm run build npm run build
Test by locally serving via [Caddy](https://caddyserver.com): Test by locally serving via [Caddy](https://caddyserver.com):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment