Permalink
Browse files

NOTE: This will break any configuration files from JSIL 0.5 or earlier!

NOTE: The output location for content manifests has changed!
Overhaul how variable expansion works for paths in JSIL configuration:
  The complete set of expansion variables is contained in a single VariableSet that is used for all variable expansion.
  Failed variable expansion will produce an exception along with a list of currently valid variables.
  Attempt to propagate variable expansion changes the same way nested configuration changes are propagated (so variables either always expand to what they should in a particular context, or fail)
  Configurations can now include a 'CustomVariables' dictionary that defines custom string variables.
  Variable expansions now work for file settings.
Content manifests now get written to the content output directory instead of the assembly output directory.
  • Loading branch information...
1 parent 37af135 commit b5898d1102979e80ffcf35dccbcc806277c0f48e @kg kg committed Aug 18, 2012
View
@@ -8,6 +8,7 @@ namespace JSIL.Compiler {
public class BuildGroup {
public IProfile Profile;
public Configuration BaseConfiguration;
+ public VariableSet BaseVariables;
public string[] FilesToBuild;
}
}
View
@@ -85,6 +85,7 @@
<Compile Include="Program.cs" />
<Compile Include="SolutionBuilder.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="VariableSet.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\JSIL\JSIL.csproj">
View
@@ -38,6 +38,7 @@ public sealed class SolutionBuildConfiguration {
public string OutputDirectory;
public string Profile;
public Dictionary<string, object> ProfileSettings = new Dictionary<string, object>();
+ public Dictionary<string, string> CustomVariables = new Dictionary<string, string>();
public void MergeInto (Configuration result) {
base.MergeInto(result);
@@ -58,6 +59,9 @@ public sealed class SolutionBuildConfiguration {
foreach (var kvp in ProfileSettings)
result.ProfileSettings[kvp.Key] = kvp.Value;
+ foreach (var kvp in CustomVariables)
+ result.CustomVariables[kvp.Key] = kvp.Value;
+
SolutionBuilder.MergeInto(result.SolutionBuilder);
}
@@ -66,5 +70,26 @@ public sealed class SolutionBuildConfiguration {
MergeInto(result);
return result;
}
+
+ private Func<string> BindCustomVariable (string key) {
+ return () => this.CustomVariables[key];
+ }
+
+ public VariableSet ApplyTo (VariableSet variables) {
+ var result = variables.Clone();
+
+ foreach (var kvp in CustomVariables)
+ result[kvp.Key] = BindCustomVariable(kvp.Key);
+
+ result["ConfigDirectory"] = () => Path;
+ result["OutputDirectory"] = () => OutputDirectory;
+ result["Profile"] = () => Profile;
+
+ result["Configuration"] = () => SolutionBuilder.Configuration;
+ result["Platform"] = () => SolutionBuilder.Platform;
+ result["Target"] = () => SolutionBuilder.Target;
+
+ return result;
+ }
}
}
@@ -7,9 +7,18 @@ namespace JSIL.Compiler.Extensibility {
public interface IProfile {
bool IsAppropriateForSolution (SolutionBuilder.SolutionBuildResult buildResult);
- SolutionBuilder.SolutionBuildResult ProcessBuildResult (Configuration configuration, SolutionBuilder.SolutionBuildResult buildResult);
- Configuration GetConfiguration (Configuration defaultConfiguration);
- TranslationResult Translate (AssemblyTranslator translator, Configuration configuration, string assemblyPath, bool scanForProxies);
- void WriteOutputs (TranslationResult result, string path, string manifestPrefix);
+ SolutionBuilder.SolutionBuildResult ProcessBuildResult (
+ VariableSet variables, Configuration configuration, SolutionBuilder.SolutionBuildResult buildResult
+ );
+ Configuration GetConfiguration (
+ Configuration defaultConfiguration
+ );
+ TranslationResult Translate (
+ VariableSet variables, AssemblyTranslator translator,
+ Configuration configuration, string assemblyPath, bool scanForProxies
+ );
+ void WriteOutputs (
+ VariableSet variables, TranslationResult result, string path, string manifestPrefix
+ );
}
}
@@ -13,15 +13,15 @@ public abstract class BaseProfile : IProfile {
return defaultConfiguration;
}
- public virtual TranslationResult Translate (AssemblyTranslator translator, Configuration configuration, string assemblyPath, bool scanForProxies) {
+ public virtual TranslationResult Translate (VariableSet variables, AssemblyTranslator translator, Configuration configuration, string assemblyPath, bool scanForProxies) {
var result = translator.Translate(assemblyPath, scanForProxies);
AssemblyTranslator.GenerateManifest(translator.Manifest, assemblyPath, result);
return result;
}
- public virtual void WriteOutputs (TranslationResult result, string path, string manifestPrefix) {
+ public virtual void WriteOutputs (VariableSet variables, TranslationResult result, string path, string manifestPrefix) {
Console.WriteLine(manifestPrefix + "manifest.js");
foreach (var fe in result.OrderedFiles)
@@ -30,7 +30,7 @@ public abstract class BaseProfile : IProfile {
result.WriteToDirectory(path, manifestPrefix);
}
- public virtual SolutionBuilder.SolutionBuildResult ProcessBuildResult (Configuration configuration, SolutionBuilder.SolutionBuildResult buildResult) {
+ public virtual SolutionBuilder.SolutionBuildResult ProcessBuildResult (VariableSet variables, Configuration configuration, SolutionBuilder.SolutionBuildResult buildResult) {
return buildResult;
}
}
@@ -16,7 +16,9 @@ public class XNA3 : BaseProfile {
);
}
- public override TranslationResult Translate (AssemblyTranslator translator, Configuration configuration, string assemblyPath, bool scanForProxies) {
+ public override TranslationResult Translate (
+ VariableSet variables, AssemblyTranslator translator, Configuration configuration, string assemblyPath, bool scanForProxies
+ ) {
var result = translator.Translate(assemblyPath, scanForProxies);
ResourceConverter.ConvertEmbeddedResources(configuration, assemblyPath, result);
@@ -36,15 +38,15 @@ public class XNA3 : BaseProfile {
result.FrameworkVersion = 3.5;
result.Assemblies.Proxies.Add("JSIL.Proxies.XNA3.dll");
- Common.InitConfiguration(result);
-
return result;
}
- public override SolutionBuilder.SolutionBuildResult ProcessBuildResult (Configuration configuration, SolutionBuilder.SolutionBuildResult buildResult) {
- Common.ProcessContentProjects(configuration, buildResult, ContentProjectsProcessed);
+ public override SolutionBuilder.SolutionBuildResult ProcessBuildResult (
+ VariableSet variables, Configuration configuration, SolutionBuilder.SolutionBuildResult buildResult
+ ) {
+ Common.ProcessContentProjects(variables, configuration, buildResult, ContentProjectsProcessed);
- return base.ProcessBuildResult(configuration, buildResult);
+ return base.ProcessBuildResult(variables, configuration, buildResult);
}
}
}
@@ -27,12 +27,12 @@ public class XNA4 : BaseProfile {
result.FrameworkVersion = 4.0;
result.Assemblies.Proxies.Add("JSIL.Proxies.XNA4.dll");
- Common.InitConfiguration(result);
-
return result;
}
- public override TranslationResult Translate (AssemblyTranslator translator, Configuration configuration, string assemblyPath, bool scanForProxies) {
+ public override TranslationResult Translate (
+ VariableSet variables, AssemblyTranslator translator, Configuration configuration, string assemblyPath, bool scanForProxies
+ ) {
var result = translator.Translate(assemblyPath, scanForProxies);
ResourceConverter.ConvertEmbeddedResources(configuration, assemblyPath, result);
@@ -46,10 +46,12 @@ public class XNA4 : BaseProfile {
return result;
}
- public override SolutionBuilder.SolutionBuildResult ProcessBuildResult (Configuration configuration, SolutionBuilder.SolutionBuildResult buildResult) {
- Common.ProcessContentProjects(configuration, buildResult, ContentProjectsProcessed);
+ public override SolutionBuilder.SolutionBuildResult ProcessBuildResult (
+ VariableSet variables, Configuration configuration, SolutionBuilder.SolutionBuildResult buildResult
+ ) {
+ Common.ProcessContentProjects(variables, configuration, buildResult, ContentProjectsProcessed);
- return base.ProcessBuildResult(configuration, buildResult);
+ return base.ProcessBuildResult(variables, configuration, buildResult);
}
}
}
Oops, something went wrong.

0 comments on commit b5898d1

Please sign in to comment.