# Incremental package build



## jamesmintram (Mar 7, 2020)

Hi, So my situation is as follows:

I have a crash bug when running firefox. 
I have built and installed firefox from the ports tree.
I have modified a C file inside of the work folder - and wish to rebuild (ie incrementally) with my change + test
Running make after changing a file in the work folder does nothing

I assume I am missing something? Is this even the right approach? If not, how should I be doing this? (Links to articles/other posts appreciated)


----------



## T-Daemon (Mar 7, 2020)

Try this: After each modification of the C file, from /usr/ports/www/firefox
`rm work/.stage_done.firefox._usr_local`
`rm -r work/stage`
`make`

The "incremental" build will be faster when devel/ccache is installed.


----------



## jamesmintram (Mar 10, 2020)

Thanks. I tried that and it seemed to do something (re-packaging I guess) but it didn't rebuild source file I had changed.

I will try ccache and see if that helps.

I guess one question to ask would be: Is it the right thing to do? Work on a port inside of usr/ports? Or should I copy it to somewhere under my own home folder while I work on it?


----------



## SirDice (Mar 10, 2020)

jamesmintram said:


> I have modified a C file inside of the work folder - and wish to rebuild (ie incrementally) with my change + test
> Running make after changing a file in the work folder does nothing


Create a proper patch file for it in files/. 

https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/slow-patch.html


----------



## jamesmintram (Mar 10, 2020)

OK, I have read that page but it seems related to preparing a patch/port for publication:

`In the preparation of the port, files that have been added or changed can be recorded with diff(1)`

Whereas I am looking for a development workflow. Ie how do I edit, compile + test quickly.


----------



## SirDice (Mar 10, 2020)

Build flow


```
make extract
make patch
(edit files)
make makepatch (to create proper patch files in files/) or do this step by hand
make clean
while true; do
  make
  make clean
done
```


----------



## jamesmintram (Mar 10, 2020)

Thanks! That makes a lot more sense, I assume I can also edit files in the while loop? (Updated below)


```
make extract
make patch
(edit files)
make makepatch (to create proper patch files in files/) or do this step by hand
make clean
while true; do
  (edit files here as well?)
  make
  make clean
done
```


----------



## SirDice (Mar 10, 2020)

A generic `make` typically runs all these in succession (it does a bit more but these are probably the most important ones):

```
make extract # extracts the sources
make patch   # runs any patches, either from the Makefile directly and/or the patches in files/
make configure # runs ./configure
make # Actually builds the thing.
```

You're usually better off working _with_ the ports system and _using_ the features it provides than trying to fight it. Keep in mind that a `make clean` basically removes the work/ directory and thus all your changes and previous (incomplete) builds are gone too. To keep your changes it's imperative to have them in files/, so they are applied every time you run a build.


----------



## jamesmintram (Mar 10, 2020)

I see. Thanks for the information, I think that is enough to help me through!


----------



## SirDice (Mar 10, 2020)

Definitely read through the Porter's handbook. While it's intended to create (and submit) ports for FreeBSD, it contains a lot of information on how a port works, how to build something, dependency chains, etc. There's also the ports(7) man page but that's more a reference to all the various targets you can use as a user of a port.


----------

