Changeset 3473

Show
Ignore:
Timestamp:
03/01/10 07:22:28 (5 months ago)
Author:
trichards
Message:

Added fixup for Eclipse in zpkg.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Setup/trunk/Package/zpkg.lua

    r3464 r3473  
    474474end 
    475475 
     476local function fixEclipseHandler() 
     477function generateBuildHandler(startArg) 
     478    -- First arg is build directory, second arg is source directory 
     479 
     480        local argsUsed = 2; 
     481    local buildDirectory = ""; 
     482    local sourceDirectory = ""; 
     483 
     484    -- Get buildDirectory from the first argument 
     485    if arg[startArg + 1] ~= nil then 
     486        buildDirectory =  arg[startArg + 1]; 
     487    else 
     488        print("Usage: zpkg build fix <buildDir> <sourceDir>"); 
     489        return argsUsed; 
     490    end 
     491     
     492    -- Get sourceDirectory from the second argument 
     493    if arg[startArg + 2] ~= nil then 
     494        sourceDirectory =  arg[startArg + 2]; 
     495    else 
     496        print("Usage: zpkg build fix <buildDir> <sourceDir>"); 
     497        return argsUsed; 
     498    end 
     499 
     500        local inputProject = buildDirectory .. "/.project"; 
     501    local inputCProject = buildDirectory .. "/.cproject"; 
     502 
     503        local outputProject = sourceDirectory .. "/project"; 
     504        local outputCProject = sourceDirectory .. "/cproject"; 
     505         
     506    -- Load the .project file 
     507        local template = loadTemplate(inputProject) 
     508 
     509        if (template == nil) then 
     510                print("Error finding " .. inputProject) 
     511                return argsUsed; 
     512        end 
     513         
     514        local result = string.gsub(template, buildDirectory .. "</name>", sourceDirectory .. "</name>"); 
     515 
     516        local file = io.open(outputProject, "w") 
     517        file:write(result) 
     518        file:close() 
     519 
     520    -- Load the .cproject file 
     521    template = loadTemplate(inputCProject); 
     522        if (template == nil) then 
     523                print("Error finding " .. inputCProject) 
     524                return argsUsed; 
     525        end 
     526 
     527    return argsUsed; 
     528end 
    476529 
    477530buildHandlers = 
    478531{ 
    479532        ["generate"] = { func = generateBuildHandler, help = "Generate configuration files" } 
     533    ["fix"] = { func = fixEclipseHandler, help = "Fix Eclipse build files to work with version control" }  
    480534} 
    481535