Skip to content

Suggestion: custom post-generator scripts #144

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

Open
code-disaster opened this issue Apr 27, 2017 · 1 comment
Open

Suggestion: custom post-generator scripts #144

code-disaster opened this issue Apr 27, 2017 · 1 comment
Labels

Comments

@code-disaster
Copy link
Contributor

code-disaster commented Apr 27, 2017

Use case: I'm doing a little side-project which uses Crinkler to shrink the executable. For this build variant, I'm using VS2013 because Crinkler doesn't work well with more recent versions of the Windows SDK.

My current work flow:

  • Run ./fips gen win32-vs2013-minsizerel which is a release config which adds the /CRINKLER link parameter, among other things.
  • Run ./fips open win32-vs2013-minsizerel to load the VS 2013 project.
  • In the VS2013 project properties, add ${projectRoot}\ to the ExecutablePath settings.
  • In my project root, there is the Crinkler executable named link.exe which is then picked as the linker by Visual Studio.
  • Redo the changes inside VS each time the project changes, and project files are overwritten.

Now, in theory there is a CMake option to customize the linker executable, but my StackOverflow skills have failed me to find a working solution, if there even is one supposed to work with the VS generators.

Here's the idea: Allow a post-generator script, very much like code generation, which runs after ./fips gen. The script can just sit in fips-generators, and can be added as an option to fips-configs/${my-custom-config}.yml.

The script may need to pass a few information, e.g. the project root, the generator output path in fips-build/, and/or the (a list of) project path(s). In my example, a custom script would then try to open fips-build/${path-to-project}/${project-name}.vcxproj, and inject an <ExecutablePath> property.

@floooh floooh assigned floooh and unassigned floooh Apr 27, 2017
@floooh floooh added the feature label Apr 27, 2017
@floooh
Copy link
Owner

floooh commented Apr 27, 2017

Sounds doable :)

In the meantime a workaround could be to write your own 'fips verb' scripts, which runs the 'fips gen' functionality, and after that injects crinkle, it would look roughly like this (copied from https://github.com/floooh/oryol/blob/master/fips-verbs/testrunner.py), and you would run "./fips crinkle" instead of "./fips gen"

from mod import log, project, settings, util, config

#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args) :
    cfg_name = settings.get(proj_dir, 'config')
    project.gen(fips_dir, proj_dir, cfg_name)

    # for each application target, inject crinkle in vcxproj file
    cfg = config.load(fips_dir, proj_dir, cfg_name)[0]
    proj_name = util.get_project_name_from_dir(proj_dir)
    build_dir = util.get_build_dir(fips_dir, proj_name, cfg)
    success, targets = project.get_target_list(fips_dir, proj_dir, cfg_name)
    if success :
        app_targets = [tgt for tgt in targets if targets[tgt] == 'app']
        for app in app_targets :
            # hmmmmm... ok now it gets tricky... the vcxproj file for this
            # target which has been generated by cmake is somewhere under 
            # build_dir but we don't have the information WHERE... so some
            # hackery and hard-wiring would be involved here...
            log.info(">>> patching vcxproj for target '{}'".format(app))

#-------------------------------------------------------------------------------
def help() :
    log.info(log.YELLOW +
             'fips crinkle\n' +
             log.DEF +
             '    gen and inject crinkle')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants