common-workflow-library / legacy

Deprecated
https://github.com/common-workflow-library/bio-cwl-tools
Apache License 2.0
100 stars 62 forks source link

example with gcc #3

Closed lindenb closed 9 years ago

lindenb commented 9 years ago

Hi all, this is my latest use-case. As a reminder, I'm trying to (automatically) convert a Makefile to CWL.

The makefile would be

.PHONY:all
all:a.out
a.out: source1.o source2.o
    gcc -o a.out source1.o source2.o
source1.o : source1.c source1.h
    gcc -Wall -c -o source1.o source1.c
source2.o : source2.c
    gcc -Wall -c -o source2.o source2.c

it compiles two sources and link them . See the code under : https://github.com/lindenb/cwl-workflows/tree/compile/workflows/compile

My current broken CWL workflow is here: https://github.com/lindenb/cwl-workflows/tree/compile/workflows/compile

My main problems :

Pierre

tetron commented 9 years ago

Hi, I am on holiday this week and will be able to respond when I am back next week.

On August 5, 2015 3:39:09 AM EDT, Pierre Lindenbaum notifications@github.com wrote:

Hi all, this is my latest use-case. As a reminder, I'm trying to (automatically) convert a Makefile to CWL.

The makefile would be

.PHONY:all
all:a.out
a.out: source1.o source2.o
  gcc -o a.out source1.o source2.o
source1.o : source1.c source1.h
  gcc -Wall -c -o source1.o source1.c
source2.o : source2.c
  gcc -Wall -c -o source2.o source2.c

it compiles two sources and link them . See the code under : https://github.com/lindenb/cwl-workflows/tree/compile/workflows/compile

My current broken CWL workflow is here: https://github.com/lindenb/cwl-workflows/tree/compile/workflows/compile

My main problems :

  • the inputs for the "#compile" are existing files, how should I declare them in the step
  • I'm puzzled how to declare the final output of my workflow; it should be a step specific output id isn't it ? but in https://github.com/common-workflow-language/workflows/blob/master/workflows/hello/hello.cwl it's the output of a tool.
  • there is something wrong in the path, while the makefile above works, the $PATH is 'lost' in cwl-runner and cc1 the subprogram of gcc is not found.
  • how should I declare and run the "#link" tool to use both compiled object ?

Thank you for your help,

Pierre

You can view, comment on, or merge this pull request online at:

https://github.com/common-workflow-language/workflows/pull/3

-- Commit Summary --

  • example with gcc

-- File Changes --

M workflows/README.md (2) A workflows/compile/README.md (19) A workflows/compile/compile1.cwl (68) A workflows/compile/source1.c (3) A workflows/compile/source1.h (1) A workflows/compile/source2.c (1)

-- Patch Links --

https://github.com/common-workflow-language/workflows/pull/3.patch https://github.com/common-workflow-language/workflows/pull/3.diff


Reply to this email directly or view it on GitHub: https://github.com/common-workflow-language/workflows/pull/3

tetron commented 9 years ago

Hi @lindenb

Try this:

#!/usr/bin/env cwl-runner

- id: "#compile"
  class: CommandLineTool
  inputs:
    - id: "#src"
      type: File
      inputBinding: {}
    - id: "#object"
      type: string
      inputBinding:
          prefix: "-o"
  outputs:
    - id: "#compiled"
      type: File
      outputBinding:
          glob:
             engine: cwl:JsonPointer
             script: /job/object
  baseCommand: gcc
  arguments:
    - "-c"
    - "-Wall"

- id: "#link"
  class: CommandLineTool
  inputs:
    - id: "#objects"
      type:  { type: array, items: File }
      inputBinding:
        position: 2
    - id: "#output"
      type: string
      inputBinding:
          position: 1
          prefix: "-o"
  outputs:
    - id: "#executable"
      type: File
      outputBinding:
          glob:
             engine: cwl:JsonPointer
             script: /job/output
  baseCommand: gcc

- id: "#main"
  class: Workflow
  requirements:
    - class: EnvVarRequirement
      envDef:
        - envName: PATH
          envValue: /usr/bin
  inputs: []
  outputs:
    - id: "#main.output"
      type: File
      source: "#linkobj.executable"
  steps :
    - id: "#compilesources-src1"
      run: {import: "#compile"}
      inputs:
         - { id: "#compilesources-src1.src" , default: {class: File, path: "source1.c" } }
         - { id: "#compilesources-src1.object" , default: "source1.o" }
      outputs:
        - { id: "#compilesources-src1.compiled" }

    - id: "#compilesources-src2"
      run: {import: "#compile"}
      inputs:
         - { id: "#compilesources-src2.src" , default: {class: File, path: "source2.c" } }
         - { id: "#compilesources-src2.object" , default: "source2.o" }
      outputs:
         - { id: "#compilesources-src2.compiled" }

    - id: "#linkobj"
      run: {import: "#link"}
      inputs:
         - { id: "#linkobj.objects" , source: ["#compilesources-src1.compiled", "#compilesources-src2.compiled"] }
         - { id: "#linkobj.output" , default: "a.out" }
      outputs:
         - { id: "#linkobj.executable" }
mr-c commented 9 years ago

Hello @lindenb, does @tetron 's suggestion work for you?

lindenb commented 9 years ago

Hi, I'm away from my mail/sources. I'll test this later. P.

lindenb commented 9 years ago

@tetron @mr-c I'm back from my holidays, the solution you provided works fine , thanks ! I've pushed the changes, feel free to merge :-)