Skip to content

Commit

Permalink
make rewrite-wp8-references.boo into a proper project and publish it …
Browse files Browse the repository at this point in the history
…as RetargetAssembly so it can be used by unityscript
  • Loading branch information
bamboo committed Dec 3, 2012
1 parent 8d1db66 commit c93ead2
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 22 deletions.
25 changes: 11 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -142,24 +142,21 @@ subprojects {
}

dependencies {
subprojects.each {
subprojects.findAll { it.projectDir.parentFile.name == 'src' }.each {
'default' project(it.path)
}
}

task rewriteWindowsPhone8AssemblyReferences(type: Exec) {
def wp8BooLangTask = project(':Boo.Lang').tasks.compileWindowsPhone8
def compileBooi = project(':booi').tasks.compileDefault
dependsOn compileBooi
dependsOn wp8BooLangTask
inputs.source compileBooi.assemblyFile
inputs.source file('scripts/rewrite-wp8-references.boo')
inputs.source wp8BooLangTask.assemblyFile
executable rootProject.extensions.unity.monoBleedingEdge.cli
args inputs.files
}
project(':Boo.Lang') {
tasks.assembleWindowsPhone8 {
dependsOn rewriteWindowsPhone8AssemblyReferences
def retargetAssemblyTask = project(':RetargetAssembly').tasks.compileDefault
tasks.compileWindowsPhone8 {
dependsOn retargetAssemblyTask
doLast {
project.exec {
executable rootProject.extensions.unity.monoBleedingEdge.cli
args retargetAssemblyTask.assemblyFile
args assemblyFile
}
}
}
}
22 changes: 16 additions & 6 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
def includeFromDir(String dir, String name) {
include name
project(":$name").projectDir = new File(dir, name)
}

def includeSrcProject(String name) {
includeFromDir 'src', name
}

def includeToolProject(String name) {
includeFromDir 'tools', name
}

def srcProjects = [
'Boo.Lang',
Expand All @@ -12,11 +24,9 @@ def srcProjects = [
'booi',
'booish',
]
srcProjects.each { include it }

def srcDir = file('src')
rootProject.children.each {
it.projectDir = new File(srcDir, it.name)
it.buildFileName = "${it.name}.gradle"
srcProjects.each {
includeSrcProject it
}

includeToolProject 'RetargetAssembly'

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# rewrites all assembly references to match wp8 assemblies:
# rewrites all system assembly references to match wp8 assemblies:
# Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
# and change the assembly runtime to net-4.0

Expand All @@ -18,11 +18,18 @@ class AssemblyReferenceRewriter:
def RewriteReferencesOf(assembly as string):
m = ModuleDefinition.ReadModule(assembly)
m.Runtime = _runtime
for assemblyRef in m.AssemblyReferences:
for assemblyRef in RetargetableAssemblyReferencesOf(m):
assemblyRef.Version = _version
assemblyRef.PublicKeyToken = _publicKeyToken
m.Write(assembly, WriterParameters(StrongNameKeyPair: _strongNameKeyPair))

def RetargetableAssemblyReferencesOf(m as ModuleDefinition):
return (asmRef for asmRef in m.AssemblyReferences if IsRetargetable(asmRef))

def IsRetargetable(asmRef as AssemblyNameReference):
name = asmRef.Name
return name.StartsWith('System') or name == 'mscorlib'

def ParsePublicKeyToken(token as string):
return array(ParseHexByte(token[i:i+2]) for i in range(0, len(token), 2))

Expand Down
13 changes: 13 additions & 0 deletions tools/RetargetAssembly/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version = '0.1.0'

assembly {
target = 'exe'
}

dependencies {
'default' project(':Boo.Lang')
}

tasks.compileDefault {
dependsOn project(':booc').tasks.compileDefault
}

0 comments on commit c93ead2

Please sign in to comment.