pkg-config file now has script pathes
[unitool.git] / db / LoadLibtoolObject.java
blobbebcdc62e121e0fb3300ce780897bd8bb489dd48
2 package org.de.metux.unitool.db;
4 import org.de.metux.util.ShellVariableDef;
5 import org.de.metux.util.StrUtil;
6 import org.de.metux.util.PathNormalizer;
8 import java.io.BufferedReader;
9 import java.io.IOException;
10 import java.io.FileNotFoundException;
11 import java.io.FileReader;
13 import org.de.metux.unitool.base.ObjectInfo;
16 // if we have an relative filename (within another directory),
17 // we assume this as a prefix.
20 public class LoadLibtoolObject
22 static private String _fix_fn(String dirname, String filename)
24 if (dirname==null)
25 return filename;
27 if (filename.startsWith("/"))
28 return filename;
30 if ((dirname==null)||(dirname.length()==0))
31 return filename;
33 return dirname+"/"+filename;
36 static public ObjectInfo load_lo(String fn)
37 throws FileNotFoundException, IOException
39 BufferedReader in = new BufferedReader(new FileReader(fn));
41 String dirname = PathNormalizer.dirname(fn);
42 if (!StrUtil.isEmpty(dirname))
43 dirname += "/";
45 String line;
46 ObjectInfo inf = new ObjectInfo();
47 inf.lo_file = fn;
49 while ((line=in.readLine())!=null)
51 ShellVariableDef shvar;
53 try
55 shvar = new ShellVariableDef(line);
57 catch (ShellVariableDef.XEmpty e)
59 continue;
61 catch (ShellVariableDef.XParseFailed e)
63 throw new RuntimeException("parse error in "+fn+": "+e);
66 if (shvar.value.length()==0)
67 continue;
69 if (shvar.name.equals("pic_object"))
70 inf.object_pic = _fix_fn(dirname,shvar.value);
71 else if (shvar.name.equals("non_pic_object"))
72 inf.object_nonpic = _fix_fn(dirname,shvar.value);
73 else
74 throw new RuntimeException
76 "Unhandled variable: \""+
77 shvar.name+"\" => \""+
78 shvar.value+"\""
82 System.out.println("LoadLibtoolObject(): fn=\""+fn+"\" pic=\""+inf.object_pic+"\" nonpic=\""+inf.object_nonpic);
84 return inf;