Custom compilation? (Compile only changed files)

When I was in ArchLinux, writing C++ code, I used to have them MakeFile files to specify exactly how I want compilation to be. Something like this:

program_NAME := binary
program_C_SRCS := $(wildcard *.c)
program_CXX_SRCS := $(wildcard *.cpp)
program_C_OBJS := ${program_C_SRCS:.c=.o}
program_CXX_OBJS := ${program_CXX_SRCS:.cpp=.o}
program_OBJS := $(program_C_OBJS) $(program_CXX_OBJS)
program_INCLUDE_DIRS := ./include
program_LIBRARY_DIRS :=
program_LIBRARIES :=
program_HEADERS := $(wildcard *.h)

CPPFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))
LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))
LDFLAGS += $(foreach library,$(program_LIBRARIES),-l$(library))
CXXFLAGS += -g

.PHONY: all clean distclean

all: $(program_NAME)

$(program_OBJS): $(program_HEADERS)

$(program_NAME): $(program_OBJS)
	$(LINK.cc) $(program_OBJS) -o $(program_NAME)

clean:
	# @- $(RM) $(program_NAME)
	@- $(RM) $(program_OBJS)

distclean: clean

Thus, when I build, only the files that did change gets recompiled.

Can this be achieved in Unity? in someway? I really don’t like the fact that my whole project gets recompiled just cause I added a Debug.Log - And yes, I read this, and it doesn’t say much.

Thanks.

Hello,

In Unity there are a few different “levels” of scripts. As you probably know some files in special folders get compiled before others, such as anything in an Editor folder, or anything in the Standard Assets. These levels can be slit up like so:

  1. Everything in an Editor folder in Standard Assets gets compiled. Boo and UJS get compiled into one assembly, while C# gets compiled into another.
  2. Everything in the Standard Assets folder, that isn’t in Editor gets compiled. The language split up is the same throughout the entire proccess.
  3. Everything outside of the Standard Assets in an Editor folder gets compiled.
  4. Everything outside of both the Standard Assets and any Editor folder gets compiled.

When all the scripts in one of these levels get compiled, they are all put together into one big source. So when you write different scripts in the same level, you’re basically writing one big file. I’m pretty sure that even in C++ you can’t compile pieces of a file individually :wink:

In the end you end up with 8 assemblies altogether. I’m pretty sure that Unity doesn’t recompile all of them if only one has been changed, so therefore the most optimisation that can be done is already done.

The only way around this is to compile your own assemblies into dynamically linked libraries and put those into the Pligins folder. I found a editor script on the wiki that does this with C# files here. It probably won’t work with any scripts that are not self-contained, but you never know :wink:

Hope this helps,
Benproductions1