Place the basil leaves, pine nuts, garlic (if using), and a pinch of salt in the bowl of a food processor fitted with a blade attachment. Process for about 5 or 6 (1-second) pulses. Add the grated cheeses and process for another 5 or 6 (1-second) pulses. With the motor running, add the oil in a slow, steady stream and process until the mixture’s smooth. Taste the pesto and season with salt and pepper.