void link(void) { int i; FILE *fp; if ( ( obj_file_cnt() + lib_file_cnt() ) > 0 ) { if ( get_dosex() != OPT_PMODE ) fprintf( stderr, "LINK use only with PMODE!\n" ); sprintf( args, "/NOIGNORECASE %s @" RESPONSE " ", get_option(OPT_MAPFILE) ? "/MAP" : "" ); fp = response( RESPONSE ); if (! get_option(OPT_NODEFLIB) ) { if ( get_option(OPT_DEBUG) ) fprintf(fp,"%s\\C0DOSD.OBJ", get_syslib_path() ); else fprintf(fp,"%s\\C0DOS.OBJ", get_syslib_path() ); } for ( i = 0; i < obj_file_cnt(); i++ ) fprintf( fp, " %s", obj_file(i) ); fprintf( fp, "\n%s\n%s\n", get_exe_name(), get_option( OPT_MAPFILE) ? get_exe_name() : "NUL" ); if (! get_option(OPT_NODEFLIB) ) fprintf(fp,"%s\\CLDOS.LIB", get_syslib_path() ); for ( i = 0; i < lib_file_cnt(); i++ ) fprintf( fp, " %s", lib_file(i) ); fprintf( fp, "\n" ); fclose(fp); exec("LINK", args ); if (! get_option(OPT_KEEPRSP) ) unlink( RESPONSE ); } }
void wlink(void) { int i; char *dosx; FILE *fp; if ( ( obj_file_cnt() + lib_file_cnt() ) > 0 ) { switch ( get_dosex() ) { case OPT_PMODEW:dosx = "pmodew.exe"; break; case OPT_DOS4G: dosx = "4gs.exe"; break; case OPT_WDOSX: dosx = "wdosxle.exe"; break; case OPT_DOS32A:dosx = "dos32a.exe"; break; case OPT_ZRDX: dosx = "zrdx.exe"; break; case OPT_CAUSEWAY: dosx = "cwstub.exe"; break; case OPT_D3X: dosx = "d3xw.exe"; break; case OPT_PMODE: default: fprintf( stderr, "WLINK NO use with PMODE!\n" ); dosx = "4gs.exe"; break; } fp = response( RESPONSE ); fprintf( fp, "op osname=CC386[%s]\n" "format os2 le\n" "op nod\n" "op quiet\n" "op stub=%s\\%s\n" "name %s\n", dosx, get_syslib_path(), dosx, get_exe_name() ); if ( get_option(OPT_MAPFILE) ) fprintf( fp, "op map\n" ); if ( get_option(OPT_DEBUG) ) fprintf( fp, "debug all \nop symf\n" ); if (! get_option(OPT_NODEFLIB) ) fprintf( fp, "file %s\\C0DOSW.OBJ\n", get_syslib_path() ); for( i = 0; i < obj_file_cnt(); i++) fprintf( fp, "file %s\n", obj_file(i) ); if (! get_option(OPT_NODEFLIB) ) fprintf( fp, "library %s\\CLDOS.LIB\n", get_syslib_path() ); for( i = 0; i < lib_file_cnt(); i++) fprintf( fp, "library %s\n", lib_file(i) ); fclose(fp); exec("WLINK", "@" RESPONSE ); if (! get_option(OPT_KEEPRSP) ) unlink( RESPONSE ); } }
void tlink(void) { int i; FILE *fp; if ( ( obj_file_cnt() + lib_file_cnt() ) > 0 ) { if ( get_dosex() != OPT_PMODE ) fprintf( stderr, "TLINK use only with PMODE!\n" ); fp = response( RESPONSE ); fprintf( fp, "/3/c/d%s%s", get_option(OPT_MAPFILE) ? "/m/l/s" : "/x", get_option(OPT_DEBUG) ? "/v" : "" ); if ( lib_file_cnt() > 0 ) fprintf(fp, "/L%s ", get_lib_path() ); if (! get_option(OPT_NODEFLIB) ) { if ( get_option(OPT_DEBUG) ) fprintf(fp,"%s\\C0DOSD.OBJ", get_syslib_path() ); else fprintf(fp,"%s\\C0DOS.OBJ", get_syslib_path() ); } for ( i = 0; i < obj_file_cnt(); i++ ) fprintf( fp, " %s", obj_file(i) ); fprintf( fp, ",%s,%s,", get_exe_name(), get_option( OPT_MAPFILE) ? get_exe_name() : "NUL" ); if (! get_option(OPT_NODEFLIB) ) fprintf(fp,"%s\\CLDOS.LIB", get_syslib_path() ); for ( i = 0; i < lib_file_cnt(); i++ ) fprintf( fp, " %s", lib_file(i) ); fprintf( fp, "\n" ); fclose(fp); exec("TLINK", "@" RESPONSE ); if (! get_option(OPT_KEEPRSP) ) unlink( RESPONSE ); } }
/** * Non-Windows shared library constructor. This ensures that the environment * variable \c TWEEK_BASE_DIR is set as soon as this shared library is loaded. * If it is not set, then it sets it based on an assumption about the * structure of a Tweek installation. More specifically, an assumption is made * that this shared library lives in the \c lib subdirectory of the Tweek * installation. Therefore, the root of the Tweek installation is the parent * of the directory containing this shared library. */ extern "C" void __attribute ((constructor)) tweekLibraryInit() { fs::path base_dir; const char* env_dir = std::getenv("TWEEK_BASE_DIR"); // If TWEEK_BASE_DIR is not set, look up the path to this shared library // and use it to provide a default setting for that environment variable. if ( NULL == env_dir ) { Dl_info info; info.dli_fname = 0; const int result = #if defined(__GNUC__) && __GNUC_MAJOR__ < 4 dladdr((void*) &tweekLibraryInit, &info); #else dladdr(reinterpret_cast<void*>(&tweekLibraryInit), &info); #endif // NOTE: dladdr(3) really does return a non-zero value on success. if ( 0 != result ) { try { fs::path lib_file(info.dli_fname, fs::native); lib_file = fs::system_complete(lib_file); #if defined(VPR_OS_IRIX) && defined(_ABIN32) const std::string bit_suffix("32"); #elif defined(VPR_OS_IRIX) && defined(_ABI64) || \ defined(VPR_OS_Linux) && defined(__x86_64__) const std::string bit_suffix("64"); #else const std::string bit_suffix(""); #endif // Get the directory containing this shared library. const fs::path lib_path = lib_file.branch_path(); // Start the search for the root of the Tweek installation in the // parent of the directory containing this shared library. base_dir = lib_path.branch_path(); // Use the lib subdirectory to figure out when we have found the // root of the Tweek installation tree. const fs::path lib_subdir(std::string("lib") + bit_suffix); bool found(false); while ( ! found && ! base_dir.empty() ) { try { if ( ! fs::exists(base_dir / lib_subdir) ) { base_dir = base_dir.branch_path(); } else { found = true; } } catch (fs::filesystem_error&) { base_dir = base_dir.branch_path(); } } if ( found ) { setenv("TWEEK_BASE_DIR", base_dir.native_directory_string().c_str(), 1); } } catch (fs::filesystem_error& ex) { std::cerr << "Automatic assignment of TWEEK_BASE_DIR failed:\n" << ex.what() << std::endl; } } } else { try { base_dir = fs::path(env_dir, fs::native); } catch (fs::filesystem_error& ex) { std::cerr << "Invalid path set in TWEEK_BASE_DIR environment " << "variable:\n" << ex.what() << std::endl; } } if ( ! base_dir.empty() ) { // If base_dir were empty, this would result in data_dir being relative // to the current working directory. const fs::path data_dir = base_dir / TWEEK_SHARE_DIR; // We use the overwrite value of 0 as a way around testing whether the // environment variable is already set. setenv("TWEEK_DATA_DIR", data_dir.native_directory_string().c_str(), 0); } }
/** * Non-Windows shared library constructor. This ensures that the environment * variable \c GADGET_BASE_DIR is set as soon as this shared library is loaded. * If it is not set, then it sets it based on an assumption about the * structure of a Gadgeteer installation. More specifically, an assumption is * made that this shared library lives in the \c lib subdirectory of the * Gadgeteer installation. Therefore, the root of the Gadgeteer installation * is the parent of the directory containing this shared library. */ extern "C" void __attribute ((constructor)) gadgetLibraryInit() { fs::path base_dir; const char* env_dir = std::getenv("GADGET_BASE_DIR"); // If GADGET_BASE_DIR is not set, look up the path to this shared library // and use it to provide a default setting for that environment variable. if ( NULL == env_dir ) { Dl_info info; info.dli_fname = 0; const int result = #if defined(__GNUC__) && __GNUC_MAJOR__ < 4 dladdr((void*) &gadgetLibraryInit, &info); #else dladdr(reinterpret_cast<void*>(&gadgetLibraryInit), &info); #endif // NOTE: dladdr(3) really does return a non-zero value on success. if ( 0 != result ) { try { fs::path lib_file( #if BOOST_VERSION >= 104600 && BOOST_FILESYSTEM_VERSION == 3 info.dli_fname #else info.dli_fname, fs::native #endif ); lib_file = fs::system_complete(lib_file); #if defined(GADGET_LIBDIR_NAME) const std::string lib_dir_name(GADGET_LIBDIR_NAME); #else const std::string lib_dir_name("lib"); #endif // Get the directory containing this shared library. const fs::path lib_path = lib_file.branch_path(); // Start the search for the root of the Gadgeteer installation in // the parent of the directory containing this shared library. base_dir = lib_path.branch_path(); // Use the lib subdirectory to figure out when we have found the // root of the Gadgeteer installation tree. const fs::path lib_subdir(lib_dir_name); bool found(false); while ( ! found && ! base_dir.empty() ) { try { if ( ! fs::exists(base_dir / lib_subdir) ) { base_dir = base_dir.branch_path(); } else { found = true; } } catch (fs::filesystem_error&) { base_dir = base_dir.branch_path(); } } if ( found ) { setenv("GADGET_BASE_DIR", #if BOOST_VERSION >= 104600 && BOOST_FILESYSTEM_VERSION == 3 base_dir.native().c_str(), #else base_dir.native_directory_string().c_str(), #endif 1); } } catch (fs::filesystem_error& ex) { std::cerr << "Automatic assignment of GADGET_BASE_DIR failed:\n" << ex.what() << std::endl; } } } else { try { base_dir = #if BOOST_VERSION >= 104600 && BOOST_FILESYSTEM_VERSION == 3 fs::path(env_dir); #else fs::path(env_dir, fs::native); #endif } catch (fs::filesystem_error& ex) { std::cerr << "Invalid path set in GADGET_BASE_DIR environment " << "variable:\n" << ex.what() << std::endl; } } if ( ! base_dir.empty() ) { // If base_dir were empty, this would result in data_dir being relative // to the current working directory. const fs::path data_dir = base_dir / GADGET_SHARE_DIR; // We use the overwrite value of 0 as a way around testing whether the // environment variable is already set. setenv("GADGET_DATA_DIR", #if BOOST_VERSION >= 104600 && BOOST_FILESYSTEM_VERSION == 3 data_dir.native().c_str(), #else data_dir.native_directory_string().c_str(), #endif 0); } }
bool SRAssembler::read_library_file() { ifstream lib_file(this->library_file.c_str()); string line; Library* lib = NULL; while (getline(lib_file, line)){ line = trim(line); if (line == "[LIBRARY]") { if (lib != NULL){ if (lib->get_left_read() == ""){ print_message("r1 file is expected in config file!"); return false; } this->libraries.push_back(*lib); } lib = new Library(this->libraries.size(), this->data_dir, this->tmp_dir, this->logger); } else { vector<string> tokens; tokenize(line, tokens, "="); if (tokens.size() == 2){ string param = trim(tokens[0]); string value = trim(tokens[1]); if (param == "r1" && lib != NULL) { lib->set_left_read(value); if (!file_exists(lib->get_left_read())) { print_message("r1 file in config file: " + lib->get_left_read() + " does not exist!"); return false; } } if (param == "r2" && lib != NULL) { lib->set_right_read(value); if (!file_exists(lib->get_right_read())) { print_message("r2 file in config file: " + lib->get_right_read() + " does not exist!"); return false; } lib->set_paired_end(true); } if (param == "insert_size" && lib != NULL) { lib->set_insert_size(str2int(value)); } if (param == "direction" && lib != NULL) { lib->set_reversed(str2int(value)); } if (param == "format" && lib != NULL) { if (value == "fastq") { lib->set_format(FORMAT_FASTQ); } else if (value == "fasta") { lib->set_format(FORMAT_FASTA); } else { print_message("format in config file should be 'fastq' or 'fasta'!"); return false; } } } } } if (lib != NULL){ if (lib->get_left_read() == ""){ print_message("r1 file is expected in config file!"); return false; } this->libraries.push_back(*lib); } if (this->libraries.size() == 0){ print_message(" No [LIBRARY] section found in config file!"); return false; } return true; }
void valx(void) { int i; FILE *fp; char *c0 = "C0DOS.OBJ"; char *c0d= "C0DOSD.OBJ"; char *cl = "CLDOS.LIB"; char *ci = NULL; char *dosx = NULL; char *lnk_op = "/NCI /32"; if ( ( obj_file_cnt() + lib_file_cnt() ) > 0 ) { int sys = get_dosex(); switch ( sys ) { case OPT_W32CON: c0d = c0 = "C0xwin.obj"; cl = "CLWIN.LIB"; ci = "CLIMP.LIB"; lnk_op = "/NCI /PE"; break; case OPT_W32GUI: c0d = c0 = "C0win.obj"; cl = "CLWIN.LIB"; ci = "CLIMP.LIB"; lnk_op = "/NCI /PE /WIN"; break; case OPT_W32DLL: c0d = c0 = "C0dwin.obj"; cl = "CLWIN.LIB"; ci = "CLIMP.LIB"; lnk_op = "/NCI /PE /BDL"; break; case OPT_DOS32A: c0d = "c0doswd.obj" ; c0 = "c0dosw.obj" ; lnk_op = "/NCI /LE" ; dosx = "stub32a.exe" ; break ; case OPT_PMODEW: c0d = "c0doswd.obj" ; c0 = "c0dosw.obj" ; lnk_op = "/NCI /LE" ; dosx = "pmodew.exe"; break; case OPT_DOS4G: c0d = "c0doswd.obj" ; c0 = "c0dosw.obj" ; lnk_op = "/NCI /LE" ; dosx = "4gstub.exe"; break; case OPT_WDOSX: c0d = "c0doswd.obj" ; c0 = "c0dosw.obj" ; lnk_op = "/NCI /LE" ; dosx = "wdosxle.exe"; break; case OPT_ZRDX: c0d = "c0doswd.obj" ; c0 = "c0dosw.obj" ; lnk_op = "/NCI /LE" ; dosx = "zrdx.exe"; break; case OPT_CAUSEWAY: c0d = "c0doswd.obj" ; c0 = "c0dosw.obj" ; lnk_op = "/NCI /LE" ; dosx = "cwstub.exe"; break; case OPT_HXDOS: c0d = c0 = "C0xwin.obj"; cl = "CLWIN.LIB"; ci = "CLIMP.LIB"; lnk_op = "/NCI /PE"; dosx = "dpmist32.bin"; break; case OPT_WHXDOS: c0d = c0 = "C0doswhx.obj"; lnk_op = "/NCI /PE"; dosx = "hdld32.bin"; break; case OPT_D3X: c0d = "c0doswd.obj"; c0 = "c0dos.obj"; lnk_op = "/NCI /LE" ; dosx = "d3xw.exe"; break; default: fprintf( stderr, "VALX use only with PMODE!\n" ); case OPT_PMODE: break; } fp = response( RESPONSE ); fprintf( fp, "-NOCA -USE32 %s ", get_option(OPT_MAPFILE) ? "-MAP" : "-NOMAP" ); if ( lnk_op ) fprintf( fp, "%s ", lnk_op); if (dosx) fprintf(fp, "-STB:(%s\\%s) ", get_syslib_path(), dosx); if (! get_option(OPT_NODEFLIB) ) { if ( get_option(OPT_DEBUG) ) fprintf(fp,"\"%s\\%s\"", get_syslib_path(), c0d ); else fprintf(fp,"\"%s\\%s\"", get_syslib_path(), c0 ); } for ( i = 0; i < obj_file_cnt(); i++ ) fprintf( fp, " %s", obj_file(i) ); fprintf( fp, ",%s,%s,", get_exe_name(), get_option( OPT_MAPFILE) ? get_exe_name() : "NUL" ); if (! get_option(OPT_NODEFLIB) ) fprintf(fp,"\"%s\\%s\"", get_syslib_path(), cl ); if (ci) fprintf(fp," \"%s\\%s\"", get_syslib_path(), ci ); for ( i = 0; i < lib_file_cnt(); i++ ) fprintf( fp, " %s", lib_file(i) ); fprintf( fp, "\n" ); for ( i = 0; i < res_file_cnt(); i++ ) fprintf( fp, " %s", res_file(i) ); fprintf( fp, "\n\n" ); fclose(fp); exec("VALX", "@" RESPONSE ); if (! get_option(OPT_KEEPRSP) ) unlink( RESPONSE ); if ( !get_option(OPT_KEEPGEN) ) { del_res_tmpfiles(); } if (sys == OPT_WHXDOS) { exec("PATCHPE", get_exe_name()); } } }
void olink(void) { int i; FILE *fp; char *c0 = "c0pm.o"; char *c0d= "c0pmd.o"; char *cl = "cldos.l"; char *ci = NULL; char *lnk_op = "/T:PM"; if ( ( obj_file_cnt() + lib_file_cnt() ) > 0 ) { int sys = get_dosex(); switch ( sys ) { case OPT_W32CON: c0d = c0 = "c0xpe.o"; cl = "clwin.l"; ci = "climp.l"; lnk_op = "/T:CON32"; break; case OPT_W32GUI: c0d = c0 = "c0pe.o"; cl = "clwin.l"; ci = "climp.l"; lnk_op = "/T:GUI32"; break; case OPT_W32DLL: c0d = c0 = "c0dpe.o"; cl = "clwin.l"; ci = "climp.l"; lnk_op = "/T:DLL32"; break; case OPT_DOS32A: c0d = "c0watd.o" ; c0 = "c0wat.o" ; lnk_op = "/T:DOS32;sstub32a.exe" ; break ; case OPT_PMODEW: c0d = "c0watd.o" ; c0 = "c0wat.o" ; lnk_op = "/T:DOS32;spmodew.exe" ; break; case OPT_DOS4G: c0d = "c0watd.o" ; c0 = "c0wat.o" ; lnk_op = "/T:DOS32;s4gstub.exe" ; break; case OPT_WDOSX: c0d = "c0watd.o" ; c0 = "c0wat.o" ; lnk_op = "/T:DOS32;swdosxle.exe" ; break; case OPT_ZRDX: c0d = "c0watd.o" ; c0 = "c0wat.o" ; lnk_op = "/T:DOS32;szrdx.exe" ; break; case OPT_CAUSEWAY: c0d = "c0watd.o" ; c0 = "c0wat.o" ; lnk_op = "/T:DOS32;scwstub.exe" ; break; case OPT_HXDOS: c0d = c0 = "c0xpe.o"; cl = "CLWIN.L"; ci = "CLIMP.L"; lnk_op = "/T:CON32;sdpmist32.bin"; break; case OPT_WHXDOS: c0d = "c0hxd.o"; c0 = "c0hx.o"; lnk_op = "/T:CON32;shdld32.bin /DOBJECTALIGN=10000"; break; case OPT_D3X: c0d = "c0watd.o" ; c0 = "c0wat.o" ; lnk_op = "/T:DOS32;sd3xw.exe" ; break; default: fprintf( stderr, "VALX use only with PMODE!\n" ); case OPT_PMODE: break; } fp = response( RESPONSE ); fprintf( fp, "-c%s", get_option(OPT_MAPFILE) ? " -m" : "" ); fprintf( fp, " -o%s%s", get_exe_name(), get_option( OPT_MAPFILE) ? get_exe_name() : ""); if ( lnk_op ) { fprintf( fp, " %s", lnk_op); } if (! get_option(OPT_NODEFLIB) ) { if ( get_option(OPT_DEBUG) ) fprintf(fp," \"%s\\%s\"", get_syslib_path(), c0d ); else fprintf(fp," \"%s\\%s\"", get_syslib_path(), c0 ); } for ( i = 0; i < obj_file_cnt(); i++ ) fprintf( fp, " %s", obj_file(i) ); for ( i = 0; i < lib_file_cnt(); i++ ) fprintf( fp, " %s", lib_file(i) ); if (! get_option(OPT_NODEFLIB) ) { if (cl) { fprintf(fp," \"%s\\%s\"", get_syslib_path(), cl ); } if (ci) { fprintf(fp," \"%s\\%s\"", get_syslib_path(), ci ); } } for ( i = 0; i < res_file_cnt(); i++ ) fprintf( fp, " %s", res_file(i) ); fclose(fp); exec("olink", "@" RESPONSE ); if (! get_option(OPT_KEEPRSP) ) unlink( RESPONSE ); if ( !get_option(OPT_KEEPGEN) ) { del_res_tmpfiles(); } if (sys == OPT_WHXDOS) { exec("PATCHPE", get_exe_name()); } } }