c-for-go icon indicating copy to clipboard operation
c-for-go copied to clipboard

How to add a Framework?

Open danjenkins opened this issue 3 years ago • 5 comments

I've offered up CFLAGS and LDFLAGS for how to find the CoreFoundation framework but while it's processing the file given in Includes in the GENERATOR section...it fails to find the framework during the processing step

processing decklink.yml ⠋[ERR] ./sdk/Mac/include/DeckLinkAPI.h:46:10: include file not found: CoreFoundation/CoreFoundation.h. Search paths:

The search paths don't note the flags....

Here are the flags given...

  FlagGroups:
    - name: CFLAGS
      traits: ["darwin"]
      flags:
        - "-F/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks"
        - "-framework CoreFoundation"
    - name: LDFLAGS
      traits: ["darwin"]
      flags:
        - "-F/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks"
        - "-framework CoreFoundation"

If anyones got any ideas that would be great :D

EDIT:

My parser section looks like...

PARSER:
  IncludePaths:
    - /usr/include
    - /usr/local/include
  SourcesPaths:
    - ./sdk/Mac/include/DeckLinkAPI.h
  Arch: aarch64

But then theres no way to provide framework's to the parser section?

danjenkins avatar Sep 16 '22 12:09 danjenkins

  1. Parser uses those paths to find and parse headers. Usually I plug in the frameworks only to provide symbols for linking, i.e. in LDFLAGS.

  2. Parsing frameworks (OS X) folders weren't feasible before, as it contained too much VERY advanced code constructs, and CCv1 (the previous parser) wasn't able to handle it. After this PR https://github.com/xlab/c-for-go/pull/127 which upgraded to new parser CCv4 the situation might've changed.

  3. If you need to provide frameworks for linking, the best way is to put those flags into a separate file manually, because using that in FlagGroups means that it will be included in every Go file generated. Which is not always a problem, but just doesn't look nice.

Example file: https://github.com/vulkan-go/vulkan/blob/master/vulkan_darwin.go (I did it manually)

Also, check out how folks at GLFW do it: https://github.com/go-gl/glfw/blob/master/v3.3/glfw/build.go

xlab avatar Sep 16 '22 22:09 xlab

If you don't mind sharing a minimal reproducible example.. I can try :D

xlab avatar Sep 16 '22 22:09 xlab

hey @xlab here's the repo - https://github.com/broadcastervc/go-decklink - I wouldnt call the Decklink SDK minimal though :(

The Decklink SDK is a c++ sdk with "extern C" which should mean it's usable by c-for-go ?

To get c-for-go to be happy with the files on linux I needed to add struct before REFIID in a few files. The files would all get processed correctly but then I'm stuck on what I need to add to the yml file to make it output functions.

I still can't get past the CoreFoundation framework on mac though even after upgrading to the latest version of c-for-go

danjenkins avatar Sep 17 '22 11:09 danjenkins

I wouldnt call the Decklink SDK minimal though

I am not afraid of big examples :D Just mentioned minimal in case you don't want to share the full code.

which should mean it's usable by c-for-go ?

true!

I still can't get past the CoreFoundation framework

I will try on this week.

xlab avatar Sep 19 '22 16:09 xlab

hey @xlab did you ever get a chance to take a look at this? just coming back to it now myself.

danjenkins avatar Jan 04 '23 17:01 danjenkins