FACTOR_ROOTS env var

db4
Slava Pestov 2008-12-01 17:19:47 -06:00
parent 973e3faa00
commit 87656b19e3
3 changed files with 22 additions and 7 deletions

View File

@ -1,7 +1,7 @@
! Copyright (C) 2008 Doug Coleman. ! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: assocs combinators kernel sequences splitting system USING: assocs combinators kernel sequences splitting system
vocabs.loader ; vocabs.loader init ;
IN: environment IN: environment
HOOK: os-env os ( key -- value ) HOOK: os-env os ( key -- value )
@ -25,3 +25,8 @@ HOOK: (set-os-envs) os ( seq -- )
{ [ os winnt? ] [ "environment.winnt" require ] } { [ os winnt? ] [ "environment.winnt" require ] }
{ [ os wince? ] [ ] } { [ os wince? ] [ ] }
} cond } cond
[
"FACTOR_ROOTS" os-env os windows? ";" ":" ? split
[ add-vocab-root ] each
] "environment" add-init-hook

View File

@ -13,6 +13,8 @@ $nl
{ $code "\"resource:work\" \"palindrome\" scaffold-vocab" } { $code "\"resource:work\" \"palindrome\" scaffold-vocab" }
"If you look at the output, you will see that a few files were created in your ``work'' directory. The following phrase will print the full path of your work directory:" "If you look at the output, you will see that a few files were created in your ``work'' directory. The following phrase will print the full path of your work directory:"
{ $code "\"work\" resource-path ." } { $code "\"work\" resource-path ." }
"The work directory is one of several " { $link "vocabs.roots" } " where Factor searches for vocabularies. It is possible to define new vocabulary roots; see " { $link "add-vocab-roots" } ". To keep things simple in this tutorial, we'll just use the work directory, though."
$nl
"Open the work directory in your file manager, and open the subdirectory named " { $snippet "palindrome" } ". Inside this subdirectory you will see a file named " { $snippet "palindrome.factor" } ". We will be editing this file." "Open the work directory in your file manager, and open the subdirectory named " { $snippet "palindrome" } ". Inside this subdirectory you will see a file named " { $snippet "palindrome.factor" } ". We will be editing this file."
$nl $nl
"Notice that the file ends with an " { $link POSTPONE: IN: } " form telling Factor that all definitions in this source file should go into the " { $snippet "palindrome" } " vocabulary using the " { $link POSTPONE: IN: } " word:" "Notice that the file ends with an " { $link POSTPONE: IN: } " form telling Factor that all definitions in this source file should go into the " { $snippet "palindrome" } " vocabulary using the " { $link POSTPONE: IN: } " word:"

View File

@ -2,6 +2,18 @@ USING: vocabs vocabs.loader.private help.markup help.syntax
words strings io ; words strings io ;
IN: vocabs.loader IN: vocabs.loader
ARTICLE: "add-vocab-roots" "Working with code outside of the Factor source tree"
"You can work with code outside of the Factor source tree by adding additional directories to the list of vocabulary roots."
$nl
"There are three ways of doing this."
$nl
"The first way is to use an environment variable. Factor looks at the " { $snippet "FACTOR_ROOTS" } " environment variable for a list of " { $snippet ":" } "-separated paths (on Unix) or a list of " { $snippet ";" } "-separated paths (on Windows)."
$nl
"The second way is to create a configuration file. You can list additional vocabulary roots in a file that Factor reads at startup:"
{ $subsection "factor-roots" }
"Finally, you can add vocabulary roots dynamically using a word:"
{ $subsection add-vocab-root } ;
ARTICLE: "vocabs.roots" "Vocabulary roots" ARTICLE: "vocabs.roots" "Vocabulary roots"
"The vocabulary loader searches for it in one of the root directories:" "The vocabulary loader searches for it in one of the root directories:"
{ $subsection vocab-roots } { $subsection vocab-roots }
@ -12,12 +24,8 @@ ARTICLE: "vocabs.roots" "Vocabulary roots"
{ { $snippet "extra" } " - additional contributed libraries." } { { $snippet "extra" } " - additional contributed libraries." }
{ { $snippet "work" } " - a root for vocabularies which are not intended to be contributed back to Factor." } { { $snippet "work" } " - a root for vocabularies which are not intended to be contributed back to Factor." }
} }
"You can store your own vocabularies in the " { $snippet "work" } " directory. You can also store code outside of the Factor source tree by making Factor aware of it first. There are two ways of doing this." "You can store your own vocabularies in the " { $snippet "work" } " directory."
$nl { $subsection "add-vocab-roots" } ;
"You can list additional vocabulary roots in a file that Factor reads at startup:"
{ $subsection "factor-roots" }
"Or you can add them dynamically using a word:"
{ $subsection add-vocab-root } ;
ARTICLE: "vocabs.loader" "Vocabulary loader" ARTICLE: "vocabs.loader" "Vocabulary loader"
"The vocabulary loader is defined in the " { $vocab-link "vocabs.loader" } " vocabulary." "The vocabulary loader is defined in the " { $vocab-link "vocabs.loader" } " vocabulary."