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
)
27 if (filename
.startsWith("/"))
30 if ((dirname
==null)||(dirname
.length()==0))
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
))
46 ObjectInfo inf
= new ObjectInfo();
49 while ((line
=in
.readLine())!=null)
51 ShellVariableDef shvar
;
55 shvar
= new ShellVariableDef(line
);
57 catch (ShellVariableDef
.XEmpty e
)
61 catch (ShellVariableDef
.XParseFailed e
)
63 throw new RuntimeException("parse error in "+fn
+": "+e
);
66 if (shvar
.value
.length()==0)
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
);
74 throw new RuntimeException
76 "Unhandled variable: \""+
77 shvar
.name
+"\" => \""+
82 System
.out
.println("LoadLibtoolObject(): fn=\""+fn
+"\" pic=\""+inf
.object_pic
+"\" nonpic=\""+inf
.object_nonpic
);