Skip to content

Commit

Permalink
Merge branch 'xnor/conan' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
x37v committed Sep 2, 2021
2 parents 12a114d + 0bf850b commit 768519f
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Conan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Conan

You can use [conan](https://conan.io/) to integrate the min-api.

## Using Conan

There is [cmake](https://cmake.org/) based project in [examples/min.conan](examples/min.conan)
that uses a version of *min* that is packaged with conan.

This example uses a repository that you may or may not have access to. If you
don't, you can build the conan package locally, as indicated below, before
building the example.

## Creating and Uploading packages

To create a new version of the conan package based on the current checkout,
you'll want to run the commands below, but replace the tags with something
reasonable.

If you tag the git branch you'll make a version of the package with that name,
which will make using it easier later.

```shell
git tag v1.2.3
conan create . xnor/testing
```

To upload, you'll have to have a repository, here I've set up `cycling-jfrog` as a remote.
For example, if the version is `xnor_conan_v1.2.3` and I tagged with `xnor/testing`.

```shell
conan upload min-api/xnor_conan_v1.2.3@xnor/testing --all -r cycling-jfrog
```

Once you've uploaded the package you can use it as detailed below, and if your
repository is public, you can easily share your project with others without having
to include the *min-api* project inside your project.

You can also package *min-api* locally and build without uploading, but others will
have to do that themselves as well if they want to build your project.
1 change: 1 addition & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This folder contains the support files you will need to compile an external obje
* `script` : resources to be included and used by CMake
* `test` : supporting code and resources for unit testing
* [max-sdk-base](https://github.com/Cycling74/max-sdk-base) : a git submodule that provides the low-level bindings to the Max application
* [Conan.md](Conan.md) : information about how to create and use conan packages with `min-api`

## License

Expand Down
24 changes: 24 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from conans import ConanFile, tools

class MinAPI(ConanFile):
name = "min-api"
license = "MIT"
url = "https://github.com/Cycling74/min-api"
description = "Support files for compiling a MAX external object written in C++ using a high-level declarative application programming interface"

def set_version(self):
git = tools.Git(folder=self.recipe_folder)
tag = git.get_tag()
if tag:
self.version = tag.replace("/", "_")
else:
self.version = ("%s_%s" % (git.get_branch().replace("/", "_"), git.get_revision()))[:51]

def package_id(self):
self.info.header_only()

def export_sources(self):
self.copy("**", excludes=["*.js", "*.html", "examples/**"])

def package(self):
self.copy("**")
50 changes: 50 additions & 0 deletions examples/min.conan/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
cmake_minimum_required(VERSION 3.19)

project(MinConanExample)

set(AUTHOR_DOMAIN "com.cycling74")
set(COPYRIGHT_STRING "Copyright (c) 2020 Cycling '74")

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build, options are: Debug Release" FORCE)
endif()

#don't pollute the source directory
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/externals/" CACHE FILEPATH "The destination path for the built external")

if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/master/conan.cmake"
"${CMAKE_BINARY_DIR}/conan.cmake")
endif()

include(${CMAKE_BINARY_DIR}/conan.cmake)
conan_check(VERSION 1.29.0 REQUIRED)

conan_add_remote(
NAME cycling-public
INDEX 1
URL https://conan-public.cycling74.com
VERIFY_SSL True
)

conan_cmake_configure(
REQUIRES min-api/xnor_conan_981e563d455d4697f76dd0d0607d40e2357e5228@xnor/testing
GENERATORS cmake_paths
)
conan_cmake_autodetect(settings)
conan_cmake_install(
PATH_OR_REFERENCE .
BUILD missing
SETTINGS ${settings}
)

include(${CMAKE_CURRENT_BINARY_DIR}/conan_paths.cmake)
include(${CONAN_MIN-API_ROOT}/script/min-package.cmake)
include(${CONAN_MIN-API_ROOT}/script/min-pretarget.cmake)

include_directories("${C74_INCLUDES}")
set(SOURCE_FILES "min.conan.cpp")
add_library(${PROJECT_NAME} MODULE ${SOURCE_FILES})

include(${CONAN_MIN-API_ROOT}/script/min-posttarget.cmake)
60 changes: 60 additions & 0 deletions examples/min.conan/min.conan.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/// @file
/// @ingroup minexamples
/// @copyright Copyright 2018 The Min-DevKit Authors. All rights reserved.
/// @license Use of this source code is governed by the MIT License found in the License.md file.

#include "c74_min.h"

using namespace c74::min;

class conan : public object<conan> {
public:
MIN_DESCRIPTION {"Post to the Max Console."};
MIN_TAGS {"utilities"};
MIN_AUTHOR {"Cycling '74"};
MIN_RELATED {"print, jit.print, dict.print"};

inlet<> input { this, "(bang) post greeting to the max console" };
outlet<> output { this, "(anything) output the message which is posted to the max console" };


// define an optional argument for setting the message
argument<symbol> greeting_arg { this, "greeting", "Initial value for the greeting attribute.",
MIN_ARGUMENT_FUNCTION {
greeting = arg;
}
};


// the actual attribute for the message
attribute<symbol> greeting { this, "greeting", "hello world",
description {
"Greeting to be posted. "
"The greeting will be posted to the Max console when a bang is received."
}
};


// respond to the bang message to do something
message<> bang { this, "bang", "Post the greeting.",
MIN_FUNCTION {
symbol the_greeting = greeting; // fetch the symbol itself from the attribute named greeting

cout << the_greeting << endl; // post to the max console
output.send(the_greeting); // send out our outlet
return {};
}
};


// post to max window == but only when the class is loaded the first time
message<> maxclass_setup { this, "maxclass_setup",
MIN_FUNCTION {
cout << "hello world" << endl;
return {};
}
};

};

MIN_EXTERNAL(conan);

0 comments on commit 768519f

Please sign in to comment.