gobject-introspection: GIR: tries to find .gir in a current vocabulary's directory, in system gir-1.0 (/usr/share/gir-1.0, /usr/local/share/gir-1.0)
or user-defined (GIR_DIRS env. variable) directories;db4
parent
479304d0a7
commit
1dcb49b0d4
|
@ -1,15 +1,47 @@
|
||||||
! Copyright (C) 2010 Anton Gorenko.
|
! Copyright (C) 2010 Anton Gorenko.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors combinators gobject-introspection.common
|
USING: accessors combinators environment gobject-introspection.common
|
||||||
gobject-introspection.ffi gobject-introspection.loader
|
gobject-introspection.ffi gobject-introspection.loader
|
||||||
gobject-introspection.types kernel lexer locals namespaces parser
|
gobject-introspection.types io io.files io.pathnames kernel lexer
|
||||||
sequences xml ;
|
locals make namespaces parser sequences splitting summary vocabs
|
||||||
|
vocabs.parser xml ;
|
||||||
IN: gobject-introspection
|
IN: gobject-introspection
|
||||||
|
|
||||||
|
ERROR: gir-not-found name paths ;
|
||||||
|
|
||||||
|
M: gir-not-found summary
|
||||||
|
[ name>> "“" "” file not found on paths:\n" surround ]
|
||||||
|
[ paths>> "\n" join ] bi
|
||||||
|
"\n\nUse the existing path or declare GIR_DIRS environment variable"
|
||||||
|
3append ;
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
:: define-gir-vocab ( file-name -- )
|
: system-gir-dirs ( -- dirs )
|
||||||
file-name file>xml xml>repository
|
"XDG_DATA_DIRS" os-env "/usr/local/share/:/usr/share/" or
|
||||||
|
":" split [ "gir-1.0" append-path ] map ;
|
||||||
|
|
||||||
|
: custom-gir-dirs ( -- dirs )
|
||||||
|
"GIR_DIRS" os-env ":" split ;
|
||||||
|
|
||||||
|
: current-vocab-dirs ( -- dirs )
|
||||||
|
[
|
||||||
|
current-vocab vocab-name "." split "/" join dup ,
|
||||||
|
dup file-name "ffi" = [ parent-directory , ] [ drop ] if
|
||||||
|
] { } make ;
|
||||||
|
|
||||||
|
:: resolve-gir-path ( path -- path )
|
||||||
|
path exists?
|
||||||
|
[ path ] [
|
||||||
|
current-vocab-dirs custom-gir-dirs system-gir-dirs
|
||||||
|
3append sift :> paths
|
||||||
|
paths [ path append-path exists? ] find nip
|
||||||
|
[ path append-path ] [ path paths gir-not-found ] if*
|
||||||
|
] if ;
|
||||||
|
|
||||||
|
: define-gir-vocab ( path -- )
|
||||||
|
resolve-gir-path dup " loading " write print
|
||||||
|
file>xml xml>repository
|
||||||
{
|
{
|
||||||
[ namespace>> name>> current-namespace-name set-global ]
|
[ namespace>> name>> current-namespace-name set-global ]
|
||||||
[ def-ffi-repository ]
|
[ def-ffi-repository ]
|
||||||
|
|
Loading…
Reference in New Issue