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

Convert build system to CMake #2

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Bb]uild*
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[submodule "Jinja2Cpp"]
path = Jinja2Cpp
url = ../Jinja2Cpp
url = ../../katietz/Jinja2Cpp
[submodule "yaml-cpp"]
path = yaml-cpp
url = ../yaml-cpp
url = ../../katietz/yaml-cpp
branch = master
79 changes: 79 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
cmake_minimum_required(VERSION 3.0.0)

set(target_name crender)
project("${target_name}")

# update submodules

# jinja2cpp
add_subdirectory(Jinja2Cpp)

# yaml-cpp
add_subdirectory(yaml-cpp)


# Possibly set some flags
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing" )
#set(CMAKE_POSITION_INDEPENDENT_CODE ON)


# Boost!
#find_package( Boost REQUIRED date_time thread system chrono)
#include_directories(SYSTEM ${Boost_INCLUDE_DIRS})

#if( NOT WIN32 AND NATIVE_SIZE EQUAL 64 )
# set( Boost_LIBRARIES ${Boost_LIBRARIES} rt)
#endif()



# Not everyone considers GLOBing good form in a mature project.
file(GLOB_RECURSE src_cpp src/*.cpp src/*.cc)
file(GLOB_RECURSE src_h src/*.h)

add_executable(${target_name} ${src_cpp} ${src_h} )
set_property(TARGET ${target_name} PROPERTY CXX_STANDARD 17)

target_include_directories(${target_name} PRIVATE
${CMAKE_SOURCE_DIR}/src
)

target_include_directories(${target_name} SYSTEM PRIVATE
${CMAKE_SOURCE_DIR}/Jinja2Cpp/include
${CMAKE_SOURCE_DIR}/yaml-cpp/include
)

#target_link_directories(${target_name} PRIVATE # maybe this should be public?
# )

target_link_libraries(${target_name} PRIVATE # maybe this should be public?
jinja2cpp
yaml-cpp
pthread
)

if( APPLE OR UNIX OR MINGW )
target_compile_options(${target_name} PRIVATE
-Wall
-Wextra
-Werror
-Wfloat-equal
-Wshadow
# -Wduplicated-branches
-Wctor-dtor-privacy
-Wnon-virtual-dtor
-Wsuggest-override
-Wredundant-decls
# -Wlogical-op
-Wold-style-cast
)

elseif(MSVC)
target_compile_options(${target_name} PRIVATE
/W4
/WX
)

else()
message(FATAL_ERROR "Can't set compile options")
endif()
13 changes: 13 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog
All notable changes to this project will be documented in this file.

## [yy.ddd] - tbd
- Warnings as errors, increase warning level.
- Make finding the 'Data' directory more robust.
- Attempt to create output directory when it doesn't exist.
- Add default output directory.
- Change build system to CMake.

## [0.1] - 2021-12-29
- Addition of changelog.
- Fork from katietz.
52 changes: 22 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,48 +13,42 @@ This is a small tool intended to do linting, pre-rendering, and analysis of cond
It supports some jinja2 features (be aware it doesn't support full python-language feature)
It outputs files in yaml format.

Building / Installing
---------------------
Acquiring
---------

Right now build scripts are only available for Unix-like operating systems. Nevertheless the
adjustments required for Windows are pretty straight-forward, and just a few adjustments might be necessary for it.
Assuming a checkout from git, ensure submodules are updated:
`git submodule update --init`

1. Build `Jinja2Cpp` by executing the `bldJinja2Cpp.sh` script (or run its cmake manually).
Note: Test test-suite is not adjusted, so don't wonder if it fails right now.
```
$ ./bldJinja2Cpp.sh
```
Building
--------

2. Build `yaml-cpp` by executing the `bldYaml-cpp.sh` script.
```
$ ./bldYaml-cpp.sh
```
Just use cmake as you normally would. For example:

3. Build `crender` itself by executing the `bld.sh` script.
```
$ ./bld.sh
```sh
mkdir Build && \
cd Build && \
cmake .. -G"Ninja" -DCMAKE_BUILD_TYPE=Release && \
ninja
```

4. Confirm that `crender` is working.
```
$ ./bin/crender --help
```
Note that Windows isn't yet completely supported, though it's probably a trivial change.

5. After building you will find 2 new directories in `crender`'s git root directory.
- `pref/`: Contains all binaries created by `Jinja2Cpp` and `yaml-cpp`.
- `bin/`: Contains the created `crender` binary.
Installing
----------

The `crender` binary assumes there is a `data/` directory at the same level as the `bin/` directory. So if you move `crender` somewhere else, don't forget to also move the `data/` directory and its content accordingly.
The `crender` binary assumes there is a `data/` directory either
colocated with the execuable or at some level above it. If you move
`crender`, don't forget to also move the `data/` directory and its
content accordingly.

Usage
-----

Example (querying all of the feedstocks for `linux-aarch64`):
```sh
./bin/crender -a linux-aarch64 -o ./output_linux-aarch64 -i -S -p 3.8 ../aggregate/*-feedstock
```
$ ./bin/crender -a linux-aarch64 -o ./output_linux-aarch64 -i -S -p 3.8 ../aggregate/*-feedstock
```
NB1: You will ned to make sure the output directory (`-o`) exists before running the command.
NB2: You can specify multiple python versions using the `-p` parameter, and multiple architectures/subdirs with the `-a` parameter.
NB1: You can specify multiple python versions using the `-p` parameter, and multiple architectures/subdirs with the `-a` parameter.

Outputs
-------
Expand Down Expand Up @@ -118,5 +112,3 @@ This sources were majorly extended by Kai Tietz by using the same license for it
yaml-cpp is released under MIT-like license by Jesse Beder.

crender is released under MIT-like license. See LICENSE for more details.


11 changes: 0 additions & 11 deletions bld.sh

This file was deleted.

19 changes: 0 additions & 19 deletions bldJinja2Cpp.sh

This file was deleted.

17 changes: 0 additions & 17 deletions bldYaml-cpp.sh

This file was deleted.

8 changes: 4 additions & 4 deletions src/lint.cc
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ void info_add_output_envp(const char *pkname, const char *version, const char *e
if (nstr == version)
{
const YAML::Node &nn = n[version];
size_t nz2 = nn.size();
//size_t nz2 = nn.size();
for (size_t j = 0; j < 0; j++)
{
nstr = cr_get_config_str(nn, j, "");
Expand Down Expand Up @@ -789,7 +789,7 @@ static bool has_requires_pkg_in(const char *sname, const YAML::Node &pk, const c
if (!n.IsSequence())
return false;
size_t sz = n.size();
size_t l = strlen(dep);
//size_t l = strlen(dep);
for (size_t j = 0; j < sz; j++)
{
std::string msg = cr_get_config_str(n, j, "");
Expand Down Expand Up @@ -861,7 +861,7 @@ void info_add_depends_on_kind_pkg(const char *pkname, const char *nver, const ch
{
if (!dep || *dep == 0)
return;

std::string pn = pkname;
if (nver && *nver != 0)
{
Expand Down Expand Up @@ -1103,4 +1103,4 @@ static void check_command_script_line(const char *s, const char *pkname, const c
add_info_note(pkname, pkver, msg.c_str());
}
}
}
}
Loading