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

feat: update generated file #11

Merged
merged 8 commits into from
Dec 19, 2024
Merged
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
8 changes: 4 additions & 4 deletions .github/workflows/ci_macos.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: macOS 12
name: macOS 13

on:
push:
Expand All @@ -21,14 +21,14 @@ defaults:
jobs:
build:
name: ${{ matrix.name }}
runs-on: macos-12
runs-on: macos-13
timeout-minutes: 180
strategy:
fail-fast: false
matrix:
include:
- name: "clang12 (c++20)"
compiler: "clang-12"
- name: "clang17 (c++20)"
compiler: "clang-17"
build_type: Release
cpp: 20

Expand Down
35 changes: 20 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,37 @@ CXXFLAGS += -Werror -Wextra -Wall

cwl_v1_2.h: FORCE
schema-salad-tool --codegen cpp \
--codegen-spdx-copyright-text "Copyright 2016-2023 CWL Project Contributors" \
--codegen-spdx-copyright-text "Copyright 2016-2024 CWL Project Contributors" \
--codegen-spdx-license-identifier "Apache-2.0" \
https://github.com/common-workflow-language/cwl-v1.2/raw/main/CommonWorkflowLanguage.yml \
> $@

## clean : clean up the build
clean: FORCE
rm -f cwl_output_example cwl_input_example output_cwl.cwl
rm -f cwl_output_example cwl_input_example cwl_input_example_store_config

## regen_parser : regenerate the CWL v1.2 parser
regen_parser: cwl_v1_*.h

define run_test
@result="$(shell eval $(1) | md5sum -b)" ; \
expected="$(shell eval $(2) | md5sum -b)" ; \
if [ "$$result" != "$$expected" ] ; then \
echo test failed '$(1)': $$result != $$expected; exit 1; \
fi;
endef

## tests : compile and run the tests
tests: FORCE cwl_output_example cwl_input_example
@result_output="$(shell ./cwl_output_example | md5sum -b)" ; \
result_input="$(shell ./cwl_input_example expected_cwl.cwl | md5sum -b)" ; \
expected="$(shell cat expected_cwl.cwl | md5sum -b)" ; \
if [ "$$result_output" = "$$expected" ] ; then \
if [ "$$result_input" = "$$expected" ] ; then \
echo test passed ; \
else \
echo test failed cwl_input_example $$result_input != $$expected; exit 1; \
fi \
else \
echo test failed cwl_output_example $$result_output != $$expected; exit 1; \
fi
tests: FORCE cwl_output_example cwl_input_example cwl_input_example_store_config
$(call run_test,./cwl_output_example,cat tests/expected_cwl.cwl)
$(call run_test,./cwl_input_example tests/expected_cwl.cwl,cat tests/expected_cwl.cwl)
$(call run_test,./cwl_input_example_store_config tests/01_types.cwl,cat tests/01_types_expected.cwl)
$(call run_test,./cwl_input_example_store_config tests/01_types.cwl no_simplification,cat tests/01_types_expected_no_simplification.cwl)
$(call run_test,./cwl_input_example_store_config tests/01_types.cwl no_list_to_map,cat tests/01_types_expected_no_list_to_map.cwl)
$(call run_test,./cwl_input_example_store_config tests/01_types.cwl no_simplification no_list_to_map,cat tests/01_types_expected_no_simplification_and_list_to_map.cwl)
$(call run_test,./cwl_input_example tests/02_expression.cwl,cat tests/02_expression_expected.cwl)

@echo test passed
FORCE:

# Use this to print the value of a Makefile variable
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ It is a single header and can be copied into your own project for any usage.

The usage can be seen in the [cwl_output_example.cpp](cwl_output_example.cpp) file, which show cases on how to describe your tools.
Another short example of loading a CWL description file an be seen in [cwl_input_example.cpp](cwl_input_example.cpp).

The generations was done by calling:
make cwl_v1_2.h
17 changes: 4 additions & 13 deletions cwl_input_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,13 @@
* It loads a CWL description from a file and populates C++ classes.
*/


// using shortened cwl:: namespace instead of https___w3id_org_cwl_cwl
namespace cwl = https___w3id_org_cwl_cwl;
// using shortened cwl:: namespace instead of w3id_org::cwl
namespace cwl = w3id_org::cwl;

int main(int argc, char** argv) {
if (argc != 2) return 1;

auto yaml = YAML::LoadFile(argv[1]);
auto tool = cwl::CommandLineTool{};
fromYaml(yaml, tool);

auto y = toYaml(tool);

YAML::Emitter out;
out << y;
std::cout << out.c_str() << "\n";

auto tool = cwl::load_document(argv[1]);
cwl::store_document(tool, std::cout);
return 0;
}
34 changes: 34 additions & 0 deletions cwl_input_example_store_config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "cwl_v1_2.h"

#include <iostream>

/**
* This test program creates loads and prints a CWL description.
*
* It assumes that printing to stdout works (see cwl_output_example).
* It loads a CWL description from a file and populates C++ classes.
*/

// using shortened cwl:: namespace instead of w3id_org::cwl
namespace cwl = w3id_org::cwl;

int main(int argc, char** argv) {
if (argc < 2) return 1;

auto tool = cwl::load_document(argv[1]);

// parse command line
auto config = cwl::store_config{};
for (int i{2}; i < argc; ++i) {
auto sv = std::string_view{argv[i]};
if (sv == "no_simplification") {
config.simplifyTypes = false;
} else if (sv == "no_list_to_map") {
config.transformListsToMaps = false;
} else if (sv == "tags") {
config.generateTags = true;
}
}
cwl::store_document(tool, std::cout, config);
return 0;
}
10 changes: 3 additions & 7 deletions cwl_output_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* It should print a valid CWL description to stdout.
*/

// using shortened cwl:: namespace instead of https___w3id_org_cwl_cwl
namespace cwl = https___w3id_org_cwl_cwl;
// using shortened cwl:: namespace instead of w3id_org::cwl::cwl
namespace cwl = w3id_org::cwl::cwl;

int main() {
// declaring information about this tool in general
Expand Down Expand Up @@ -105,9 +105,5 @@ int main() {
}


auto y = toYaml(tool);

YAML::Emitter out;
out << y;
std::cout << out.c_str() << "\n";
w3id_org::cwl::store_document(tool, std::cout);
}
Loading
Loading