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

Auto-generated distinct macros per lib. Resolves #428 #429

Merged
merged 1 commit into from
Nov 28, 2020

Conversation

iboB
Copy link
Contributor

@iboB iboB commented Nov 19, 2020

This was generated by the following ruby script:

SDECL = 'SOKOL_API_DECL'

def process_file(fname)
  lines = File.readlines(fname)

  lines.find { |line|
    line =~ /^#if.* SOKOL_([A-Z]_+)_INCLUDED/
  }
  ldecl = "SOKOL_#{$1}_API_DECL"

  decl_line = lines.index { |line|
    line =~ /^#if.* #{SDECL}/
  }

  return if !decl_line

  lines.map! { |line|
    line.
      gsub("#{SDECL}" + ' ' * (ldecl.length - SDECL.length), ldecl).
      gsub(SDECL, ldecl)
  }

  lines[decl_line, 0] = <<~EOF
    #if defined(#{SDECL}) && !defined(#{ldecl})
        #define #{ldecl} #{SDECL}
    #endif

  EOF

  File.write(fname, lines.join)
end

# process_file 'sokol_time.h'

Dir['**/*.h'].each do |f|
  process_file f
end

@iboB
Copy link
Contributor Author

iboB commented Nov 19, 2020

oops... forgot to mark this as a draft. Sorry about that

This is not ready to merge, yet. I saw some problems from the script. If all checks pass, I'll fix the problems manually

@iboB iboB force-pushed the distinct_export_macros branch from bdab256 to 3f6829c Compare November 19, 2020 12:19
@iboB iboB force-pushed the distinct_export_macros branch from 3f6829c to 426c460 Compare November 19, 2020 12:20
@iboB
Copy link
Contributor Author

iboB commented Nov 19, 2020

Ok. All checks have passed. I fixed the bad auto-generation of sokol_gfx_imgui.

@floooh I think this is ready for merge

@floooh
Copy link
Owner

floooh commented Nov 28, 2020

Ok, I'm merging this now (manually, as I usually do). I wonder if the macro is actually needed inside the SOKOL_IMPL block too, I'll experiment with this on Windows a bit. (ah nvm, I confused this with the separate SOKOL_API_IMPL macro...), it'll probably make sense to give this the same treatment... I'll think about it.

@floooh floooh merged commit fad0bf8 into floooh:master Nov 28, 2020
@floooh
Copy link
Owner

floooh commented Nov 28, 2020

..and merged, many thanks!

@iboB iboB deleted the distinct_export_macros branch February 2, 2022 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants