Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,32 @@
*.slo
*.lo
*.o
*.obj

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Compiled executables
*.exe

# Build directories
build/
bin/
debug/
release/
.vs/

# Backup files
*~
*.bak

# Auto tools generated files.
.deps/
Expand All @@ -40,3 +50,6 @@ compile
libtocc/src/libtocc.pc
libtocc/tests/libtocctests

# Catch2 files
catch_amalgamated.cpp
catch_amalgamated.hpp
15 changes: 13 additions & 2 deletions cli/docs/source/compile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
:hidden:


How to Compile Tocc's Official CLI
==================================
How to Compile Tocc's Official CLI in a Unix-like OS (Linux, BSD, etc)
======================================================================

In order to compile CLI, you need first have ``libtocc`` compiled and
installed. Follow the instructions in
Expand Down Expand Up @@ -62,3 +62,14 @@ This will install ``tocc`` binary in the directory you specified using
``--prefix`` (or the default directory).



How to Compile Tocc's Official CLI in Windows using Microsoft Visual C++
========================================================================

1. Open solution file ``tocc\msvc\libtocctests.sln`` in MSVC.
2. Select project ``tocc``.
3. Build this project.
4. Select project ``tocc-initialize``.
5. Build this project.
6. The programs will be ``tocc.exe`` and ``tocc-initialize`` in directory ``tocc\msvc\x64\release`` or ``tocc\msvc\x64\debug``.

Binary file added cli/src/TOCCFILES.DB
Binary file not shown.
4 changes: 3 additions & 1 deletion cli/src/actions/assign_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ namespace tocccli
}

// Converting files vector to array.
const char* files_array[files.size()];
const char* sizevar;
const char** files_array = (const char**) malloc(files.size() * sizeof sizevar);
for (int i = 0; i < files.size(); i++)
{
files_array[i] = files[i].get_id();
Expand All @@ -71,5 +72,6 @@ namespace tocccli
}

this->libtocc_manager->assign_tags(files_array, files.size(), &tags_collection);
free(files_array);
}
}
4 changes: 3 additions & 1 deletion cli/src/actions/remove_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ namespace tocccli
}

//Extracting files ids into an array
const char* file_ids[files.size()];
const char* sizevar;
const char** file_ids = (const char**)malloc(files.size() * sizeof sizevar);
for(int i = 0; i < files.size(); i++)
{
file_ids[i] = files[i].get_id();
Expand All @@ -66,5 +67,6 @@ namespace tocccli
{
this->libtocc_manager->remove_files(file_ids, files.size());
}
free(file_ids);
}
}
4 changes: 3 additions & 1 deletion cli/src/actions/set_title_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ namespace tocccli
}

//extract file ids to an array
const char* file_ids[files.size()];
const char* sizevar;
const char** file_ids = (const char**)malloc(files.size() * sizeof sizevar);
for(int i = 0; i < files.size(); i++)
{
file_ids[i] = files[i].get_id();
}

this->libtocc_manager->set_titles(file_ids, files.size(), cmd_arguments.front().c_str());
free(file_ids);
}
}
4 changes: 3 additions & 1 deletion cli/src/actions/tags_statistics_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,16 @@ namespace tocccli
else
{
// Converting files vector to array of IDs.
const char* files_array[files.size()];
const char* sizevar;
const char** files_array = (const char**)malloc(files.size() * sizeof sizevar);
for (int i = 0; i < files.size(); i++)
{
files_array[i] = files[i].get_id();
}

statistics_collection =
this->libtocc_manager->get_tags_statistics(files_array, files.size());
free(files_array);
}

// Print statistics in a pretty format.
Expand Down
7 changes: 4 additions & 3 deletions cli/src/actions/unassign_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ namespace tocccli
{
throw InvalidParametersError("-u, --unassign, must have at least one argument.");
}

// Converting files vector to array.
const char* files_array[files.size()];
// Converting files vector to array.
const char* sizevar;
const char** files_array = (const char**)malloc(files.size() * sizeof sizevar);
for (int i = 0; i < files.size(); i++)
{
files_array[i] = files[i].get_id();
Expand All @@ -71,5 +71,6 @@ namespace tocccli
}

this->libtocc_manager->unassign_tags(files_array, files.size(), &tags_collection);
free(files_array);
}
}
7 changes: 7 additions & 0 deletions cli/src/initializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
*/

#include <iostream>
#ifdef _MSC_VER
#include "unistdx.h"
#else
#include <unistd.h> // getcwd
#endif
#include <cstdio> // FILENAME_MAX
#include <errno.h>

Expand Down Expand Up @@ -55,6 +59,9 @@ int main(int argc, char* argv[])
{
// Using current directory as the base path.
char path_buffer[FILENAME_MAX];
#ifdef _MSC_VER
#define getcwd _getcwd
#endif
if (!getcwd(path_buffer, FILENAME_MAX))
{
std::cout << tocccli::translate_errno(errno) << std::endl;
Expand Down
7 changes: 7 additions & 0 deletions cli/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
#include <string>
#include <vector>
#include <utility>
#ifdef _MSC_VER
#include "unistdx.h"
#else
#include <unistd.h> // getcwd
#endif
#include <cstdio> // FILENAME_MAX
#include <iostream>
#include <errno.h>
Expand Down Expand Up @@ -50,6 +54,9 @@ int main(int argc, char* argv[])

// Finding the current directory (default of Base Path).
char path_buffer[FILENAME_MAX];
#ifdef _MSC_VER
#define getcwd _getcwd
#endif
if (!getcwd(path_buffer, FILENAME_MAX))
{
std::cout << translate_errno(errno) << std::endl;
Expand Down
90 changes: 70 additions & 20 deletions libtocc/docs/source/compile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ Un-compress the package, then run::
$ make
$ make install

Compiling libtocc for Unix-like OS's (Linux, BSD, etc)
------------------------------------------------------

Compiling libtocc
-----------------

1. Bootstraiping
1. Bootstrapping
^^^^^^^^^^^^^^^^

First step is bootstraping configure scripts. (You only need to do this if
First step is bootstrapping configure scripts. (You only need to do this if
you get the latest source from the repository. If you have one of the released
source packages, this step is already done for you.)

Expand Down Expand Up @@ -52,7 +51,7 @@ want to install it somewhere else, you can pass ``--prefix`` option to the

$ ./configure --prefix=/opt/libtocc/

In the above example, builded libraries will be placed in ``/opt/libtocc/lib/``
In the above example, built libraries will be placed in ``/opt/libtocc/lib/``
and public headers in ``/opt/libtocc/include``.

**Optimized/Debug Build**: By default, *libtocc* mades with ``-g`` and ``-O2``.
Expand Down Expand Up @@ -86,37 +85,69 @@ prefix. For example, if prefix is ``/usr/local/``, libraries will be copied
to ``/usr/local/lib/`` and headers to ``/usr/local/include``.


Compiling libtocc for Windows with Microsoft Visual C++
-------------------------------------------------------

Note: libtocc does not compile correctly with MSVC 2019 but it does with
MSVC 2017 or MSVC 2021.

1. Open solution file ``tocc\msvc\libtocctests.sln`` in MSVC.

2. Select project ``libtocc`` and do a build.

3. The library file will be produced in ``tocc\msvc\x64\release\libtocc.lib`` or ``tocc\msvc\x64\debug\libtocc.lib``





Test Units
----------

*libtocc* comes with some Unit Tests. They're placed in ``libtocc/tests``
directory. This section explains how to build and run these Unit Tests.

Installing Catch.hpp
^^^^^^^^^^^^^^^^^^^^
Tests are using `Catch <https://github.com/catchorg/Catch2>`_ library. The Tocc's
source code hadn't updated and it depends on the version 1 of Catch.
Installing Catch2 for Unix-like OS's (Linux, BSD, etc)
------------------------------------------------------

Download ``catch.hpp`` from `Catch 1.10.0 <https://github.com/catchorg/Catch2/releases/tag/v1.10.0>`_
and copy it to ``/usr/local/include``. Or alternatevly, copy it to another directory
and add a ``-I`` flag to the ``./configure`` command below to point to that directory.
1. Download Catch2 <https://github.com/catchorg/Catch2> to a temporary directory. Make sure you have the ``devel`` branch.
2. cd to the ``extras`` suddirectory of the temporary directory.
3. Invoke:

1. Bootstraping
^^^^^^^^^^^^^^^
Just like the bootstraping step of *libtocc* itself, you need Gnu Auto Tools.
$ gcc cache_amalgamated.cpp -o cache_amalgamated.o

$ ar rcs libcache_amalgamated.a cache_amalgamatd.o

$ sudo cp libcache_amalgamated.a /usr/local/lib

$ sudo cp cache_amalgamated.hpp /usr/local/include


Building and running test units for Unix-like OS's (Linux, BSD, etc.)
---------------------------------------------------------------------

1. Bootstrapping
^^^^^^^^^^^^^^^^
Just like the bootstrapping step of *libtocc* itself, you need Gnu Auto Tools.
Then invoke::

'
$ cd /path/to/libtocc/tests
$ ./bootstrap


'

2. Configuring
^^^^^^^^^^^^^^
Previous step creates a ``configure`` script. To run it, you need to add
``libtocc/src/`` directory to the includes path. The following command should
do it::

$ ./configure CPPFLAGS="-I../src/" CXXFLAGS="-I../src/"
$ ./configure CPPFLAGS="-I../src/ -I../tests" LDFLAGS="-L/usr/local/lib" CXXFLAGS="-I../src/ -I../tests" LIBS="-lcatch_amalgamated"

You can do this by typing:

$ ./config

Also, if you installed *libtocc* library in a non-standard path (where ``ld``
can't find it by default, say ``/opt/libtocc/lib/``) you need to add that to
Expand Down Expand Up @@ -160,8 +191,27 @@ Then send ``tests.log`` file to *tocc@aidinhut.com*, and provide your platform
information, such as your OS and its version.


Linking Your Software with *libtocc*
------------------------------------
Installing Catch2 for Windows
------------------------------------------------------

1. Download Catch2 <https://github.com/catchorg/Catch2> to a temporary directory. Make sure you have the ``devel`` branch.
2. cd to the ``extras`` suddirectory of the temporary directory.
3. Copy ``libcache_amalgamated.cpp`` and ``cache_amalgamated.hpp`` to ``tocc/libtocc/tests``



Building and running test units for Windows with Microsoft Visual C++
---------------------------------------------------------------------

1. Open solution file ``tocc\msvc\libtocctests.sln`` in MSVC.
2. Select project ``libtocctests``.
3. Build this project.
4. The program will be in ``tocc\msvc\x64\release\libtocctests.exe`` or ``tocc\msvc\x64\debug\libtocctests.exe``. Execute the program from a command prompt.



Linking Your Software with *libtocc* for Unix-like OS's (Linux, BSD, etc)
-------------------------------------------------------------------------

Using Autotools
^^^^^^^^^^^^^^^
Expand Down
4 changes: 4 additions & 0 deletions libtocc/src/libtocc/common/database_exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
* along with Tocc. If not, see <http://www.gnu.org/licenses/>.
*/

#ifdef _MSC_VER
#pragma warning(disable: 4996)
#endif

#include "libtocc/common/database_exceptions.h"
#include <string.h>

Expand Down
3 changes: 3 additions & 0 deletions libtocc/src/libtocc/common/file_system_exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
*/

#include "libtocc/common/file_system_exceptions.h"
//#ifdef _MSC_VER
#pragma warning(disable: 4996)
//#endif

#include <string>
#include <string.h> // For `strerror'.
Expand Down
28 changes: 28 additions & 0 deletions libtocc/src/libtocc/database/base_exception.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* This file is part of Tocc. (see <https://tocc.aidinhut.com>)
* Copyright (C) 2013, 2014, Aidin Gharibnavaz <tocc@aidinhut.com>
*
* Tocc is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tocc is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tocc. If not, see <http://www.gnu.org/licenses/>.
*/

#include "libtocc/common/base_exception.h"


namespace libtocc
{

BaseException::~BaseException() throw()
{
}
}
Loading