[CAT-35] implementation of Tizen Tracer C# api
authorjoon.c.baek <joon.c.baek@samsung.com>
Wed, 27 Jul 2016 22:54:55 +0000 (07:54 +0900)
committerChangjoon Baek <joon.c.baek@samsung.com>
Thu, 25 Aug 2016 00:04:24 +0000 (09:04 +0900)
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 <joon.c.baek@samsung.com>
12 files changed:
Makefile [new file with mode: 0755]
Tizen.sln [new file with mode: 0755]
Tizen.userprefs [new file with mode: 0644]
packaging/csapi-trace.manifest [new file with mode: 0644]
packaging/csapi-trace.pc.in [new file with mode: 0644]
packaging/csapi-trace.spec [new file with mode: 0644]
src/Tizen.Tracer/Interop/Interop.Libraries.cs [new file with mode: 0755]
src/Tizen.Tracer/Interop/Interop.Tracer.cs [new file with mode: 0755]
src/Tizen.Tracer/Properties/AssemblyInfo.cs [new file with mode: 0755]
src/Tizen.Tracer/Tizen.Tracer.csproj [new file with mode: 0755]
src/Tizen.Tracer/Tizen.Tracer.snk [new file with mode: 0755]
src/Tizen.Tracer/Tizen/Tracer.cs [new file with mode: 0755]

diff --git a/Makefile b/Makefile
new file mode 100755 (executable)
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 (executable)
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 (file)
index 0000000..3574f49
--- /dev/null
@@ -0,0 +1,13 @@
+<Properties>
+  <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
+  <MonoDevelop.Ide.Workbench ActiveDocument="Tizen.Tracer/Tizen/Tracer.cs">
+    <Files>
+      <File FileName="Tizen.Tracer/Tizen/Tracer.cs" Line="16" Column="3" />
+      <File FileName="Tizen.Tracer/Interop/Interop.Tracer.cs" Line="1" Column="1" />
+    </Files>
+  </MonoDevelop.Ide.Workbench>
+  <MonoDevelop.Ide.DebuggingService.Breakpoints>
+    <BreakpointStore />
+  </MonoDevelop.Ide.DebuggingService.Breakpoints>
+  <MonoDevelop.Ide.DebuggingService.PinnedWatches />
+</Properties>
diff --git a/packaging/csapi-trace.manifest b/packaging/csapi-trace.manifest
new file mode 100644 (file)
index 0000000..75b0fa5
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+    <request>
+        <domain name="_"/>
+    </request>
+</manifest>
diff --git a/packaging/csapi-trace.pc.in b/packaging/csapi-trace.pc.in
new file mode 100644 (file)
index 0000000..b42beaf
--- /dev/null
@@ -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 (file)
index 0000000..814d21a
--- /dev/null
@@ -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 (executable)
index 0000000..cee5a29
--- /dev/null
@@ -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 (executable)
index 0000000..08ec52c
--- /dev/null
@@ -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 (executable)
index 0000000..af572f3
--- /dev/null
@@ -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 (executable)
index 0000000..f5474eb
--- /dev/null
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>10.0.0</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{20C210FC-AE4F-411F-9BA9-8DD900ED61DB}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <RootNamespace>Tizen.Tracer</RootNamespace>
+    <AssemblyName>Tizen.Tracer</AssemblyName>
+    <SignAssembly>true</SignAssembly>
+    <AssemblyOriginatorKeyFile>Tizen.Tracer.snk</AssemblyOriginatorKeyFile>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <TargetFrameworkProfile />
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug</OutputPath>
+    <DefineConstants>DEBUG;</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ConsolePause>false</ConsolePause>
+    <Prefer32Bit>false</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>full</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ConsolePause>false</ConsolePause>
+    <Prefer32Bit>false</Prefer32Bit>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Interop\Interop.Libraries.cs" />
+    <Compile Include="Tizen\Tracer.cs" />
+    <Compile Include="Interop\Interop.Tracer.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <ItemGroup>
+    <None Include="Tizen.Tracer.snk" />
+  </ItemGroup>
+</Project>
diff --git a/src/Tizen.Tracer/Tizen.Tracer.snk b/src/Tizen.Tracer/Tizen.Tracer.snk
new file mode 100755 (executable)
index 0000000..95e0e71
Binary files /dev/null and b/src/Tizen.Tracer/Tizen.Tracer.snk differ
diff --git a/src/Tizen.Tracer/Tizen/Tracer.cs b/src/Tizen.Tracer/Tizen/Tracer.cs
new file mode 100755 (executable)
index 0000000..ea7bf58
--- /dev/null
@@ -0,0 +1,41 @@
+// 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;
+
+namespace Tizen
+{
+    public static class Tracer
+    {
+        public static void Begin (String name)
+        {
+            Interop.Tracer.Begin (name);
+        }
+
+        public static void End ()
+        {
+            Interop.Tracer.End ();
+        }
+
+        public static void AsyncBegin (int cookie, String name)
+        {
+            Interop.Tracer.AsyncBegin (cookie, name);
+        }
+
+        public static void AsyncEnd (int cookie, String name)
+        {
+            Interop.Tracer.AsyncEnd (cookie, name);
+        }
+
+        public static void TraceValue (int value, String name)
+        {
+            Interop.Tracer.TraceValue (value, name);
+        }
+    }
+}
+