public IEnumerable<Exception> Parse(PropertySheet propSheet, string password)
        {
            //macrotize for #declares

            var macrotizer = new PropertySheetMacrotizer(propSheet);
            propSheet = macrotizer.ReplaceDeclareMacros();

            var possibleFirstBinRule = propSheet["assembly"].FirstOrDefault();

            //get arch and version
            var exceptions = SetVersionAndArch(possibleFirstBinRule, propSheet.Rule("package").Prop("version"), propSheet.Rule("package").Prop("arch"));

            exceptions = exceptions.Concat(SetName(propSheet.Rule("package").Prop("name")));
            if (exceptions.Any())
            {
                foreach (var e in exceptions) {
                    yield return e;
                }
                yield break;
            }

            //replace the last macros
            propSheet = macrotizer.ExpandAMacro("CURRENT", _package.PackageVersion);
            propSheet = macrotizer.ExpandAMacro("ARCH", _package.PackageArch);
            propSheet = macrotizer.ExpandAMacro("NAME", _package.PackageName);
            propSheet = macrotizer.ExpandAMacro("OUTPUT", _package.DefaultOutputFile);

            exceptions = exceptions.Concat(ParsePackageRule(propSheet.Rule("package")))
                        .Concat(ParseIdentityRule(propSheet.Rule("identity"), password));

            ParseDependenciesRule(propSheet.Rule("dependencies"));
            ParseSharedLibRule(propSheet.Rule("sharedlib"));
            ParseAssemblyRules(propSheet["assembly"]);
            //ParseAppRule(propSheet.Rule("app"));
            //ParseExeFileRules(propSheet["exe-file"]);
            ParseContributorRules(propSheet["contributor"]);

            ParseHeadersRule(propSheet.Rule("headers"));
            ParseImportLibsRule(propSheet.Rule("importlibs"));
            ParseStaticLibsRule(propSheet.Rule("staticlibs"));

            ParseAssemblyRules(propSheet["assembly"]);
        }
Exemplo n.º 2
0
 public static PropertySheet Parse(string propertySheetText, string originalFilename, PropertySheet propertySheet = null )
 {
     var p = new PropertySheetParser(propertySheetText,originalFilename,propertySheet ?? new PropertySheet());
     return p.Parse();
 }
Exemplo n.º 3
0
 protected PropertySheetParser(string text, string originalFilename,PropertySheet propertySheet)
 {
     _propertySheetText = text;
     _propertySheet = propertySheet;
     _filename = originalFilename;
 }
Exemplo n.º 4
0
        private void CreateBinary(TestTarget binary, string binaryTemplate, string extension, string arch, string commandLine, List<string> autopkgFiles)
        {
            var outputPath = Path.Combine(this.tempFolder, arch);
            if (binary.Built)
                return;

            foreach (var dep in binary.Dependencies)
            {
                CreateDLL(dep, arch, autopkgFiles);
            }

            if (binary.Ignore)
                return;

            //Console.WriteLine("Building Binary [{0}-{1}]", binary.Name, binary.Version);

            var importLibrary = new StringBuilder();
            var callLibrary = new StringBuilder();

            foreach (var dll in binary.Dependencies)
            {
                importLibrary.Append(Resources.LibraryReferenceTemplate.Replace("[$LIBNAME]", dll.Name).Replace("[$LIBVERSION]", dll.Version).Replace("[$PUBLICKEYTOKEN]", publicKeyToken).Replace("[$ARCH]", arch));
                callLibrary.Append(Resources.LibraryFunctionCallTemplate.Replace("[$LIBNAME]", dll.Name).Replace("[$LIBVERSION]", dll.Version).Replace("[$PUBLICKEYTOKEN]", publicKeyToken).Replace("[$ARCH]", arch));
            }

            var tempFolder = Path.Combine(Path.GetTempPath(), binary.Name + "-" + binary.Version);
            Directory.CreateDirectory(tempFolder);
            var outputBinaryFolder = Path.Combine(outputPath, binary.Name + "-" + binary.Version);
            Directory.CreateDirectory(outputBinaryFolder);
            Environment.CurrentDirectory = outputBinaryFolder;

            foreach (var dll in binary.Dependencies)
            {
                var defFile = Resources.ModuleDefinitionFileTemplate + "print_" + dll.Name;
                File.WriteAllText(Path.Combine(tempFolder, dll.Name + ".def"), defFile);

                if (lib.Exec("/out:{0} /def:{1} /machine:{2}", Path.Combine(tempFolder, dll.Name + ".lib"), Path.Combine(tempFolder, dll.Name + ".def"), arch == "x86" ? arch : "x64") != 0)
                    throw new Exception(lib.StandardOut);

                commandLine = @"{0} /link ""{1}""".format(commandLine, Path.Combine(tempFolder, dll.Name + ".lib"));
            }

            // make C file
            var binaryText = binaryTemplate.Replace("[$LIBNAME]", binary.Name).Replace("[$LIBVERSION]", binary.Version).Replace("[$IMPORT_LIBRARY]", importLibrary.ToString()).Replace("[$CALL_LIBRARY]", callLibrary.ToString()).Replace("[$PUBLICKEYTOKEN]", publicKeyToken).Replace("[$ARCH]", arch);
            var tempCFile = Path.Combine(tempFolder, binary.Name + ".c");
            File.WriteAllText(tempCFile, binaryText);

            // compile it
            var outputBinary = Path.Combine(outputBinaryFolder, binary.Name + extension);
            if (cl.Exec(commandLine, tempCFile, outputBinary) != 0)
                throw new Exception(cl.StandardOut);

            binary.Built = true;

            //TODO create the autopkg file

            var propSheet = new PropertySheet();
            //propSheet.Keys
        }
 /// <summary>
 /// Constructor for <see cref="PropertySheetMacrotizer"/>
 /// </summary>
 /// <param name="ps">the <see cref="PropertySheet"/> for which you'd like to have macros replaced in.</param>
 public PropertySheetMacrotizer(PropertySheet ps)
 {
     _ps = ps;
 }