Skip to content

Commit 47a7bc2

Browse files
committed
Initial Commit
1 parent 2094752 commit 47a7bc2

File tree

18 files changed

+1248
-0
lines changed

18 files changed

+1248
-0
lines changed

.gitignore

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
## Ignore Visual Studio temporary files, build results, and
2+
## files generated by popular Visual Studio add-ons.
3+
4+
# User-specific files
5+
*.suo
6+
*.user
7+
*.userosscache
8+
*.sln.docstates
9+
10+
# User-specific files (MonoDevelop/Xamarin Studio)
11+
*.userprefs
12+
13+
# Build results
14+
[Dd]ebug/
15+
[Dd]ebugPublic/
16+
[Rr]elease/
17+
[Rr]eleases/
18+
x64/
19+
x86/
20+
bld/
21+
[Bb]in/
22+
[Oo]bj/
23+
24+
# Visual Studio 2015 cache/options directory
25+
.vs/
26+
27+
# MSTest test Results
28+
[Tt]est[Rr]esult*/
29+
[Bb]uild[Ll]og.*
30+
31+
# NUNIT
32+
*.VisualState.xml
33+
TestResult.xml
34+
35+
# Build Results of an ATL Project
36+
[Dd]ebugPS/
37+
[Rr]eleasePS/
38+
dlldata.c
39+
40+
# DNX
41+
project.lock.json
42+
artifacts/
43+
44+
*_i.c
45+
*_p.c
46+
*_i.h
47+
*.ilk
48+
*.obj
49+
*.pch
50+
*.pdb
51+
*.pgc
52+
*.pgd
53+
*.rsp
54+
*.sbr
55+
*.tlb
56+
*.tli
57+
*.tlh
58+
*.tmp
59+
*.tmp_proj
60+
*.log
61+
*.vspscc
62+
*.vssscc
63+
.builds
64+
*.pidb
65+
*.svclog
66+
*.scc
67+
68+
# Chutzpah Test files
69+
_Chutzpah*
70+
71+
# Visual C++ cache files
72+
ipch/
73+
*.aps
74+
*.ncb
75+
*.opensdf
76+
*.sdf
77+
*.cachefile
78+
79+
# Visual Studio profiler
80+
*.psess
81+
*.vsp
82+
*.vspx
83+
84+
# TFS 2012 Local Workspace
85+
$tf/
86+
87+
# Guidance Automation Toolkit
88+
*.gpState
89+
90+
# ReSharper is a .NET coding add-in
91+
_ReSharper*/
92+
*.[Rr]e[Ss]harper
93+
*.DotSettings.user
94+
95+
# JustCode is a .NET coding add-in
96+
.JustCode
97+
98+
# TeamCity is a build add-in
99+
_TeamCity*
100+
101+
# DotCover is a Code Coverage Tool
102+
*.dotCover
103+
104+
# NCrunch
105+
_NCrunch_*
106+
.*crunch*.local.xml
107+
108+
# MightyMoose
109+
*.mm.*
110+
AutoTest.Net/
111+
112+
# Web workbench (sass)
113+
.sass-cache/
114+
115+
# Installshield output folder
116+
[Ee]xpress/
117+
118+
# DocProject is a documentation generator add-in
119+
DocProject/buildhelp/
120+
DocProject/Help/*.HxT
121+
DocProject/Help/*.HxC
122+
DocProject/Help/*.hhc
123+
DocProject/Help/*.hhk
124+
DocProject/Help/*.hhp
125+
DocProject/Help/Html2
126+
DocProject/Help/html
127+
128+
# Click-Once directory
129+
publish/
130+
131+
# Publish Web Output
132+
*.[Pp]ublish.xml
133+
*.azurePubxml
134+
## TODO: Comment the next line if you want to checkin your
135+
## web deploy settings but do note that will include unencrypted
136+
## passwords
137+
#*.pubxml
138+
139+
*.publishproj
140+
141+
# NuGet Packages
142+
*.nupkg
143+
# The packages folder can be ignored because of Package Restore
144+
**/packages/*
145+
# except build/, which is used as an MSBuild target.
146+
!**/packages/build/
147+
# Uncomment if necessary however generally it will be regenerated when needed
148+
#!**/packages/repositories.config
149+
150+
# Windows Azure Build Output
151+
csx/
152+
*.build.csdef
153+
154+
# Windows Store app package directory
155+
AppPackages/
156+
157+
# Visual Studio cache files
158+
# files ending in .cache can be ignored
159+
*.[Cc]ache
160+
# but keep track of directories ending in .cache
161+
!*.[Cc]ache/
162+
163+
# Others
164+
ClientBin/
165+
[Ss]tyle[Cc]op.*
166+
~$*
167+
*~
168+
*.dbmdl
169+
*.dbproj.schemaview
170+
*.pfx
171+
*.publishsettings
172+
node_modules/
173+
orleans.codegen.cs
174+
.fake/
175+
176+
# RIA/Silverlight projects
177+
Generated_Code/
178+
179+
# Backup & report files from converting an old project file
180+
# to a newer Visual Studio version. Backup files are not needed,
181+
# because we have git ;-)
182+
_UpgradeReport_Files/
183+
Backup*/
184+
UpgradeLog*.XML
185+
UpgradeLog*.htm
186+
187+
# SQL Server files
188+
*.mdf
189+
*.ldf
190+
191+
# Business Intelligence projects
192+
*.rdl.data
193+
*.bim.layout
194+
*.bim_*.settings
195+
196+
# Microsoft Fakes
197+
FakesAssemblies/
198+
199+
# Node.js Tools for Visual Studio
200+
.ntvs_analysis.dat
201+
202+
# Visual Studio 6 build log
203+
*.plg
204+
205+
# Visual Studio 6 workspace options file
206+
*.opt
207+
208+
# LightSwitch generated files
209+
GeneratedArtifacts/
210+
_Pvt_Extensions/
211+
ModelManifest.xml
212+
samples/Basic/Compiler/compilation log.txt

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,47 @@
11
# Unity3D.UselessAttributeStripper
2+
23
Useless attribute stripper for IL2CPPed executable. It will help for reducing app size for iOS.
4+
5+
### Setup
6+
7+
Unzip [a release zip file](https://github.com/SaladbowlCreative/Unity3D.UselessAttributeStripper/releases) and run setup.py.
8+
- Run setup.py with administrative privilege because it may update your application directory.
9+
- If you didn't install Unity3D to default directory, you need to check your unity3d installation path.
10+
11+
if you installed unity to default path:
12+
```
13+
setup.py install
14+
```
15+
16+
if you didn't install unity to default path:
17+
```
18+
setup.py install [unity-path]
19+
```
20+
21+
### Check what's going on
22+
23+
While unity3D builds application, it will write log on intermediate path.
24+
For iOS with Unity5 & IL2CPP you can find log-file at
25+
`./Client/Output/Data/Managed/UselessAttributeStripper.txt`. (you can see [sample log](./docs/SampleLog.txt))
26+
27+
With log, you can know which attributes were removed from DLLs and the amount of removal.
28+
```
29+
- ProcessDll : /builder/GameClient/Temp/StagingArea/Data/Managed/mscorlib.dll
30+
- System.Runtime.InteropServices.ComVisibleAttribute : 1311
31+
- System.MonoTODOAttribute : 461
32+
- System.CLSCompliantAttribute : 374
33+
- (trimmed)
34+
```
35+
At the end of log, total removal infomation will be written.
36+
```
37+
* Summary *
38+
- System.Runtime.CompilerServices.CompilerGeneratedAttribute : 5566
39+
- System.Diagnostics.DebuggerHiddenAttribute : 4641
40+
- System.Runtime.InteropServices.ComVisibleAttribute : 1380
41+
- System.Runtime.CompilerServices.ExtensionAttribute : 797
42+
- (trimmed)
43+
```
44+
45+
### More
46+
47+
[Sample Case](./docs/SampleCase.md)

UselessAttributeStripper.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.24720.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UselessAttributeStripper", "src\UselessAttributeStripper\UselessAttributeStripper.csproj", "{2A067BAE-8AE3-4D28-B3D8-F88075E06549}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{2A067BAE-8AE3-4D28-B3D8-F88075E06549}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{2A067BAE-8AE3-4D28-B3D8-F88075E06549}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{2A067BAE-8AE3-4D28-B3D8-F88075E06549}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{2A067BAE-8AE3-4D28-B3D8-F88075E06549}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal

build.cmd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@echo off
2+
3+
pushd %~dp0
4+
5+
tools\nuget\NuGet.exe update -self
6+
tools\nuget\NuGet.exe install FAKE -ConfigFile tools\nuget\Nuget.Config -OutputDirectory packages -ExcludeVersion -Version 4.12
7+
8+
set encoding=utf-8
9+
packages\FAKE\tools\FAKE.exe build.fsx %*
10+
11+
popd

build.fsx

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#I @"packages/FAKE/tools"
2+
#r "FakeLib.dll"
3+
4+
open Fake
5+
open Fake.FileHelper
6+
open Fake.ProcessHelper
7+
open Fake.ZipHelper
8+
9+
// ------------------------------------------------------------------------------ Project
10+
11+
let buildSolutionFile = "./UselessAttributeStripper.sln"
12+
let buildConfiguration = "Release"
13+
14+
// ---------------------------------------------------------------------------- Variables
15+
16+
let binDir = "bin"
17+
let testDir = binDir @@ "test"
18+
19+
// ------------------------------------------------------------------------------ Targets
20+
21+
Target "Clean" (fun _ ->
22+
CleanDirs [binDir]
23+
)
24+
25+
Target "Build" (fun _ ->
26+
!! buildSolutionFile
27+
|> MSBuild "" "Rebuild" [ "Configuration", buildConfiguration ]
28+
|> Log "Build-Output: "
29+
)
30+
31+
Target "Package" (fun _ ->
32+
let workDir = binDir @@ "work"
33+
CreateDir workDir
34+
"./src/UselessAttributeStripper/bin/Release/UselessAttributeStripper.exe" |> CopyFile workDir
35+
"./src/InstallScript/setup.py" |> CopyFile workDir
36+
!! (workDir @@ "**") |> Zip workDir (binDir @@ "UselessAttributeStripper.zip")
37+
)
38+
39+
Target "Help" (fun _ ->
40+
List.iter printfn [
41+
"usage:"
42+
"build [target]"
43+
""
44+
" Targets for building:"
45+
" * Build Build"
46+
" * Package Make packages"
47+
""]
48+
)
49+
50+
// --------------------------------------------------------------------------- Dependency
51+
52+
// Build order
53+
"Clean"
54+
==> "Build"
55+
==> "Package"
56+
57+
RunTargetOrDefault "Help"

docs/SampleCase.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Sample Case
2+
3+
### Environment
4+
5+
- Target: iOS / IL2CPP
6+
- Unity 5.3.1f1 (OSX)
7+
- OSX Yosemite 10.10.5 / XCode 7.2
8+
9+
### Result executable size (original)
10+
11+
Size of executable: 151,795,952 bytes
12+
```
13+
> size exe
14+
__TEXT __DATA __OBJC others dec hex
15+
26656768 2473984 0 43909120 73039872 45a8000 exe (for architecture armv7)
16+
30523392 3735552 0 4341760000 4376018944 104d4c000 exe (for architecture arm64)
17+
```
18+
19+
### Result executable size (attribute stripped)
20+
21+
Size of executable: 132,189,648 bytes
22+
```
23+
> size exe_stripped
24+
__TEXT __DATA __OBJC others dec hex
25+
25526272 2408448 0 35684352 63619072 3cac000 exe_stripped (for architecture armv7)
26+
28966912 3637248 0 4333207552 4365811712 104390000 exe_stripped (for architecture arm64)
27+
```
28+
29+
### Compare
30+
31+
| Project | Original | Stripped | Delta |
32+
| :------------- | ----------: | ----------: | ----------: |
33+
| __TEXT (armv7) | 26,656,768 | 25,526,272 | -1,130,496 |
34+
| __TEXT (arm64) | 30,523,392 | 28,966,912 | -1,556,480 |
35+
| __DATA (armv7) | 2,473,984 | 2,408,448 | -65,536 |
36+
| __DATA (arm64) | 3,735,552 | 3,637,248 | -98,304 |
37+
| others (armv7) | 43,909,120 | 35,684,352 | -8,224,768 |
38+
| others (arm64) | - | - | - |
39+
| Total | 151,795,952 | 132,189,648 | -19,606,304 |

0 commit comments

Comments
 (0)