From dynamic to static large deviations in boundary driven exclusion particle systems