Skip to content

Commit 4e1ff79

Browse files
SGSSGenemr-c
andauthored
feat: update generated file (#11)
--------- Co-authored-by: Michael R. Crusoe <[email protected]> Co-authored-by: Michael R. Crusoe <[email protected]>
1 parent 22b65b0 commit 4e1ff79

15 files changed

+5454
-2368
lines changed

.github/workflows/ci_macos.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: macOS 12
1+
name: macOS 13
22

33
on:
44
push:
@@ -21,14 +21,14 @@ defaults:
2121
jobs:
2222
build:
2323
name: ${{ matrix.name }}
24-
runs-on: macos-12
24+
runs-on: macos-13
2525
timeout-minutes: 180
2626
strategy:
2727
fail-fast: false
2828
matrix:
2929
include:
30-
- name: "clang12 (c++20)"
31-
compiler: "clang-12"
30+
- name: "clang17 (c++20)"
31+
compiler: "clang-17"
3232
build_type: Release
3333
cpp: 20
3434

Makefile

+20-15
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,37 @@ CXXFLAGS += -Werror -Wextra -Wall
2424

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

3232
## clean : clean up the build
3333
clean: FORCE
34-
rm -f cwl_output_example cwl_input_example output_cwl.cwl
34+
rm -f cwl_output_example cwl_input_example cwl_input_example_store_config
3535

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

39+
define run_test
40+
@result="$(shell eval $(1) | md5sum -b)" ; \
41+
expected="$(shell eval $(2) | md5sum -b)" ; \
42+
if [ "$$result" != "$$expected" ] ; then \
43+
echo test failed '$(1)': $$result != $$expected; exit 1; \
44+
fi;
45+
endef
46+
3947
## tests : compile and run the tests
40-
tests: FORCE cwl_output_example cwl_input_example
41-
@result_output="$(shell ./cwl_output_example | md5sum -b)" ; \
42-
result_input="$(shell ./cwl_input_example expected_cwl.cwl | md5sum -b)" ; \
43-
expected="$(shell cat expected_cwl.cwl | md5sum -b)" ; \
44-
if [ "$$result_output" = "$$expected" ] ; then \
45-
if [ "$$result_input" = "$$expected" ] ; then \
46-
echo test passed ; \
47-
else \
48-
echo test failed cwl_input_example $$result_input != $$expected; exit 1; \
49-
fi \
50-
else \
51-
echo test failed cwl_output_example $$result_output != $$expected; exit 1; \
52-
fi
48+
tests: FORCE cwl_output_example cwl_input_example cwl_input_example_store_config
49+
$(call run_test,./cwl_output_example,cat tests/expected_cwl.cwl)
50+
$(call run_test,./cwl_input_example tests/expected_cwl.cwl,cat tests/expected_cwl.cwl)
51+
$(call run_test,./cwl_input_example_store_config tests/01_types.cwl,cat tests/01_types_expected.cwl)
52+
$(call run_test,./cwl_input_example_store_config tests/01_types.cwl no_simplification,cat tests/01_types_expected_no_simplification.cwl)
53+
$(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)
54+
$(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)
55+
$(call run_test,./cwl_input_example tests/02_expression.cwl,cat tests/02_expression_expected.cwl)
56+
57+
@echo test passed
5358
FORCE:
5459

5560
# Use this to print the value of a Makefile variable

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ It is a single header and can be copied into your own project for any usage.
1313

1414
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.
1515
Another short example of loading a CWL description file an be seen in [cwl_input_example.cpp](cwl_input_example.cpp).
16+
17+
The generations was done by calling:
18+
make cwl_v1_2.h

cwl_input_example.cpp

+4-13
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,13 @@
99
* It loads a CWL description from a file and populates C++ classes.
1010
*/
1111

12-
13-
// using shortened cwl:: namespace instead of https___w3id_org_cwl_cwl
14-
namespace cwl = https___w3id_org_cwl_cwl;
12+
// using shortened cwl:: namespace instead of w3id_org::cwl
13+
namespace cwl = w3id_org::cwl;
1514

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

19-
auto yaml = YAML::LoadFile(argv[1]);
20-
auto tool = cwl::CommandLineTool{};
21-
fromYaml(yaml, tool);
22-
23-
auto y = toYaml(tool);
24-
25-
YAML::Emitter out;
26-
out << y;
27-
std::cout << out.c_str() << "\n";
28-
18+
auto tool = cwl::load_document(argv[1]);
19+
cwl::store_document(tool, std::cout);
2920
return 0;
3021
}

cwl_input_example_store_config.cpp

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include "cwl_v1_2.h"
2+
3+
#include <iostream>
4+
5+
/**
6+
* This test program creates loads and prints a CWL description.
7+
*
8+
* It assumes that printing to stdout works (see cwl_output_example).
9+
* It loads a CWL description from a file and populates C++ classes.
10+
*/
11+
12+
// using shortened cwl:: namespace instead of w3id_org::cwl
13+
namespace cwl = w3id_org::cwl;
14+
15+
int main(int argc, char** argv) {
16+
if (argc < 2) return 1;
17+
18+
auto tool = cwl::load_document(argv[1]);
19+
20+
// parse command line
21+
auto config = cwl::store_config{};
22+
for (int i{2}; i < argc; ++i) {
23+
auto sv = std::string_view{argv[i]};
24+
if (sv == "no_simplification") {
25+
config.simplifyTypes = false;
26+
} else if (sv == "no_list_to_map") {
27+
config.transformListsToMaps = false;
28+
} else if (sv == "tags") {
29+
config.generateTags = true;
30+
}
31+
}
32+
cwl::store_document(tool, std::cout, config);
33+
return 0;
34+
}

cwl_output_example.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* It should print a valid CWL description to stdout.
99
*/
1010

11-
// using shortened cwl:: namespace instead of https___w3id_org_cwl_cwl
12-
namespace cwl = https___w3id_org_cwl_cwl;
11+
// using shortened cwl:: namespace instead of w3id_org::cwl::cwl
12+
namespace cwl = w3id_org::cwl::cwl;
1313

1414
int main() {
1515
// declaring information about this tool in general
@@ -105,9 +105,5 @@ int main() {
105105
}
106106

107107

108-
auto y = toYaml(tool);
109-
110-
YAML::Emitter out;
111-
out << y;
112-
std::cout << out.c_str() << "\n";
108+
w3id_org::cwl::store_document(tool, std::cout);
113109
}

0 commit comments

Comments
 (0)