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

Add posix port headers for ib build tool support #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hooddanielc
Copy link

@hooddanielc hooddanielc commented Oct 20, 2018

The problem

I love ib build tool. It help keeps my code sane and easy to integrate with other projects. When building one of the examples, I ran into a lot of errors with undefined references. The references were undefined because ib could not find the implementation of some functions. I believe this is because ib works by running the preprocessor on the target, then follows all headers files in the evaluated source code and repeats for all found implementations. The problem is the source code for modest is unable to be compiled this way. So I decided to change some things to allow ib to compile one of the examples. I hope this is ok :)

The solution

In order for the build tool to work on Modest source code, I need to at least add missing headers for posix port implementation and any other implementations lacking a include-able header. I definitely missed some in this pr, but I didn't want to continue in case this pr is not welcome. I hope these changes are ok.

What worked for me

The following build tool specific code was not added to this pr because I thought it would be redundant when a Makefile is already used. I do not care to add build tool specific code to the project unless the project decided to replace make with ib. I got ib working in a few steps after this code change.

  • Create file to tell ib where project root is
    source/__ib__

        touch source/__ib__
    
  • Create file to specify simple compiler and make options. More info here
    source/debug.cfg

        cc = Obj(
          tool='clang',
          flags=[],
          hdrs_flags=[ '-MM', '-MG' ],
          incl_dirs=[]
        )
    
        link = Obj(
          tool='clang',
          flags=[ '-pthread' ],
          libs=[],
          static_libs=[],
          lib_dirs=[]
        )
    
        make = Obj(
          tool='make',
          flags=[ '-s' ],
          force_flag='-B',
          all_pseudo_target='all'
        )
    
  • Create a new target that can be compiled using ib, it's a modified version of examples/modest/css_property_to_node.c. I needed to include myport/posix headers and any others to fix undefined reference errors.
    source/css_property_to_node.c

        /* ALLOW INCLUDING PORT IMPLEMENTATION USING IB */
        #include <myport/posix/mycore/utils/mcsync.h>
        #include <myport/posix/mycore/io.h>
        #include <myport/posix/mycore/memory.h>
        #include <myport/posix/mycore/thread.h>
        #include <myport/posix/mycore/perf.h>
        
        /* INCLUDE MISSED HEADERS */
        #include <myhtml/tag_init.h>
        #include <mycss/property/parser.h>
        #include <mycss/property/parser_text_decoration.h>
        #include <mycss/property/parser_background.h>
        #include <mycss/property/parser_url.h>
        #include <mycss/property/parser_image.h>
        #include <myencoding/detect.h>
        /* .... REST OF examples/modest/css_property_to_node.c */
    
  • Build target using ib and run

        # switch /usr/bin/python to python2
        cd source
        # remove all .o files so ib know to compile .c files to continue following headers
        rm **/*.o
        # build executable target (no extension)
        ib css_property_to_node
        # run built executable
        ../out/debug/css_property_to_node
    

Will any changes in this pr negatively impact other users of Modest?

No impact at all, assuming I did not make any mistakes. The implementation is unchanged left intact.

Add missing header files to misc implementations for ib build tool
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.

1 participant