From 2b8c094356445066a07efe7688c97eadb4b9a0c7 Mon Sep 17 00:00:00 2001 From: "joon.c.baek" Date: Thu, 28 Jul 2016 07:54:55 +0900 Subject: [PATCH] [CAT-35] implementation of Tizen Tracer C# api Implementation of Tizen Tracer C# api, It's wrapper of T-trace CAPI and present same feature. Add sample code using Tizen Tracer C# api under test folder, Sample code's working verified at TM1 3.0 target. Modify as review comments: 1. Change comments sytle to double-slash(//) 2. Change Folder structure, Tizen.Tracer/Tracer.cs -> Tizen/Tracer.cs 3. Add license boilerplate 4. Replace CRLF to LF, CRLF created by VS2015. Implemented as follow API review result. Change-Id: Ibc628260ac0b923cef86b1d3fa2a5b208c917594 Signed-off-by: joon.c.baek --- Makefile | 24 ++++++++ Tizen.sln | 25 ++++++++ Tizen.userprefs | 13 +++++ packaging/csapi-trace.manifest | 5 ++ packaging/csapi-trace.pc.in | 5 ++ packaging/csapi-trace.spec | 81 ++++++++++++++++++++++++++ src/Tizen.Tracer/Interop/Interop.Libraries.cs | 15 +++++ src/Tizen.Tracer/Interop/Interop.Tracer.cs | 31 ++++++++++ src/Tizen.Tracer/Properties/AssemblyInfo.cs | 43 ++++++++++++++ src/Tizen.Tracer/Tizen.Tracer.csproj | 50 ++++++++++++++++ src/Tizen.Tracer/Tizen.Tracer.snk | Bin 0 -> 596 bytes src/Tizen.Tracer/Tizen/Tracer.cs | 41 +++++++++++++ 12 files changed, 333 insertions(+) create mode 100755 Makefile create mode 100755 Tizen.sln create mode 100644 Tizen.userprefs create mode 100644 packaging/csapi-trace.manifest create mode 100644 packaging/csapi-trace.pc.in create mode 100644 packaging/csapi-trace.spec create mode 100755 src/Tizen.Tracer/Interop/Interop.Libraries.cs create mode 100755 src/Tizen.Tracer/Interop/Interop.Tracer.cs create mode 100755 src/Tizen.Tracer/Properties/AssemblyInfo.cs create mode 100755 src/Tizen.Tracer/Tizen.Tracer.csproj create mode 100755 src/Tizen.Tracer/Tizen.Tracer.snk create mode 100755 src/Tizen.Tracer/Tizen/Tracer.cs diff --git a/Makefile b/Makefile new file mode 100755 index 0000000..33e0ba8 --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +ASM_DIRS := Tizen.Tracer +ASM_DLLS := $(addsuffix .dll,$(ASM_DIRS)) + +FLAGS := /unsafe + +ALL: $(ASM_DLLS) + +define make-dll +$(eval ASM = $(strip $1)) +$(eval SRC = $(shell find $(ASM) -path $(ASM)/obj -prune -o -name '*.cs' -print)) +$(eval PKG = $(shell echo $2 | tr ' ' ',')) +$(ASM).dll: $(SRC) + @echo "[BUILD] $$@" + @mcs /nologo /out:$$@ /t:library /keyfile:$(ASM)/$(ASM).snk $(addprefix /pkg:,$(PKG)) $(FLAGS) $(SRC) + @echo "[CHECK] $$@" + @RET=`mono-shlib-cop $$@`; \ + CNT=`echo $$$$RET | grep -e '^error:' | wc -l`; \ + if [ $$$$CNT -gt 0 ]; then echo $$$$RET; rm -f $$@ exit 1; fi +endef + +$(eval $(call make-dll, Tizen.Trace, csapi-tizen)) + +clean: + @rm -f $(ASM_DLLS) diff --git a/Tizen.sln b/Tizen.sln new file mode 100755 index 0000000..0238be8 --- /dev/null +++ b/Tizen.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Tracer", "Tizen.Tracer\Tizen.Tracer.csproj", "{20C210FC-AE4F-411F-9BA9-8DD900ED61DB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {20C210FC-AE4F-411F-9BA9-8DD900ED61DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {20C210FC-AE4F-411F-9BA9-8DD900ED61DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {20C210FC-AE4F-411F-9BA9-8DD900ED61DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {20C210FC-AE4F-411F-9BA9-8DD900ED61DB}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = Tizen.Tracer\Tizen.Tracer.csproj + EndGlobalSection +EndGlobal diff --git a/Tizen.userprefs b/Tizen.userprefs new file mode 100644 index 0000000..3574f49 --- /dev/null +++ b/Tizen.userprefs @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/packaging/csapi-trace.manifest b/packaging/csapi-trace.manifest new file mode 100644 index 0000000..75b0fa5 --- /dev/null +++ b/packaging/csapi-trace.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/csapi-trace.pc.in b/packaging/csapi-trace.pc.in new file mode 100644 index 0000000..b42beaf --- /dev/null +++ b/packaging/csapi-trace.pc.in @@ -0,0 +1,5 @@ +Name: csapi-trace +Description: Tizen Trace API for C# +Version: @version@ +Libs: -r:@dllpath@/@dllname@ +Requires: diff --git a/packaging/csapi-trace.spec b/packaging/csapi-trace.spec new file mode 100644 index 0000000..814d21a --- /dev/null +++ b/packaging/csapi-trace.spec @@ -0,0 +1,81 @@ +%define dllpath %{_libdir}/mono/tizen +%define dllname Tizen.Tracer.dll + +Name: csapi-trace +Summary: Tizen Tracer API for C# +Version: 1.0.0 +Release: 1 +Group: Development/Libraries +License: Apache-2.0 +URL: https://www.tizen.org +Source0: %{name}-%{version}.tar.gz +Source1: %{name}.manifest +Source2: %{name}.pc.in + +# TODO: replace mono-compiler, mono-devel to mcs, mono-shlib-cop +BuildRequires: mono-compiler +BuildRequires: mono-devel +# TODO: replace mono-core to gacutil. +# mono-core should provide the symbol 'gacutil' +Requires(post): mono-core +Requires(postun): mono-core + +# P/Invoke Dependencies +BuildRequires: pkgconfig(ttrace) +BuildRequires: pkgconfig(capi-ttrace) + +# P/Invoke Runtime Dependencies +# TODO: It should be removed after fix tizen-rpm-config +Requires: ttrace +Requires: capi-ttrace +# DLL Dependencies +BuildRequires: pkgconfig(csapi-tizen) +#BuildRequires: ... + +%description +Tizen Tracer API for C# + +%package devel +Summary: Development package for %{name} +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description devel +Development package for %{name} + +%prep +%setup -q + +cp %{SOURCE1} . + +%build +# build dll +make + +# check p/invoke +if [ -x %{dllname} ]; then + RET=`mono-shlib-cop %{dllname}`; \ + CNT=`echo $RET | grep -E "^error:" | wc -l`; \ + if [ $CNT -gt 0 ]; then exit 1; fi +fi + +%install +# copy dll +mkdir -p %{buildroot}%{dllpath} +install -p -m 644 %{dllname} %{buildroot}%{dllpath} + +# generate pkgconfig +mkdir -p %{buildroot}%{_libdir}/pkgconfig +sed -e "s#@version@#%{version}#g" \ + -e "s#@dllpath@#%{dllpath}#g" \ + -e "s#@dllname@#%{dllname}#g" \ + %{SOURCE2} > %{buildroot}%{_libdir}/pkgconfig/%{name}.pc + +%post +gacutil -i %{dllpath}/%{dllname} + +%files +%{dllpath}/%{dllname} + +%files devel +%{_libdir}/pkgconfig/%{name}.pc diff --git a/src/Tizen.Tracer/Interop/Interop.Libraries.cs b/src/Tizen.Tracer/Interop/Interop.Libraries.cs new file mode 100755 index 0000000..cee5a29 --- /dev/null +++ b/src/Tizen.Tracer/Interop/Interop.Libraries.cs @@ -0,0 +1,15 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +internal static partial class Interop +{ + internal static partial class Libraries + { + public const string ttrace = "libttrace.so.1"; + } +} diff --git a/src/Tizen.Tracer/Interop/Interop.Tracer.cs b/src/Tizen.Tracer/Interop/Interop.Tracer.cs new file mode 100755 index 0000000..08ec52c --- /dev/null +++ b/src/Tizen.Tracer/Interop/Interop.Tracer.cs @@ -0,0 +1,31 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class Tracer + { + [DllImport(Libraries.ttrace, EntryPoint = "trace_begin")] + internal static extern int Begin (String name); + + [DllImport(Libraries.ttrace, EntryPoint = "trace_end")] + internal static extern int End (); + + [DllImport(Libraries.ttrace, EntryPoint = "trace_async_begin")] + internal static extern int AsyncBegin (int cookie, String name); + + [DllImport(Libraries.ttrace, EntryPoint = "trace_async_end")] + internal static extern int AsyncEnd (int cookie, String name); + + [DllImport(Libraries.ttrace, EntryPoint = "trace_update_counter")] + internal static extern int TraceValue (int value, String name); + } +} diff --git a/src/Tizen.Tracer/Properties/AssemblyInfo.cs b/src/Tizen.Tracer/Properties/AssemblyInfo.cs new file mode 100755 index 0000000..af572f3 --- /dev/null +++ b/src/Tizen.Tracer/Properties/AssemblyInfo.cs @@ -0,0 +1,43 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tizen.Tracer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Samsung Electronics")] +[assembly: AssemblyProduct("Tizen.Tracer")] +[assembly: AssemblyCopyright("Copyright (c) 2016 Samsung Electronics Co., Ltd")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("3577eae8-b409-4bae-a5da-c6340be1dbc2")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Tizen.Tracer/Tizen.Tracer.csproj b/src/Tizen.Tracer/Tizen.Tracer.csproj new file mode 100755 index 0000000..f5474eb --- /dev/null +++ b/src/Tizen.Tracer/Tizen.Tracer.csproj @@ -0,0 +1,50 @@ + + + + Debug + AnyCPU + 10.0.0 + 2.0 + {20C210FC-AE4F-411F-9BA9-8DD900ED61DB} + Library + Tizen.Tracer + Tizen.Tracer + true + Tizen.Tracer.snk + v4.5 + + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + false + false + + + full + true + bin\Release + prompt + 4 + false + false + + + + + + + + + + + + + + + diff --git a/src/Tizen.Tracer/Tizen.Tracer.snk b/src/Tizen.Tracer/Tizen.Tracer.snk new file mode 100755 index 0000000000000000000000000000000000000000..95e0e71ec88c0acd8ecf952833e92cfd6a60050b GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50097J7y6L_!cRkiVUF|y*&C`=sRCv#Mfbox zNyu`UmKk+Vysc2|%sv;9UY0Ya#`*6)RD^Zh5n)fTcEg?$RCd&eES_Uw5$L3xrOGdw z+1IqG0cT&jW-J(rMh@OWgp}8wBn-cq5r;AKOL{`=0|YvVE3qJO6=d8A@if4&-{+m< z{C;*C4+&c38{bCH1eK9Aymd|fVkYCLQJ;K4dlf3_KUzmf2TpV=@`0`LH>EIr-iKg( zQ$uJKVKN$VwH?{5rh0Zf%5?J2a?hk}sTEhlK4wS(-TUfg-CizVKj|9uO}9zxs`h~0 zl65(c{KkU6gIBU_*Rb$-=BGCLZ+Bq*N3A_9yKXw>T$fE<)M64UH@q zKDxa?dvmj+q|@jl)hVFHz5xV`76OkkSQE)G4!9{H1YN|Bm}Z6fkf9GD)SyutEYV!i1eoBFAkNwai>oVxM2~<^ZqjaRLVdZ>3cwi(aBm4 z25-CoXD-qKuOrP`?p4U#vo2IXJZ5K?>)F`Ww`cf%pOk@BK;j&scF-gELx@X$oJc(> z;xsum&dH>Va<5o+Y@?(ct`w#pZwo=u)d4}NcTpJfD}w~}m%X-RN6`tXjWUg`A_iYG id2Np