#include #include #include "projet.h" #include "projetx.m" /* Transaction pour prendre un projet. Ne copie que le fichier makefile.dat et cr‚ation du fichier objdist. Le fichier objdist est cr‚‚ dans le r‚pertoire des objets. S'assure que tout les fichiers sont extrait dans le r‚pertoire ombre. Retourne -1 si erreur. */ static int near prjenv_get ( USERINFO *user, const char *projet, const char *pathmake, // Path relatif du makefile.dat dans ombre // ou NULL si n'existe pas dans ombre. bool getsub, // Prend r‚cursivement les sous-r‚pertoires. bool getobj, // Cr‚ation des r‚pertoires pour compilation bool tolere, // Accepte echec de mkf.addbuild(). PROJET_LOG *log) // Log optionnel { char usrpath[MAXSIZ_PATH]; user->makusrpath(projet,usrpath); if (log != NULL) log->printf ("\tprjenv_get: usrpath = %s\n",usrpath); int ret; if( projet[0] != '\0' && file_type( usrpath) == 1){ ret= 0; }else if( (ret = file_mkdiranc (usrpath)) == -1){ xconf_error (MSG_R(E_DIRCREATE),usrpath); }else{ path_make (usrpath,"makefile.dat",usrpath); char ombpath[MAXSIZ_PATH]; if (pathmake != NULL){ user->makombpath (pathmake,ombpath); pathmake = ombpath; } if (ret != -1){ MAKEFILE mkf (pathmake,true,projet,user); if (mkf.isok()){ ret = mkf.extract (1); // S'assure que tous les // fichiers sont extraits } if (ret != -1){ // addbuild a l'effet secondaire de copier le fichier // dans l'espace usager. ret = mkf.addbuild(); if (log != NULL) log->printf ("\taddbuild %d\n",ret); if (tolere) ret = 0; } if (ret != -1){ if (getobj){ char objpath[MAXSIZ_PATH]; user->makobjpath(projet,objpath); if (file_mkdiranc(objpath) == -1){ xconf_error (MSG_R(E_DIRCREATE),objpath); ret = -1; }else{ path_make (objpath,"objdist",objpath); if (file_touch(objpath,1) == -1){ xconf_error (MSG_U(E_FILECREATE ,"Ne peut pas créer le fichier\n%s") ,objpath); ret = -1; } } } if (ret != -1){ int nbsub = 0; if (getsub){ // Copie les sous-r‚pertoires si pr‚sents mkf.setiter(); MAKEFILE_FILE *file; ret = 0; while ((file=mkf.iter("*/makefile.dat"))!=NULL){ char newprojet[MAXSIZ_PATH]; path_splitlex (file->getnom(),newprojet,NULL); #ifdef MISSING_OLD /* A cause d'un bug, certain makefile.dat font r‚f‚rence au sous-r‚pertoire h et doc. On elimine le problŠme ici. Les sous-r‚pertoires h et doc sont cr‚er si requis plus loin dans cette fonction. */ if (strcmp(newprojet,"h")!=0 && strcmp(newprojet,"doc")!=0){ #endif path_make (projet,newprojet,newprojet); mkf.extract (file,0); ret = prjenv_get (user,newprojet ,file->getrelpath(),getsub,getobj,log); if (ret == -1) break; nbsub++; } } /* #Sp‚cification: archivage / installation de la racine Les sous-r‚pertoires h et doc sont toujours cr‚‚ au moment de l'installation de la racine dans l'environnement usager ou l'environnement /kit/build. */ #if MISSING_OLD if (ret != -1 && (nbsub > 0 || projet[0] == '\0')){ // Cr‚ation des sous-r‚pertoire h et doc char newprojet[MAXSIZ_PATH]; path_make (projet,"h",newprojet); ret = prjenv_get (user,newprojet,NULL,1,getobj,1,log); path_make (projet,"doc",newprojet); ret |= prjenv_get (user,newprojet,NULL,1,getobj,1,log); } #endif } } } } if (log != NULL) log->printf ("\tprjenv_get: retourne %d\n",ret); return ret; } /* Transaction pour prendre un projet. Ne copie que le fichier makefile.dat et cr‚ation du fichier objdist. Le fichier objdist est cr‚‚ dans le r‚pertoire des objets. S'assure que tout les fichiers sont extrait dans le r‚pertoire ombre. Retourne -1 si erreur. */ int prjenv_get ( USERINFO *user, const char *projet, const char *pathmake, // Path relatif du makefile.dat dans ombre // ou NULL si n'existe pas dans ombre. bool getsub, // Prend r‚cursivement les sous-r‚pertoires. bool getobj, // Cr‚ation des r‚pertoires pour compilation PROJET_LOG *log) // Log optionnel { return prjenv_get(user,projet,pathmake,getsub,getobj,false,log); } static int near prjenv_delete(const char *path) { int ret = dir_delete(path,NULL); if (ret == -1){ xconf_error (MSG_U(E_DELETE ,"Destruction incomplète de %s") ,path); } return ret; } /* Efface les fichiers de l'environnement usager */ int prjenv_deldir ( USERINFO *user, const char *projet, int srcdir, // D‚truit le r‚pertoire o— sont les sources int objdir) // D‚truit les objets { int ret = 0; char usrpath[MAXSIZ_PATH]; user->makusrpath(projet,usrpath); char objpath[MAXSIZ_PATH]; user->makobjpath(projet,objpath); if (srcdir && file_type(usrpath) == 1) ret = prjenv_delete (usrpath); if (ret != -1 && objdir && strcmp(objpath,usrpath) != 0 && file_type(objpath) == 1) ret = prjenv_delete (objpath); return ret; }