简体   繁体   中英

Compiling workflow with version control

Up till now I've used version control for simple web-based projects that don't really have a compile stage. I've now forked a relatively large project that follows the standard "./configure; make; make install" pattern. I'm unsure about the proper workflow for this type of project.

What do I do with all the created files from the compile process?

  • Add lots of stuff to .gitignore? This is hard, because I did not create the build process and do not really understand everything that is created.
  • Checkout the project somewhere else for each build? This seems like a pain, given that I often build every few minutes.
  • Just make sure never to add something I don't know about, ie never do git add . If so, how do I cleanup now and then?

Obviously this is something everybody who deals with compiled code faces, so I'm sure there's an accepted pattern, I just am not familiar with it yet.

I agree with ChrisF, don't store binaries generated by the build in your repository. Your goal should be to have a nice .gitignore file, so that at any time running git status should show no "untracked files". That means git is either ignoring or tracking all files.

One procedure I use to build my .gitignore is this:

  1. add and commit all source to project (before anything was built)

    cd project

    git add .

    git commit -m'initial import'

  2. add simple patterns of files that will be ignored to .gitignore ; this includes tings like *.o, *.so.

    echo '*.o' > .gitignore

    echo '*.so' >> .gitignore

  3. then I run the build.

    make

  4. then I run

    git ls-files -o >> .gitignore

    which will pick up any outstanding files that are generated which you didn't specify with glob patterns.

-Bart

To clean up your working directory, you can use git clean . It won't do any harm by default, unless you specify the -f (force) flag.

The command line git clean -xfd will delete everything in your working directory, that is not in version control.

Simple strategy is to store make output in another directory, eg build and then ignore this directory. You can configure it like this:

mkdir build && cd build && ../configure

You shouldn't put intermediate or output files under source control. If you did you'd have to check them out to make the files writeable every time you compiled and built the solution.

You don't say what IDE (if any) you are using - check to see if it can add the project to source control for you. If it can then use this option as it will only add those files that are absolutely needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM