Files

copied
Last update 5 years 5 months by njbane
Filesulps
..
tmp_oshpark
DESCRIPTION
oshpark-install.ulp
oshpark-update.ulp
oshpark-upload.ulp
oshpark-utility-includes.ulp
oshpark.ulp
oshpark-install.ulp
// Find some useful locations #include "oshpark-utility-includes.ulp" void install(string SOURCEDIR){ string SELF=argv[0]; string SELF_DIR=filedir(SELF); string ULP_DIR=path_ulp[0]; string DRU_DIR=path_dru[0]; string CAM_DIR=path_cam[0]; string SCR_DIR=path_scr[0]; string LBR_DIR=path_lbr[0]; string BIN_DIR=filedir(EAGLE_PATH); string EAGLESCR_PATH=SCR_DIR+"/eagle.scr"; string MENU_STR=""+ "' [oshpark.png]Oshpark{"+ "Upload PCB: RUN oshpark-upload.ulp;"+ "|"+ "Check for updates: RUN oshpark.ulp update;"+ "|"+ "Update and install:RUN oshpark.ulp update install;"+ "} '"; sprintf(MENU_STR,"MENU %s;\n",MENU_STR); // Get the script name printf("Script self: %s\n",SELF); printf("Script self dir: %s\n",SELF_DIR); printf("File source dir: %s\n",SOURCEDIR); printf("ULP Dir: %s\n",ULP_DIR); printf("SCR Dir: %s\n",SCR_DIR); printf("BIN Dir: %s\n",BIN_DIR); real VERSION=EAGLE_VERSION+EAGLE_RELEASE/10.0; printf("Found Eagle Version %f\n",VERSION); // Copy over new files copy_dir(SOURCEDIR+"/ulp/",ULP_DIR); copy_dir(SOURCEDIR+"/bin/",BIN_DIR); copy_dir(SOURCEDIR+"/dru/",DRU_DIR); copy_dir(SOURCEDIR+"/lbr/",LBR_DIR); if(VERSION>=7.2){ copy_dir(SOURCEDIR+"/cam-7.2+/",CAM_DIR); } else{ copy_dir(SOURCEDIR+"/cam/",CAM_DIR); } // Dig through the existing Eagle.scr and add our menu item // NOTE: Eagle replaces \n with \r\n during printfs, // so a correctly printed string will not match the scanned one // without factoring in this substitution. string EAGLE_SCR_DATA[]; int EAGLE_SCR_DATA_SIZE; EAGLE_SCR_DATA_SIZE=fileread(EAGLE_SCR_DATA,SCR_DIR+"/eagle.scr"); string LINE; int BRD_START=-1; int BRD_END=-1; int i; // Find the BRD section for(i=0;i<EAGLE_SCR_DATA_SIZE; i++){ LINE=EAGLE_SCR_DATA[i]; BRD_START=i; if(strstr(LINE,"BRD:")==0 ){ break; } } // Scan for the next section for(i=BRD_START+1;i<EAGLE_SCR_DATA_SIZE; i++){ LINE=EAGLE_SCR_DATA[i]; BRD_END=i; if(strxstr(LINE,"[A-Z]{3}:")==0 ){ break; } } printf("Found a brd section from %d to %d\n", BRD_START,BRD_END); //don't mangle the file unless we need to. printf("?? %s ??\n",EAGLE_SCR_DATA[BRD_END-1]); printf("++ %s ++\n",MENU_STR); if(BRD_END>0 && strstr(EAGLE_SCR_DATA[BRD_END-1]+"\r\n",MENU_STR)>=0){ printf("Menu already installed!\n"); printf("> %s\n", EAGLE_SCR_DATA[BRD_END-1]); } else{ printf("Installing menu.!\n"); printf(">> %s\n",MENU_STR); backup_file(EAGLESCR_PATH); // Print a new menu line at the end of the BRD section output(EAGLESCR_PATH,"wt"){ for(i=0;i<EAGLE_SCR_DATA_SIZE; i++){ if(i==BRD_END && BRD_START==EAGLE_SCR_DATA_SIZE){ printf("BRD:\n"); } if(i==BRD_END){ printf(MENU_STR); } printf("%s\n",EAGLE_SCR_DATA[i]); } } } } string SCRIPTSELF=filename(argv[0]); string SCRIPTSELF_DIR=filedir(argv[0]); if(SCRIPTSELF=="oshpark-install.ulp"){ output("install.log","w") { install(SCRIPTSELF_DIR+"/.."); } }
Report a bug