diff options
author | Wonyoung Choi <wy80.choi@samsung.com> | 2019-02-08 11:20:13 +0900 |
---|---|---|
committer | Wonyoung Choi <wy80.choi@samsung.com> | 2019-02-08 11:20:13 +0900 |
commit | 4eb83aed24e69abb2d2d61ce0bf99d72fce6fd4a (patch) | |
tree | 8189f57935c28d54d76839e351109ff0c8e6b34e /tools | |
parent | 389943bbc103cdee6ccb11659d51db6ae6d689ee (diff) | |
download | tizenfx-4eb83aed24e69abb2d2d61ce0bf99d72fce6fd4a.tar.gz tizenfx-4eb83aed24e69abb2d2d61ce0bf99d72fce6fd4a.tar.bz2 tizenfx-4eb83aed24e69abb2d2d61ce0bf99d72fce6fd4a.zip |
[Build] Add APITool
* APITool is a unified tool for printing API lists and generating dummy assemblies.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/Tools.sln | 15 | ||||
-rw-r--r-- | tools/bin/ABIChecker/ABIChecker.deps.json | 8 | ||||
-rw-r--r-- | tools/bin/APITool/APITool.deps.json | 500 | ||||
-rw-r--r-- | tools/bin/APITool/APITool.dll | bin | 0 -> 19456 bytes | |||
-rw-r--r-- | tools/bin/APITool/APITool.pdb | bin | 0 -> 4448 bytes | |||
-rw-r--r-- | tools/bin/APITool/APITool.runtimeconfig.json | 9 | ||||
-rwxr-xr-x | tools/bin/APITool/CommandLine.dll | bin | 0 -> 194048 bytes | |||
-rwxr-xr-x | tools/bin/APITool/Mono.Cecil.Mdb.dll | bin | 0 -> 39424 bytes | |||
-rwxr-xr-x | tools/bin/APITool/Mono.Cecil.Pdb.dll | bin | 0 -> 87552 bytes | |||
-rwxr-xr-x | tools/bin/APITool/Mono.Cecil.Rocks.dll | bin | 0 -> 25088 bytes | |||
-rwxr-xr-x | tools/bin/APITool/Mono.Cecil.dll | bin | 0 -> 335872 bytes | |||
-rwxr-xr-x | tools/build-tools.sh | 2 | ||||
-rw-r--r-- | tools/src/APITool/APIPrinter.cs | 142 | ||||
-rw-r--r-- | tools/src/APITool/APITool.csproj | 13 | ||||
-rw-r--r-- | tools/src/APITool/AssemblyProcessor.cs | 77 | ||||
-rw-r--r-- | tools/src/APITool/DummyGenerator.cs | 155 | ||||
-rw-r--r-- | tools/src/APITool/Log.cs | 53 | ||||
-rw-r--r-- | tools/src/APITool/Options.cs | 65 | ||||
-rw-r--r-- | tools/src/APITool/Program.cs | 131 |
19 files changed, 1165 insertions, 5 deletions
diff --git a/tools/Tools.sln b/tools/Tools.sln index f11a4ab8d..12d1def7d 100644 --- a/tools/Tools.sln +++ b/tools/Tools.sln @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ABIChecker", "src\ABIChecke EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GenDummy", "src\GenDummy\GenDummy.csproj", "{3184D14E-4619-4FE3-94EB-C3E254A5742E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "APITool", "src\APITool\APITool.csproj", "{C089609B-9760-4B66-A5FD-A81CFDD94152}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -46,9 +48,22 @@ Global {3184D14E-4619-4FE3-94EB-C3E254A5742E}.Release|x64.Build.0 = Release|Any CPU {3184D14E-4619-4FE3-94EB-C3E254A5742E}.Release|x86.ActiveCfg = Release|Any CPU {3184D14E-4619-4FE3-94EB-C3E254A5742E}.Release|x86.Build.0 = Release|Any CPU + {C089609B-9760-4B66-A5FD-A81CFDD94152}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C089609B-9760-4B66-A5FD-A81CFDD94152}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C089609B-9760-4B66-A5FD-A81CFDD94152}.Debug|x64.ActiveCfg = Debug|Any CPU + {C089609B-9760-4B66-A5FD-A81CFDD94152}.Debug|x64.Build.0 = Debug|Any CPU + {C089609B-9760-4B66-A5FD-A81CFDD94152}.Debug|x86.ActiveCfg = Debug|Any CPU + {C089609B-9760-4B66-A5FD-A81CFDD94152}.Debug|x86.Build.0 = Debug|Any CPU + {C089609B-9760-4B66-A5FD-A81CFDD94152}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C089609B-9760-4B66-A5FD-A81CFDD94152}.Release|Any CPU.Build.0 = Release|Any CPU + {C089609B-9760-4B66-A5FD-A81CFDD94152}.Release|x64.ActiveCfg = Release|Any CPU + {C089609B-9760-4B66-A5FD-A81CFDD94152}.Release|x64.Build.0 = Release|Any CPU + {C089609B-9760-4B66-A5FD-A81CFDD94152}.Release|x86.ActiveCfg = Release|Any CPU + {C089609B-9760-4B66-A5FD-A81CFDD94152}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {67CEC1C6-C732-41AA-B062-6544003555A0} = {AD3273CC-611A-4C16-B000-A377C6C99D71} {3184D14E-4619-4FE3-94EB-C3E254A5742E} = {AD3273CC-611A-4C16-B000-A377C6C99D71} + {C089609B-9760-4B66-A5FD-A81CFDD94152} = {AD3273CC-611A-4C16-B000-A377C6C99D71} EndGlobalSection EndGlobal diff --git a/tools/bin/ABIChecker/ABIChecker.deps.json b/tools/bin/ABIChecker/ABIChecker.deps.json index e0548df70..9239c4983 100644 --- a/tools/bin/ABIChecker/ABIChecker.deps.json +++ b/tools/bin/ABIChecker/ABIChecker.deps.json @@ -1463,7 +1463,7 @@ "System.Composition/1.0.31": { "type": "package", "serviceable": true, - "sha512": "sha512-I+D26qpYdoklyAVUdqwUBrEIckMNjAYnuPJy/h9dsQItpQwVREkDFs4b4tkBza0kT2Yk48Lcfsv2QQ9hWsh9Iw==", + "sha512": "sha512-CbzwbjxT04VU+JzQuPOYfUCybzBtbGZdqGJS9482dDBoBHbt3Zz0QAJ/Cjzpmq5xdL+hhW4FYWf/3wq2OCVXgg==", "path": "system.composition/1.0.31", "hashPath": "system.composition.1.0.31.nupkg.sha512" }, @@ -1484,7 +1484,7 @@ "System.Composition.Hosting/1.0.31": { "type": "package", "serviceable": true, - "sha512": "sha512-fN1bT4RX4vUqjbgoyuJFVUizAl2mYF5VAb+bVIxIYZSSc0BdnX+yGAxcavxJuDDCQ1K+/mdpgyEFc8e9ikjvrg==", + "sha512": "sha512-KlZ4qkaa1p/U2WKr353XeQ9bjrxBwn9FcD5k9WFEuV1MloDMnTnhUwQU7h1WigvsCYykzoRdnDLq33wnUPwBeg==", "path": "system.composition.hosting/1.0.31", "hashPath": "system.composition.hosting.1.0.31.nupkg.sha512" }, @@ -1512,7 +1512,7 @@ "System.Diagnostics.Contracts/4.3.0": { "type": "package", "serviceable": true, - "sha512": "sha512-eelRRbnm+OloiQvp9CXS0ixjNQldjjkHO4iIkR5XH2VIP8sUB/SIpa1TdUW6/+HDcQ+MlhP3pNa1u5SbzYuWGA==", + "sha512": "sha512-BQcxLgTgNS9a0Um9ASMIMumpmAmAMFXcQO/lMvNRsTg7tLY50Bp4fEJkg+uozATg8Sj2y9nDfpTeR2ImhIafaw==", "path": "system.diagnostics.contracts/4.3.0", "hashPath": "system.diagnostics.contracts.4.3.0.nupkg.sha512" }, @@ -1617,7 +1617,7 @@ "System.Linq.Parallel/4.3.0": { "type": "package", "serviceable": true, - "sha512": "sha512-td7x21K8LalpjTWCzW/nQboQIFbq9i0r+PCyBBCdLWWnm4NBcdN18vpz/G9hCpUaCIfRL+ZxJNVTywlNlB1aLQ==", + "sha512": "sha512-rvw62DwbrjHnE4aQUxCGGLeF3sfC5Pyv+O+1ZmfnFY3SLc31YwZo1dhjABihOVQUh4drpQ5wWQB8hVQbtGkxww==", "path": "system.linq.parallel/4.3.0", "hashPath": "system.linq.parallel.4.3.0.nupkg.sha512" }, diff --git a/tools/bin/APITool/APITool.deps.json b/tools/bin/APITool/APITool.deps.json new file mode 100644 index 000000000..383435faa --- /dev/null +++ b/tools/bin/APITool/APITool.deps.json @@ -0,0 +1,500 @@ +{ + "runtimeTarget": { + "name": ".NETCoreApp,Version=v2.0", + "signature": "98b6c300d0247854f64d634c3d42698728676f02" + }, + "compilationOptions": {}, + "targets": { + ".NETCoreApp,Version=v2.0": { + "APITool/1.0.0": { + "dependencies": { + "CommandLineParser": "2.4.3", + "Mono.Cecil": "0.10.1" + }, + "runtime": { + "APITool.dll": {} + } + }, + "CommandLineParser/2.4.3": { + "runtime": { + "lib/netstandard2.0/CommandLine.dll": { + "assemblyVersion": "2.4.3.0", + "fileVersion": "2.4.3.0" + } + } + }, + "Microsoft.NETCore.Targets/1.0.1": {}, + "Mono.Cecil/0.10.1": { + "dependencies": { + "System.Collections": "4.0.11", + "System.IO.FileSystem": "4.0.1", + "System.IO.FileSystem.Primitives": "4.0.1", + "System.Reflection": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Security.Cryptography.Algorithms": "4.2.0", + "System.Security.Cryptography.Csp": "4.0.0", + "System.Threading": "4.0.11" + }, + "runtime": { + "lib/netstandard1.3/Mono.Cecil.Mdb.dll": { + "assemblyVersion": "0.10.1.0", + "fileVersion": "0.10.1.0" + }, + "lib/netstandard1.3/Mono.Cecil.Pdb.dll": { + "assemblyVersion": "0.10.1.0", + "fileVersion": "0.10.1.0" + }, + "lib/netstandard1.3/Mono.Cecil.Rocks.dll": { + "assemblyVersion": "0.10.1.0", + "fileVersion": "0.10.1.0" + }, + "lib/netstandard1.3/Mono.Cecil.dll": { + "assemblyVersion": "0.10.1.0", + "fileVersion": "0.10.1.0" + } + } + }, + "runtime.native.System.Security.Cryptography/4.0.0": { + "dependencies": { + "Microsoft.NETCore.Targets": "1.0.1" + } + }, + "System.Collections/4.0.11": { + "dependencies": { + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0" + } + }, + "System.Collections.Concurrent/4.0.12": { + "dependencies": { + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Diagnostics.Tracing": "4.1.0", + "System.Globalization": "4.0.11", + "System.Reflection": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11" + } + }, + "System.Diagnostics.Debug/4.0.11": { + "dependencies": { + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0" + } + }, + "System.Diagnostics.Tracing/4.1.0": { + "dependencies": { + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0" + } + }, + "System.Globalization/4.0.11": { + "dependencies": { + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0" + } + }, + "System.IO/4.1.0": { + "dependencies": { + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0", + "System.Text.Encoding": "4.0.11", + "System.Threading.Tasks": "4.0.11" + } + }, + "System.IO.FileSystem/4.0.1": { + "dependencies": { + "Microsoft.NETCore.Targets": "1.0.1", + "System.IO": "4.1.0", + "System.IO.FileSystem.Primitives": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Text.Encoding": "4.0.11", + "System.Threading.Tasks": "4.0.11" + } + }, + "System.IO.FileSystem.Primitives/4.0.1": { + "dependencies": { + "System.Runtime": "4.1.0" + } + }, + "System.Linq/4.1.0": { + "dependencies": { + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0" + } + }, + "System.Reflection/4.1.0": { + "dependencies": { + "Microsoft.NETCore.Targets": "1.0.1", + "System.IO": "4.1.0", + "System.Reflection.Primitives": "4.0.1", + "System.Runtime": "4.1.0" + } + }, + "System.Reflection.Primitives/4.0.1": { + "dependencies": { + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0" + } + }, + "System.Resources.ResourceManager/4.0.1": { + "dependencies": { + "Microsoft.NETCore.Targets": "1.0.1", + "System.Globalization": "4.0.11", + "System.Reflection": "4.1.0", + "System.Runtime": "4.1.0" + } + }, + "System.Runtime/4.1.0": { + "dependencies": { + "Microsoft.NETCore.Targets": "1.0.1" + } + }, + "System.Runtime.Extensions/4.1.0": { + "dependencies": { + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0" + } + }, + "System.Runtime.Handles/4.0.1": { + "dependencies": { + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0" + } + }, + "System.Runtime.InteropServices/4.1.0": { + "dependencies": { + "Microsoft.NETCore.Targets": "1.0.1", + "System.Reflection": "4.1.0", + "System.Reflection.Primitives": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Handles": "4.0.1" + } + }, + "System.Runtime.Numerics/4.0.1": { + "dependencies": { + "System.Globalization": "4.0.11", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0" + } + }, + "System.Security.Cryptography.Algorithms/4.2.0": { + "dependencies": { + "System.Collections": "4.0.11", + "System.IO": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Runtime.InteropServices": "4.1.0", + "System.Runtime.Numerics": "4.0.1", + "System.Security.Cryptography.Encoding": "4.0.0", + "System.Security.Cryptography.Primitives": "4.0.0", + "System.Text.Encoding": "4.0.11", + "runtime.native.System.Security.Cryptography": "4.0.0" + }, + "runtimeTargets": { + "runtime/unix/lib/_._": { + "rid": "unix", + "assetType": "runtime" + }, + "runtime/win/lib/_._": { + "rid": "win", + "assetType": "runtime" + } + } + }, + "System.Security.Cryptography.Csp/4.0.0": { + "dependencies": { + "System.IO": "4.1.0", + "System.Reflection": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Runtime.InteropServices": "4.1.0", + "System.Security.Cryptography.Algorithms": "4.2.0", + "System.Security.Cryptography.Encoding": "4.0.0", + "System.Security.Cryptography.Primitives": "4.0.0", + "System.Text.Encoding": "4.0.11", + "System.Threading": "4.0.11" + }, + "runtimeTargets": { + "runtime/unix/lib/_._": { + "rid": "unix", + "assetType": "runtime" + }, + "runtime/win/lib/_._": { + "rid": "win", + "assetType": "runtime" + } + } + }, + "System.Security.Cryptography.Encoding/4.0.0": { + "dependencies": { + "System.Collections": "4.0.11", + "System.Collections.Concurrent": "4.0.12", + "System.Linq": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Runtime.InteropServices": "4.1.0", + "System.Security.Cryptography.Primitives": "4.0.0", + "System.Text.Encoding": "4.0.11", + "runtime.native.System.Security.Cryptography": "4.0.0" + }, + "runtimeTargets": { + "runtime/unix/lib/_._": { + "rid": "unix", + "assetType": "runtime" + }, + "runtime/win/lib/_._": { + "rid": "win", + "assetType": "runtime" + } + } + }, + "System.Security.Cryptography.Primitives/4.0.0": { + "dependencies": { + "System.Diagnostics.Debug": "4.0.11", + "System.Globalization": "4.0.11", + "System.IO": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11" + } + }, + "System.Text.Encoding/4.0.11": { + "dependencies": { + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0" + } + }, + "System.Threading/4.0.11": { + "dependencies": { + "System.Runtime": "4.1.0", + "System.Threading.Tasks": "4.0.11" + } + }, + "System.Threading.Tasks/4.0.11": { + "dependencies": { + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0" + } + } + } + }, + "libraries": { + "APITool/1.0.0": { + "type": "project", + "serviceable": false, + "sha512": "" + }, + "CommandLineParser/2.4.3": { + "type": "package", + "serviceable": true, + "sha512": "sha512-3/WpSCsHNo4aTSaNW9SnmSqRNDgR4meKVJn5anKZn/hR/lGnDp8HbDMu1/w2GXOXi2rAhREU1cNwQMtEtlR1mg==", + "path": "commandlineparser/2.4.3", + "hashPath": "commandlineparser.2.4.3.nupkg.sha512" + }, + "Microsoft.NETCore.Targets/1.0.1": { + "type": "package", + "serviceable": true, + "sha512": "sha512-rkn+fKobF/cbWfnnfBOQHKVKIOpxMZBvlSHkqDWgBpwGDcLRduvs3D9OLGeV6GWGvVwNlVi2CBbTjuPmtHvyNw==", + "path": "microsoft.netcore.targets/1.0.1", + "hashPath": "microsoft.netcore.targets.1.0.1.nupkg.sha512" + }, + "Mono.Cecil/0.10.1": { + "type": "package", + "serviceable": true, + "sha512": "sha512-ZpklVgBklS7Rq3UQUzFZZvEpljrdyXxIbHKiZQJ4IMt4CAGYp7Z3mh5hNV4lT2e0CyTJ1Qb5ldNds0HzgYPlGw==", + "path": "mono.cecil/0.10.1", + "hashPath": "mono.cecil.0.10.1.nupkg.sha512" + }, + "runtime.native.System.Security.Cryptography/4.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-2CQK0jmO6Eu7ZeMgD+LOFbNJSXHFVQbCJJkEyEwowh1SCgYnrn9W9RykMfpeeVGw7h4IBvYikzpGUlmZTUafJw==", + "path": "runtime.native.system.security.cryptography/4.0.0", + "hashPath": "runtime.native.system.security.cryptography.4.0.0.nupkg.sha512" + }, + "System.Collections/4.0.11": { + "type": "package", + "serviceable": true, + "sha512": "sha512-YUJGz6eFKqS0V//mLt25vFGrrCvOnsXjlvFQs+KimpwNxug9x0Pzy4PlFMU3Q2IzqAa9G2L4LsK3+9vCBK7oTg==", + "path": "system.collections/4.0.11", + "hashPath": "system.collections.4.0.11.nupkg.sha512" + }, + "System.Collections.Concurrent/4.0.12": { + "type": "package", + "serviceable": true, + "sha512": "sha512-2gBcbb3drMLgxlI0fBfxMA31ec6AEyYCHygGse4vxceJan8mRIWeKJ24BFzN7+bi/NFTgdIgufzb94LWO5EERQ==", + "path": "system.collections.concurrent/4.0.12", + "hashPath": "system.collections.concurrent.4.0.12.nupkg.sha512" + }, + "System.Diagnostics.Debug/4.0.11": { + "type": "package", + "serviceable": true, + "sha512": "sha512-w5U95fVKHY4G8ASs/K5iK3J5LY+/dLFd4vKejsnI/ZhBsWS9hQakfx3Zr7lRWKg4tAw9r4iktyvsTagWkqYCiw==", + "path": "system.diagnostics.debug/4.0.11", + "hashPath": "system.diagnostics.debug.4.0.11.nupkg.sha512" + }, + "System.Diagnostics.Tracing/4.1.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-vDN1PoMZCkkdNjvZLql592oYJZgS7URcJzJ7bxeBgGtx5UtR5leNm49VmfHGqIffX4FKacHbI3H6UyNSHQknBg==", + "path": "system.diagnostics.tracing/4.1.0", + "hashPath": "system.diagnostics.tracing.4.1.0.nupkg.sha512" + }, + "System.Globalization/4.0.11": { + "type": "package", + "serviceable": true, + "sha512": "sha512-B95h0YLEL2oSnwF/XjqSWKnwKOy/01VWkNlsCeMTFJLLabflpGV26nK164eRs5GiaRSBGpOxQ3pKoSnnyZN5pg==", + "path": "system.globalization/4.0.11", + "hashPath": "system.globalization.4.0.11.nupkg.sha512" + }, + "System.IO/4.1.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-3KlTJceQc3gnGIaHZ7UBZO26SHL1SHE4ddrmiwumFnId+CEHP+O8r386tZKaE6zlk5/mF8vifMBzHj9SaXN+mQ==", + "path": "system.io/4.1.0", + "hashPath": "system.io.4.1.0.nupkg.sha512" + }, + "System.IO.FileSystem/4.0.1": { + "type": "package", + "serviceable": true, + "sha512": "sha512-IBErlVq5jOggAD69bg1t0pJcHaDbJbWNUZTPI96fkYWzwYbN6D9wRHMULLDd9dHsl7C2YsxXL31LMfPI1SWt8w==", + "path": "system.io.filesystem/4.0.1", + "hashPath": "system.io.filesystem.4.0.1.nupkg.sha512" + }, + "System.IO.FileSystem.Primitives/4.0.1": { + "type": "package", + "serviceable": true, + "sha512": "sha512-kWkKD203JJKxJeE74p8aF8y4Qc9r9WQx4C0cHzHPrY3fv/L/IhWnyCHaFJ3H1QPOH6A93whlQ2vG5nHlBDvzWQ==", + "path": "system.io.filesystem.primitives/4.0.1", + "hashPath": "system.io.filesystem.primitives.4.0.1.nupkg.sha512" + }, + "System.Linq/4.1.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-bQ0iYFOQI0nuTnt+NQADns6ucV4DUvMdwN6CbkB1yj8i7arTGiTN5eok1kQwdnnNWSDZfIUySQY+J3d5KjWn0g==", + "path": "system.linq/4.1.0", + "hashPath": "system.linq.4.1.0.nupkg.sha512" + }, + "System.Reflection/4.1.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-JCKANJ0TI7kzoQzuwB/OoJANy1Lg338B6+JVacPl4TpUwi3cReg3nMLplMq2uqYfHFQpKIlHAUVAJlImZz/4ng==", + "path": "system.reflection/4.1.0", + "hashPath": "system.reflection.4.1.0.nupkg.sha512" + }, + "System.Reflection.Primitives/4.0.1": { + "type": "package", + "serviceable": true, + "sha512": "sha512-4inTox4wTBaDhB7V3mPvp9XlCbeGYWVEM9/fXALd52vNEAVisc1BoVWQPuUuD0Ga//dNbA/WeMy9u9mzLxGTHQ==", + "path": "system.reflection.primitives/4.0.1", + "hashPath": "system.reflection.primitives.4.0.1.nupkg.sha512" + }, + "System.Resources.ResourceManager/4.0.1": { + "type": "package", + "serviceable": true, + "sha512": "sha512-TxwVeUNoTgUOdQ09gfTjvW411MF+w9MBYL7AtNVc+HtBCFlutPLhUCdZjNkjbhj3bNQWMdHboF0KIWEOjJssbA==", + "path": "system.resources.resourcemanager/4.0.1", + "hashPath": "system.resources.resourcemanager.4.0.1.nupkg.sha512" + }, + "System.Runtime/4.1.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-v6c/4Yaa9uWsq+JMhnOFewrYkgdNHNG2eMKuNqRn8P733rNXeRCGvV5FkkjBXn2dbVkPXOsO0xjsEeM1q2zC0g==", + "path": "system.runtime/4.1.0", + "hashPath": "system.runtime.4.1.0.nupkg.sha512" + }, + "System.Runtime.Extensions/4.1.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-CUOHjTT/vgP0qGW22U4/hDlOqXmcPq5YicBaXdUR2UiUoLwBT+olO6we4DVbq57jeX5uXH2uerVZhf0qGj+sVQ==", + "path": "system.runtime.extensions/4.1.0", + "hashPath": "system.runtime.extensions.4.1.0.nupkg.sha512" + }, + "System.Runtime.Handles/4.0.1": { + "type": "package", + "serviceable": true, + "sha512": "sha512-nCJvEKguXEvk2ymk1gqj625vVnlK3/xdGzx0vOKicQkoquaTBJTP13AIYkocSUwHCLNBwUbXTqTWGDxBTWpt7g==", + "path": "system.runtime.handles/4.0.1", + "hashPath": "system.runtime.handles.4.0.1.nupkg.sha512" + }, + "System.Runtime.InteropServices/4.1.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-16eu3kjHS633yYdkjwShDHZLRNMKVi/s0bY8ODiqJ2RfMhDMAwxZaUaWVnZ2P71kr/or+X9o/xFWtNqz8ivieQ==", + "path": "system.runtime.interopservices/4.1.0", + "hashPath": "system.runtime.interopservices.4.1.0.nupkg.sha512" + }, + "System.Runtime.Numerics/4.0.1": { + "type": "package", + "serviceable": true, + "sha512": "sha512-+XbKFuzdmLP3d1o9pdHu2nxjNr2OEPqGzKeegPLCUMM71a0t50A/rOcIRmGs9wR7a8KuHX6hYs/7/TymIGLNqg==", + "path": "system.runtime.numerics/4.0.1", + "hashPath": "system.runtime.numerics.4.0.1.nupkg.sha512" + }, + "System.Security.Cryptography.Algorithms/4.2.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-8JQFxbLVdrtIOKMDN38Fn0GWnqYZw/oMlwOUG/qz1jqChvyZlnUmu+0s7wLx7JYua/nAXoESpHA3iw11QFWhXg==", + "path": "system.security.cryptography.algorithms/4.2.0", + "hashPath": "system.security.cryptography.algorithms.4.2.0.nupkg.sha512" + }, + "System.Security.Cryptography.Csp/4.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-/i1Usuo4PgAqgbPNC0NjbO3jPW//BoBlTpcWFD1EHVbidH21y4c1ap5bbEMSGAXjAShhMH4abi/K8fILrnu4BQ==", + "path": "system.security.cryptography.csp/4.0.0", + "hashPath": "system.security.cryptography.csp.4.0.0.nupkg.sha512" + }, + "System.Security.Cryptography.Encoding/4.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-FbKgE5MbxSQMPcSVRgwM6bXN3GtyAh04NkV8E5zKCBE26X0vYW0UtTa2FIgkH33WVqBVxRgxljlVYumWtU+HcQ==", + "path": "system.security.cryptography.encoding/4.0.0", + "hashPath": "system.security.cryptography.encoding.4.0.0.nupkg.sha512" + }, + "System.Security.Cryptography.Primitives/4.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-Wkd7QryWYjkQclX0bngpntW5HSlMzeJU24UaLJQ7YTfI8ydAVAaU2J+HXLLABOVJlKTVvAeL0Aj39VeTe7L+oA==", + "path": "system.security.cryptography.primitives/4.0.0", + "hashPath": "system.security.cryptography.primitives.4.0.0.nupkg.sha512" + }, + "System.Text.Encoding/4.0.11": { + "type": "package", + "serviceable": true, + "sha512": "sha512-U3gGeMlDZXxCEiY4DwVLSacg+DFWCvoiX+JThA/rvw37Sqrku7sEFeVBBBMBnfB6FeZHsyDx85HlKL19x0HtZA==", + "path": "system.text.encoding/4.0.11", + "hashPath": "system.text.encoding.4.0.11.nupkg.sha512" + }, + "System.Threading/4.0.11": { + "type": "package", + "serviceable": true, + "sha512": "sha512-N+3xqIcg3VDKyjwwCGaZ9HawG9aC6cSDI+s7ROma310GQo8vilFZa86hqKppwTHleR/G0sfOzhvgnUxWCR/DrQ==", + "path": "system.threading/4.0.11", + "hashPath": "system.threading.4.0.11.nupkg.sha512" + }, + "System.Threading.Tasks/4.0.11": { + "type": "package", + "serviceable": true, + "sha512": "sha512-k1S4Gc6IGwtHGT8188RSeGaX86Qw/wnrgNLshJvsdNUOPP9etMmo8S07c+UlOAx4K/xLuN9ivA1bD0LVurtIxQ==", + "path": "system.threading.tasks/4.0.11", + "hashPath": "system.threading.tasks.4.0.11.nupkg.sha512" + } + } +}
\ No newline at end of file diff --git a/tools/bin/APITool/APITool.dll b/tools/bin/APITool/APITool.dll Binary files differnew file mode 100644 index 000000000..cf6848120 --- /dev/null +++ b/tools/bin/APITool/APITool.dll diff --git a/tools/bin/APITool/APITool.pdb b/tools/bin/APITool/APITool.pdb Binary files differnew file mode 100644 index 000000000..ea5f448d4 --- /dev/null +++ b/tools/bin/APITool/APITool.pdb diff --git a/tools/bin/APITool/APITool.runtimeconfig.json b/tools/bin/APITool/APITool.runtimeconfig.json new file mode 100644 index 000000000..7539019b1 --- /dev/null +++ b/tools/bin/APITool/APITool.runtimeconfig.json @@ -0,0 +1,9 @@ +{ + "runtimeOptions": { + "tfm": "netcoreapp2.0", + "framework": { + "name": "Microsoft.NETCore.App", + "version": "2.0.0" + } + } +}
\ No newline at end of file diff --git a/tools/bin/APITool/CommandLine.dll b/tools/bin/APITool/CommandLine.dll Binary files differnew file mode 100755 index 000000000..a7feec12c --- /dev/null +++ b/tools/bin/APITool/CommandLine.dll diff --git a/tools/bin/APITool/Mono.Cecil.Mdb.dll b/tools/bin/APITool/Mono.Cecil.Mdb.dll Binary files differnew file mode 100755 index 000000000..4fcaa4131 --- /dev/null +++ b/tools/bin/APITool/Mono.Cecil.Mdb.dll diff --git a/tools/bin/APITool/Mono.Cecil.Pdb.dll b/tools/bin/APITool/Mono.Cecil.Pdb.dll Binary files differnew file mode 100755 index 000000000..9b68872c8 --- /dev/null +++ b/tools/bin/APITool/Mono.Cecil.Pdb.dll diff --git a/tools/bin/APITool/Mono.Cecil.Rocks.dll b/tools/bin/APITool/Mono.Cecil.Rocks.dll Binary files differnew file mode 100755 index 000000000..becd68533 --- /dev/null +++ b/tools/bin/APITool/Mono.Cecil.Rocks.dll diff --git a/tools/bin/APITool/Mono.Cecil.dll b/tools/bin/APITool/Mono.Cecil.dll Binary files differnew file mode 100755 index 000000000..58dddaa32 --- /dev/null +++ b/tools/bin/APITool/Mono.Cecil.dll diff --git a/tools/build-tools.sh b/tools/build-tools.sh index 7ed2a1193..46923e5e0 100755 --- a/tools/build-tools.sh +++ b/tools/build-tools.sh @@ -17,7 +17,7 @@ find $SOURCE_DIR -type d -name "obj" -prune -exec rm -r "{}" \; dotnet publish -c $CONF Tools.sln # Install -APPS="GenDummy ABIChecker" +APPS="GenDummy ABIChecker APITool" for x in $APPS; do mkdir -p $BINARY_DIR/$x diff --git a/tools/src/APITool/APIPrinter.cs b/tools/src/APITool/APIPrinter.cs new file mode 100644 index 000000000..415b94849 --- /dev/null +++ b/tools/src/APITool/APIPrinter.cs @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.IO; +using System.Linq; +using Mono.Cecil; + +namespace APITool +{ + public class APIPrinter : AssemblyProcessor + { + ListOptions _options; + bool _isPrintAll; + + StreamWriter _writer; + + public APIPrinter(ListOptions options) + { + _options = options; + _isPrintAll = !(options.PrintTypes | options.PrintFields | options.PrintProperties | options.PrintEvents | options.PrintMethods); + + if (!string.IsNullOrEmpty(options.OutputFile)) { + _writer = new StreamWriter(options.OutputFile); + } else { + _writer = new StreamWriter(Console.OpenStandardOutput()); + } + } + + public void Run(string filepath) + { + var asm = AssemblyDefinition.ReadAssembly(filepath); + ProcessAssembly(asm); + } + + protected override void ProcessType(TypeDefinition typeDef) + { + if (typeDef.IsPublic) + { + bool isHidden = IsHidden(typeDef.CustomAttributes); + if (_options.PrintHiddens || !isHidden) + { + if (_isPrintAll || _options.PrintTypes) + { + _writer.WriteLine("T: {0}{1}{2}", + isHidden ? "*hidden* " : string.Empty, + typeDef.FullName, + typeDef.BaseType != null ? " : " + typeDef.BaseType.FullName : string.Empty); + _writer.Flush(); + } + base.ProcessType(typeDef); + } + } + } + + protected override void ProcessField(FieldDefinition fieldDef) + { + if (fieldDef.IsPublic && fieldDef.IsLiteral) + { + bool isHidden = IsHidden(fieldDef.CustomAttributes); + if ((_isPrintAll || _options.PrintFields) && (_options.PrintHiddens || !isHidden)) + { + _writer.WriteLine("F: {0}{1}{2}{3}", + isHidden ? "*hidden* " : string.Empty, + fieldDef.IsStatic ? "static " : string.Empty, + fieldDef.FullName, + fieldDef.HasConstant ? " = " + fieldDef.Constant : string.Empty); + _writer.Flush(); + } + } + } + + protected override void ProcessProperty(PropertyDefinition propDef) + { + bool isHidden = IsHidden(propDef.CustomAttributes); + if ((_isPrintAll || _options.PrintProperties) && (_options.PrintHiddens || !isHidden)) + { + _writer.WriteLine("P: {0}{1} {{ {2}{3} }}", + isHidden ? "*hidden* " : string.Empty, + propDef.FullName, + propDef.GetMethod != null ? "get;" : string.Empty, + propDef.SetMethod != null ? " set;" : string.Empty); + _writer.Flush(); + } + } + + protected override void ProcessEvent(EventDefinition eventDef) + { + bool isHidden = IsHidden(eventDef.CustomAttributes); + if ((_isPrintAll || _options.PrintEvents) && (_options.PrintHiddens || !isHidden)) + { + _writer.WriteLine("E: {0}{1}", + isHidden ? "*hidden* " : string.Empty, + eventDef.FullName); + _writer.Flush(); + } + } + + protected override void ProcessMethod(MethodDefinition methodDef) + { + if (methodDef.IsPublic && !methodDef.IsGetter && !methodDef.IsSetter && !methodDef.IsAddOn && !methodDef.IsRemoveOn) + { + bool isHidden = IsHidden(methodDef.CustomAttributes); + if ((_isPrintAll || _options.PrintMethods) && (_options.PrintHiddens || !isHidden)) + { + _writer.WriteLine("M: {0}{1}", + isHidden ? "*hidden* " : string.Empty, + methodDef.FullName); + _writer.Flush(); + } + } + } + + bool IsHidden(Mono.Collections.Generic.Collection<CustomAttribute> attrs) + { + bool ret = false; + var attr = attrs.FirstOrDefault(a => a.AttributeType.FullName == "System.ComponentModel.EditorBrowsableAttribute"); + if (attr != null) + { + if (attr.ConstructorArguments.Count > 0) + { + ret = (int)attr.ConstructorArguments[0].Value == (int)System.ComponentModel.EditorBrowsableState.Never; + } + } + return ret; + } + + } +} diff --git a/tools/src/APITool/APITool.csproj b/tools/src/APITool/APITool.csproj new file mode 100644 index 000000000..5bcfbb6f4 --- /dev/null +++ b/tools/src/APITool/APITool.csproj @@ -0,0 +1,13 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFramework>netcoreapp2.0</TargetFramework> + </PropertyGroup> + + <ItemGroup> + <PackageReference Include="CommandLineParser" Version="2.4.3" /> + <PackageReference Include="Mono.Cecil" Version="0.10.1" /> + </ItemGroup> + +</Project> diff --git a/tools/src/APITool/AssemblyProcessor.cs b/tools/src/APITool/AssemblyProcessor.cs new file mode 100644 index 000000000..98600d8f5 --- /dev/null +++ b/tools/src/APITool/AssemblyProcessor.cs @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System.Linq; +using Mono.Cecil; + +namespace APITool +{ + public abstract class AssemblyProcessor + { + protected virtual void ProcessAssembly(AssemblyDefinition asmDef) + { + foreach (var module in asmDef.Modules.OrderBy(x => x.Name)) + { + ProcessModule(module); + } + } + + protected virtual void ProcessModule(ModuleDefinition moduleDef) + { + foreach (var typedef in moduleDef.Types.OrderBy(x => x.FullName)) + { + ProcessType(typedef); + } + } + + protected virtual void ProcessType(TypeDefinition typeDef) + { + foreach (var field in typeDef.Fields.OrderBy(x => x.FullName)) + { + ProcessField(field); + } + + foreach (var prop in typeDef.Properties.OrderBy(x => x.FullName)) + { + ProcessProperty(prop); + } + + foreach (var method in typeDef.Methods.OrderBy(x => x.FullName)) + { + ProcessMethod(method); + } + + foreach (var ev in typeDef.Events.OrderBy(x => x.FullName)) + { + ProcessEvent(ev); + } + + foreach (var nt in typeDef.NestedTypes.OrderBy(x => x.FullName)) + { + ProcessType(nt); + } + } + + protected abstract void ProcessField(FieldDefinition fieldDef); + + protected abstract void ProcessProperty(PropertyDefinition propDef); + + protected abstract void ProcessEvent(EventDefinition eventDef); + + protected abstract void ProcessMethod(MethodDefinition methodDef); + + } +} diff --git a/tools/src/APITool/DummyGenerator.cs b/tools/src/APITool/DummyGenerator.cs new file mode 100644 index 000000000..c50085420 --- /dev/null +++ b/tools/src/APITool/DummyGenerator.cs @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Reflection; +using System.Linq; +using Mono.Cecil; +using Mono.Cecil.Cil; + +namespace APITool +{ + public class DummyGenerator : AssemblyProcessor + { + public void Run(string srcPath, string targetPath) + { + var asm = AssemblyDefinition.ReadAssembly(srcPath); + ProcessAssembly(asm); + asm.Write(targetPath); + } + + protected override void ProcessAssembly(AssemblyDefinition asmDef) + { + Log.Verbose("Assembly: " + asmDef.FullName); + + var attr = asmDef.CustomAttributes.FirstOrDefault(a => a.AttributeType.FullName == "System.Runtime.CompilerServices.ReferenceAssemblyAttribute"); + if (attr != null) + { + asmDef.CustomAttributes.Remove(attr); + } + + base.ProcessAssembly(asmDef); + } + + protected override void ProcessField(FieldDefinition fieldDef) + { + Log.Verbose(" Field: " + fieldDef.FullName); + } + + protected override void ProcessMethod(MethodDefinition methodDef) + { + Log.Verbose($" Method: {methodDef.FullName}"); + if (methodDef.Name == "Finalize") + { + ReplaceWithVoidReturn(methodDef); + } + else + { + ReplaceWithThrowPNSE(methodDef); + } + } + + protected override void ProcessProperty(PropertyDefinition propDef) + { + Log.Verbose(" Property: " + propDef.FullName); + if (propDef.GetMethod != null) + { + Log.Verbose(" Getter:"); + ReplaceWithThrowPNSE(propDef.GetMethod); + } + if (propDef.SetMethod != null) + { + Log.Verbose(" Setter:"); + ReplaceWithThrowPNSE(propDef.SetMethod); + } + } + + protected override void ProcessEvent(EventDefinition eventDef) + { + Log.Verbose(" Event: " + eventDef.FullName); + if (eventDef.AddMethod != null) + { + Log.Verbose(" Add:"); + ReplaceWithThrowPNSE(eventDef.AddMethod); + } + if (eventDef.RemoveMethod != null) + { + Log.Verbose(" Remove:"); + ReplaceWithThrowPNSE(eventDef.RemoveMethod); + } + foreach (var method in eventDef.OtherMethods) + { + Log.Verbose(" Other: " + method.FullName); + ReplaceWithThrowPNSE(method); + } + } + + private bool ReplaceWithThrowPNSE(MethodDefinition method) + { + if (method.HasBody && method.IsIL) + { + ClearMethodBody(method); + + ConstructorInfo exceptionCtor = typeof(PlatformNotSupportedException).GetConstructor(new Type[] { typeof(System.String) }); + var exceptionCtorRef = method.Module.ImportReference(exceptionCtor); + + var processor = method.Body.GetILProcessor(); + processor.Append(processor.Create(OpCodes.Ldstr, "Not Supported Feature")); + processor.Append(processor.Create(OpCodes.Newobj, exceptionCtorRef)); + processor.Append(processor.Create(OpCodes.Throw)); + + PrintMethodBody(method); + + return true; + } + return false; + } + + private void ReplaceWithVoidReturn(MethodDefinition method) + { + if (method.HasBody && method.IsIL) + { + ClearMethodBody(method); + + var processor = method.Body.GetILProcessor(); + processor.Append(processor.Create(OpCodes.Nop)); + processor.Append(processor.Create(OpCodes.Ret)); + + PrintMethodBody(method); + } + } + + private void ClearMethodBody(MethodDefinition method) + { + var processor = method.Body.GetILProcessor(); + while (method.Body.Instructions.Count > 0) + { + processor.Remove(method.Body.Instructions[0]); + } + } + + private void PrintMethodBody(MethodDefinition method) + { + if (method.HasBody) + { + foreach (var inst in method.Body.Instructions) + { + Log.Verbose($" {inst.ToString()}"); + } + } + } + } +} diff --git a/tools/src/APITool/Log.cs b/tools/src/APITool/Log.cs new file mode 100644 index 000000000..08f2e587b --- /dev/null +++ b/tools/src/APITool/Log.cs @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace APITool +{ + public enum LogLevel + { + NONE = 0, + ERROR, + WARNING, + INFO, + DEBUG, + VERBOSE + } + + public class Log + { + public static LogLevel Level { get; set; } = LogLevel.INFO; + + public static void Error(string msg) => Print(LogLevel.ERROR, "[ERROR] " + msg); + + public static void Warning(string msg) => Print(LogLevel.WARNING, "[WARNING] " + msg); + + public static void Info(string msg) => Print(LogLevel.INFO, "[INFO] " + msg); + + public static void Debug(string msg) => Print(LogLevel.DEBUG, "[DEBUG] " + msg); + + public static void Verbose(string msg) => Print(LogLevel.VERBOSE, "[VERBOSE] " + msg); + + private static void Print(LogLevel msgLevel, string msg) + { + if (Level >= msgLevel) + { + Console.WriteLine(msg); + } + } + } +}
\ No newline at end of file diff --git a/tools/src/APITool/Options.cs b/tools/src/APITool/Options.cs new file mode 100644 index 000000000..a98af89f4 --- /dev/null +++ b/tools/src/APITool/Options.cs @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using CommandLine; + +namespace APITool +{ + [Verb("list", HelpText = "Show public exposed API list.")] + public class ListOptions + { + [Option('v', "verbose", Default = false, HelpText = "Print verbose messages.")] + public bool Verbose { get; set; } + + [Option('t', "types", Default = false, HelpText = "Print types.")] + public bool PrintTypes { get; set; } + + [Option('f', "fields", Default = false, HelpText = "Print fields.")] + public bool PrintFields { get; set; } + + [Option('p', "properties", Default = false, HelpText = "Print properties.")] + public bool PrintProperties { get; set; } + + [Option('e', "events", Default = false, HelpText = "Print events.")] + public bool PrintEvents { get; set; } + + [Option('m', "methods", Default = false, HelpText = "Print methods.")] + public bool PrintMethods { get; set; } + + [Option('h', "include-hidden", Default = false, HelpText = "Print hidden(internal API) entries.")] + public bool PrintHiddens { get; set; } + + [Option('o', "output", Required=false, HelpText = "Output file path")] + public string OutputFile {get; set;} + + [Value(0, MetaName = "target", Required = true, HelpText = "Target assembly or directory")] + public string Target { get; set; } + } + + [Verb("dummy", HelpText = "Generate dummy assemblies")] + public class DummyOptions + { + [Option('v', "verbose", Default = false, HelpText = "Print verbose messages.")] + public bool Verbose { get; set; } + + [Value(0, MetaName = "InputPath", Required = true, HelpText = "Input file or directory to process.")] + public string InputPath { get; set; } + + [Value(1, MetaName = "OutputPath", HelpText = "Output path for generated files.")] + public string OutputPath { get; set; } + } + +} diff --git a/tools/src/APITool/Program.cs b/tools/src/APITool/Program.cs new file mode 100644 index 000000000..51e93524a --- /dev/null +++ b/tools/src/APITool/Program.cs @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using CommandLine; + +namespace APITool +{ + class Program + { + public int RunListAndReturnExitCode(ListOptions options) + { + if (options.Verbose) + { + Log.Level = LogLevel.VERBOSE; + } + + APIPrinter printer = new APIPrinter(options); + + string absTarget = Path.GetFullPath(options.Target); + if (Directory.Exists(absTarget)) + { + DirectoryInfo targetDir = new DirectoryInfo(absTarget); + var targetFiles = targetDir.GetFiles("*.dll").OrderBy(f => f.Name); + foreach (var file in targetFiles) + { + printer.Run(file.FullName); + } + } + else if (File.Exists(absTarget)) + { + printer.Run(absTarget); + } + else + { + Log.Error($"No such file found: {absTarget}"); + return 1; + } + + return 0; + } + + public int RunDummyAndReturnExitCode(DummyOptions options) + { + if (options.Verbose) + { + Log.Level = LogLevel.VERBOSE; + } + + DummyGenerator dummyGenerator = new DummyGenerator(); + + // Convert to absolute path + if (!string.IsNullOrEmpty(options.InputPath)) + { + options.InputPath = Path.GetFullPath(options.InputPath); + } + if (!string.IsNullOrEmpty(options.OutputPath)) + { + options.OutputPath = Path.GetFullPath(options.OutputPath); + } + + if (Directory.Exists(options.InputPath)) + { + if (string.IsNullOrEmpty(options.OutputPath) || !Directory.Exists(options.OutputPath)) + { + throw new DirectoryNotFoundException("Directory should be set as the output path."); + } + + if (!options.OutputPath.EndsWith(Path.DirectorySeparatorChar)) + { + options.OutputPath += Path.DirectorySeparatorChar; + } + + DirectoryInfo inputDirInfo = new DirectoryInfo(options.InputPath); + FileInfo[] inputFiles = inputDirInfo.GetFiles("*.dll", SearchOption.AllDirectories); + + Regex rgx = new Regex("^" + options.InputPath.Replace("\\", "\\\\").Replace("+", "\\+")); + foreach (var f in inputFiles) + { + Log.Info($"Processing {f.FullName} ..."); + dummyGenerator.Run(f.FullName, rgx.Replace(f.FullName, options.OutputPath)); + } + } + else + { + if (!File.Exists(options.InputPath)) + { + throw new FileNotFoundException("Couldn't find the input file : " + options.InputPath); + } + dummyGenerator.Run(options.InputPath, options.OutputPath); + } + + return 0; + } + + static int Main(string[] args) + { + try + { + Program program = new Program(); + return Parser.Default.ParseArguments<ListOptions, DummyOptions>(args).MapResult( + (ListOptions opts) => program.RunListAndReturnExitCode(opts), + (DummyOptions opts) => program.RunDummyAndReturnExitCode(opts), + errs => 1); + } + catch (Exception ex) + { + Log.Error(ex.Message); + Log.Error(ex.StackTrace); + Environment.Exit(1); + } + return 0; + } + } +} |