Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 17, 2008, 8:59:48 PM (16 years ago)
Author:
rgrieder
Message:

Merged revisions 1875-2278 of the buildsystem branch to buildsystem2.

Location:
code/branches/buildsystem2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/buildsystem2

  • code/branches/buildsystem2/src/tolua/lua/doit.lua

    r2087 r2509  
    1414function parse_extra()
    1515
    16         for k,v in ipairs(_extra_parameters or {}) do
    17                
    18                 local b,e,name,value = string.find(v, "^([^=])=(.*)$")
    19                 if b then
    20                         _extra_parameters[name] = value
    21                 else
    22                         _extra_parameters[v] = true
    23                 end
    24         end
     16    for k,v in ipairs(_extra_parameters or {}) do
     17       
     18        local b,e,name,value = string.find(v, "^([^=])=(.*)$")
     19        if b then
     20            _extra_parameters[name] = value
     21        else
     22            _extra_parameters[v] = true
     23        end
     24    end
    2525end
    2626
    2727function doit ()
    28         -- define package name, if not provided
    29         if not flags.n then
    30                 if flags.f then
    31                         flags.n = gsub(flags.f,"%..*$","")
    32                         _,_,flags.n = string.find(flags.n, "([^/\\]*)$")
    33                 else
    34                         error("#no package name nor input file provided")
    35                 end
    36         end
     28    -- define package name, if not provided
     29    if not flags.n then
     30        if flags.f then
     31            flags.n = gsub(flags.f,"%..*$","")
     32            _,_,flags.n = string.find(flags.n, "([^/\\]*)$")
     33        else
     34            error("#no package name nor input file provided")
     35        end
     36    end
    3737
    38         -- parse table with extra paramters
    39         parse_extra()
     38    -- parse table with extra paramters
     39    parse_extra()
    4040
    41         -- do this after setting the package name
    42         if flags['L'] then
    43                 dofile(flags['L'])
    44         end
     41    -- get potential working directory
     42    if not flags.w then
     43        flags.w = ''
     44    end
    4545
    46         -- add cppstring
    47         if not flags['S'] then
    48                 _basic['string'] = 'cppstring'
    49                 _basic['std::string'] = 'cppstring'
    50                 _basic_ctype.cppstring = 'const char*'
    51         end
     46    -- do this after setting the package name
     47    if flags.L then
     48        if string.sub(flags.L, 1, 1) == '/' or string.sub(flags.L, 1, 1) == '\\' then
     49            dofile(flags.L)
     50        else
     51            dofile(flags.w..'/'..flags.L)
     52        end
     53    end
    5254
    53         -- proccess package
    54         local p  = Package(flags.n,flags.f)
     55    -- add cppstring
     56    if not flags.S then
     57        _basic['string'] = 'cppstring'
     58        _basic['std::string'] = 'cppstring'
     59        _basic_ctype.cppstring = 'const char*'
     60    end
    5561
    56         if flags.p then
    57                 return        -- only parse
    58         end
     62    -- proccess package
     63    local file
     64    if flags.f then
     65        if string.sub(flags.f, 1, 1) == '/' or string.sub(flags.f, 1, 1) == '\\' then
     66            file = flags.f
     67        else
     68            file = flags.w..'/'..flags.f
     69        end
     70    else
     71        file = flags.f
     72    end
     73    local p  = Package(flags.n, file)
    5974
    60         if flags.o then
    61                 local st,msg = writeto(flags.o)
    62                 if not st then
    63                         error('#'..msg)
    64                 end
    65         end
     75    if flags.p then
     76        return        -- only parse
     77    end
    6678
    67         p:decltype()
    68         if flags.P then
    69                 p:print()
    70         else
    71                 p:preamble()
    72                 p:supcode()
    73                 p:register()
    74                 push(p)
    75                 post_output_hook(p)
    76                 pop()
    77         end
     79    if flags.o then
     80        local file
     81        if string.sub(flags.o, 1, 1) == '/' or string.sub(flags.o, 1, 1) == '\\' then
     82            file = flags.o
     83        else
     84            file = flags.w..'/'..flags.o
     85        end
     86        local st,msg = writeto(file)
     87        if not st then
     88            error('#'..msg)
     89        end
     90    end
    7891
    79         if flags.o then
    80                 writeto()
    81         end
     92    p:decltype()
     93    if flags.P then
     94        p:print()
     95    else
     96        p:preamble()
     97        p:supcode()
     98        p:register()
     99        push(p)
     100        post_output_hook(p)
     101        pop()
     102    end
    82103
    83         -- write header file
    84         if not flags.P then
    85                 if flags.H then
    86                         local st,msg = writeto(flags.H)
    87                         if not st then
    88                                 error('#'..msg)
    89                         end
    90                         p:header()
    91                         writeto()
    92                 end
    93         end
     104    if flags.o then
     105        writeto()
     106    end
     107
     108    -- write header file
     109    if not flags.P then
     110        if flags.H then
     111            local file
     112            if string.sub(flags.H, 1, 1) == '/' or string.sub(flags.H, 1, 1) == '\\' then
     113                file = flags.H
     114            else
     115                file = flags.w..'/'..flags.H
     116            end
     117            local st,msg = writeto(file)
     118            if not st then
     119                error('#'..msg)
     120            end
     121            p:header()
     122            writeto()
     123        end
     124    end
    94125end
    95126
Note: See TracChangeset for help on using the changeset viewer.