Usually, building a temple is no problem at all. There is incredible benefit for the sentient beings that get killed during construction: worms, insects, and so on. They are never reborn in the lower realms, and receive a good rebirth. This is due to the power of holy objects, because Buddha is free from all defilements and has perfected all qualities, including the inconceivable powers that are inspired by and achieved through compassion for all sentient beings. A temple or monastery is a merit field for the Buddha, Dharma, and Sangha. Even when we build ordinary rooms, we should build them with the idea that we are building a home for the Triple Gem.
It is the same for sentient beings killed by vehicles or by being stepped on during construction of a temple. They share in the merit of building the temple, because they gave their lives for the temple to be built. Therefore, they are not reborn in the lower realms.
There is a quotation from an Indian pandit which states that when you build a monastery, any insect that dies during construction is never reborn in the lower realms. Even when you cook food for the people who are building the monastery, whoever is touched by the smoke of the cooking is liberated from the lower realms. This is due to the role of the people building the temple, monastery, or meditation hall, which is connected with the power of the Buddha and the Triple Gem.
You can construct any building with the idea that you are creating a home for the Triple Gem, and then when you have finished, you can place a picture of the Buddha in it, and it becomes a temple. When you do this, you fulfill the motivation you set at the beginning of the project, so it isn’t a lie. Then, since the construction took place for the sake of building a temple or monastery, those sentient beings killed during the process are protected from the lower realms.