Homogenization of Dirichlet and Neumann problems with gradient constraints