Git Product home page Git Product logo

conan-rs's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

conan-rs's Issues

Conan install error

Hi,

I tried to use 'conan-rs' following the steps mentioned. However, I am getting an error as below:

Running `/home/rust-test/rust/rust-conan/target/debug/build/rust-conan-ab89c5392bdc9e1a/build-script-build`

[rust-conan 0.1.0] usage: conan install [-h] [-f FORMAT] [-v [V]] [--name NAME]
[rust-conan 0.1.0] [--version VERSION] [--user USER] [--channel CHANNEL]
[rust-conan 0.1.0] [--requires REQUIRES] [--tool-requires TOOL_REQUIRES]
[rust-conan 0.1.0] [-b BUILD] [-r REMOTE | -nr] [-u] [-o OPTIONS_HOST]
[rust-conan 0.1.0] [-o:b OPTIONS_BUILD] [-o:h OPTIONS_HOST]
[rust-conan 0.1.0] [-pr PROFILE_HOST] [-pr:b PROFILE_BUILD]
[rust-conan 0.1.0] [-pr:h PROFILE_HOST] [-s SETTINGS_HOST]
[rust-conan 0.1.0] [-s:b SETTINGS_BUILD] [-s:h SETTINGS_HOST] [-c CONF_HOST]
[rust-conan 0.1.0] [-c:b CONF_BUILD] [-c:h CONF_HOST] [-l LOCKFILE]
[rust-conan 0.1.0] [--lockfile-partial] [--lockfile-out LOCKFILE_OUT]
[rust-conan 0.1.0] [--lockfile-packages] [--lockfile-clean] [-g GENERATOR]
[rust-conan 0.1.0] [-of OUTPUT_FOLDER] [--deploy DEPLOY]
[rust-conan 0.1.0] [path]
[rust-conan 0.1.0] conan install: error: unrecognized arguments: -if conanfile.txt
[rust-conan 0.1.0] ERROR: Exiting with code: 2

Please let me know how to fix the same.

successfully hardcoded the include path for CXX

I had to hard-code the include path

    let include_path = "/home/emcp/.conan/data/twsapi/10.25.01/stonks/prod/package/2a448472971d7718b4207a1ee198ae4f78f2995d/include";

from my conan-rs installed library.. but is there a better more elegant way to get this wired together with CXX?

build.rs

use std::path::{Path, PathBuf};
use cxx_build::CFG;
use conan::*;


fn main() {
    // requires : sudo apt install libintelrdfpmath-dev
    println!("cargo:rustc-link-lib=bidgcc000");

    let default_conan_profile = "default";

    let command: InstallCommand = InstallCommandBuilder::new()
        .with_profile(&default_conan_profile)
        .build_policy(BuildPolicy::Missing)
        .recipe_path(Path::new("conanfile.txt"))
        .build();

    if let Some(build_info) = command.generate() {
        println!("using conan build info");
        build_info.cargo_emit();

        let twsapi:&BuildDependency = build_info.get_dependency("twsapi").unwrap();

        let twsapi_inc_dir:Vec<&str> = twsapi.get_include_dirs();

        for dir in &twsapi_inc_dir {
            let twsapi_inc_dir_path = Path::new(dir);
            // Add TWSAPI Conan Pkg to Includes
            CFG.exported_header_dirs.extend([twsapi_inc_dir_path]);
        }
    }

    let build_command = BuildCommandBuilder::new()
        .with_recipe_path(PathBuf::from("../../../conanfile.py"))
        .with_build_path(PathBuf::from("../../../build/"))
        .build();

    if let Some(exit_status) = build_command.run() {
       println!("conan build exited with {}", exit_status);
    }

    let include_path = "/home/emcp/.conan/data/twsapi/10.25.01/stonks/prod/package/2a448472971d7718b4207a1ee198ae4f78f2995d/include";

    cxx_build::bridge("src/main.rs")
        .file("src/gettingstarted.cc")
        .include(include_path)
        .flag_if_supported("-std=c++17")
        .compile("twsapi_helloworld");



    println!("cargo:rerun-if-changed=src/main.rs");
    println!("cargo:rerun-if-changed=src/gettingstarted.cc");
    println!("cargo:rerun-if-changed=include/gettingstarted.h");
}

Having trouble grasping once the conan package is added.. how best to call the code.. CXX + ConanRS example?

I have two successful separate projects which I am now trying to sort of combine.

Project #1

a basic conanrs setup which pulls in the C++ recipe I wrote .. but I am unsure how to proceed to use it in rust

Project #2

instantiate this project https://github.com/dtolnay/cxx/tree/master/demo

The challenge

How can I start to call my Conan package code.. like the CXX demo example ? are there tutorials out there showing the way to include C++ code via conan.. and start integrating it properly in a rust program.. in my case it will be a GRPC server wrapping my custom conan packages C++

Progress So Far

I've so far just combined the build.rs of the two

use std::path::Path;
use std::env;

use conan::*;

fn main() {

    let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
    let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
    let default_conan_profile = "default";
    let _conan_profile = format!("{}-{}", target_os, target_arch);

    let command = InstallCommandBuilder::new()
        .with_profile(&default_conan_profile)
        .build_policy(BuildPolicy::Missing)
        .recipe_path(Path::new("conanfile.txt"))
        .build();

    if let Some(build_info) = command.generate() {
        println!("using conan build info");
        build_info.cargo_emit();
    }

    cxx_build::bridge("src/main.rs")
        .file("src/blobstore.cc")
        .flag_if_supported("-std=c++17")
        .compile("cxxbridge-demo");

    println!("cargo:rerun-if-changed=src/main.rs");
    println!("cargo:rerun-if-changed=src/blobstore.cc");
    println!("cargo:rerun-if-changed=include/blobstore.h");
}

Everything builds fine.. but next I need to learn how to start calling the Conan provided code..

conan generate failures

Hi,

While using 'conan-rs' to integrate rust with conan, I see failures as:

[hello 0.1.0] ======== Finalizing install (deploy, generators) ========
[hello 0.1.0] conanfile.txt: Writing generators to /work/rust-app
[hello 0.1.0] ERROR: Invalid generator 'json'. Available types: CMakeToolchain, CMakeDeps, MesonToolchain, MSBuildDeps, MSBuildToolchain, NMakeToolchain, NMakeDeps, VCVars, QbsProfile, VirtualRunEnv, VirtualBuildEnv, AutotoolsDeps, AutotoolsToolchain, PkgConfigDeps, BazelDeps, BazelToolchain, IntelCC, XcodeDeps, XcodeToolchain, PremakeDeps, MakeDeps, SConsDeps

I am using 'conan2' which doesn't seem to support 'json' as generator. However, install.rs pushes '-g json' for install command.

Could you please help to fix the issue?

No option for setting options

In InstallCommandBuilder there is a with_profile and other settings related fluent methods, but there is no method to set options (which are required for using some packages.)

We've worked around this issue for a while locally with environment variables, but it would save us hacking to add something like with_option to set an option.

successfully gotten to compile but project in CXX fails at linker stage

I just wanted to checkin if I am doing something wrong with my conan package.. I have updated my recipe to call out the system library dependency.. but CXX still cannot find my libraries built.. everything works in C++ just fine so I am a bit lost

dtolnay/cxx#1132 (comment)

note: /usr/bin/ld: /home/emcp/Dev/git/JRGEMCP_Bootstrapping/bootstrap-rust-cpp-conan/target/debug/build/twsapi_grpc_server-f1ae9ab28f1e650b/out/libtwsapi-grpc-server.a(twsapi-client.o): in function
 `decimalToString[abi:cxx11](unsigned long long)':                                                                                                                                                       
          /home/emcp/.conan/data/twsapi/10.20.01/stonks/prod/package/062863c92a5a0a247840166e9f84ebe8d10786b9/include/Decimal.h:68: undefined reference to `__bid64_to_string'    

the conanmanifest.txt

1669456927
bin/JavaDDE.dll: 8a1c959be15a0b8701dbe83338a8f9fa
bin/JavaDDEx64.dll: 4153f04a310ca3610771fc8e35e3c8bc
bin/biddll.dll: 5b6664fa454d750709cfe4b6aff762de
conaninfo.txt: 33600f202dc2ac2783c2a606f6678d2a
include/CommissionReport.h: dc3e59f802e48f98a5d442b3f828fda1
include/CommonDefs.h: 76c431e6b6cf28f85431cf7922b42b62
include/Contract.h: 30f22cc07544fd2927c6d55a0aa8f532
include/ContractCondition.h: 338c06207c139eb50727a405b45711f2
include/Decimal.h: b0ae33c9bd1ba429cdc8b64e837f50de
include/DefaultEWrapper.h: 9ef79c5f2bf05f84f2f6cd71ecf011a9
include/DepthMktDataDescription.h: d152ac5211dfeb932bc0d09a5c68efcc
include/EClient.h: e0b8c74d4799ab1f69b369d455e7d401
include/EClientException.h: 364391057b8d129c5fd3048d04cbd25b
include/EClientMsgSink.h: 039f0d72c18cdfd56f2cc086a192a51c
include/EClientSocket.h: 102edd49f5990a996c6d0a313ecde069
include/EDecoder.h: 230fbc655a959aa710dd81c8a3f02006
include/EMessage.h: 1864a7e06e49bd0900aeb2d540d092d9
include/EMutex.h: 13c65b792e117577f6aa0336080063c0
include/EOrderDecoder.h: 33fb1a5d8c80a1be4f8014b621c9a9dc
include/EPosixClientSocketPlatform.h: 2b4f8e35b523b8c315f8dc10d95f5690
include/EReader.h: bfd2cb150eb1b5ec7d4d0902c50a446f
include/EReaderOSSignal.h: 2646cf85790a77d02393f9601d2bbe6b
include/EReaderSignal.h: 3445b62e82330d96c1d0960c024323fc
include/ESocket.h: 3bf392a921426990e88345f099a0f741
include/ETransport.h: b22da11d30137acaf4cccbbb472cf40c
include/EWrapper.h: 85862b206fc8b39d3b6b025333b24dc6
include/EWrapper_prototypes.h: 72055e8bb6cb53387369e502d3f82937
include/Execution.h: 478a674269396ca20591b92fe21b354f
include/FamilyCode.h: 046882fb077fbff4d78b1dbf995817d4
include/HistogramEntry.h: af34b4f4150a52d02ac4fb55f5b4c154
include/HistoricalSession.h: d72aa4d4789c878d50e1dca8720af7e8
include/HistoricalTick.h: c2ce30d543a14a7f11e2346c2850ec3e
include/HistoricalTickBidAsk.h: 8d8f66466bd6c7df8efa0934ec03fdcc
include/HistoricalTickLast.h: 496d5cf9a17da5c0fbf801e1b8b2a95c
include/IExternalizable.h: 1a2e529c48ba52df4e32419233bdf5a8
include/MarginCondition.h: c61677888e52bed6b50f7d1d45a19754
include/NewsProvider.h: a9f74105139aee84ac5d8afe1a394703
include/OperatorCondition.h: 40f8f0b64dca4e51b363ab6a47de4d81
include/Order.h: 6cbb997c8f5d6769e3000ffdfdfc29b2
include/OrderCondition.h: 08ac57efc6741c2a4f1bc3fe0f2776d9
include/OrderState.h: 7f41dd41f907e004c32976e32b748b95
include/PercentChangeCondition.h: bf5390b73ae673332aedd894923df088
include/PriceCondition.h: 08e42b5739a570fe841f110c8919d93f
include/PriceIncrement.h: 314f7ff3ebfec3f6badd9e44d9373fc8
include/ScannerSubscription.h: ab96323b2f493905ed21390363210d8c
include/SoftDollarTier.h: 448e6a16b69815de1e3e61247e6497fc
include/StdAfx.h: 4c2a04d94745ac8b28cfed549b4254cc
include/TagValue.h: 4b78a41afdad69f0d2fc9915b6d0c8a1
include/TickAttrib.h: 9544d8b0c33549eda8390da1ac196c7e
include/TickAttribBidAsk.h: 1fb4dd1e86e4ff6f4c9827d6954dd96f
include/TickAttribLast.h: 8ace281e3f228bbfe9364755276d193e
include/TimeCondition.h: 4d9557059924f1c7b4cbbbe4d354099f
include/TwsSocketClientErrors.h: fb95ef037bf3f60c86cc0af52e9b05a7
include/VolumeCondition.h: 4190af00ee3e0db634fa42da3a292dbc
include/WshEventData.h: 4688ce2c6c52e3d01fd08b622fdb0650
include/bar.h: ffd367caa980641090a092d7f75e7b2e
include/executioncondition.h: efd9496785ff162315abe48095cd24c7
include/platformspecific.h: afb49774959ec5d8fd045b60f1fba9f2
include/resource.h: f94777f52839d6193582e03ae215fd01
lib/biddll.lib: 35d3c5d1935a045e632f9537a1bf35be
lib/libbid.a: cc99fe8df80f9a360674c91b5023aae0
lib/libbid.lib: 1fa5d341302f79a3a7eb502b27c631c3
lib/libbid.so: e4bd934330ddeb5ba21cf1e08d7cbf19
lib/libtwsapi.a: 3c060cc878f1115e8fe49ef5a02afd1b

I added the system library dep like so

def package_info(self):
    self.cpp_info.libs = ["twsapi"]
    self.cpp_info.system_libs = ["bidgcc000"]

https://stackoverflow.com/a/74475762/389976

but seems CXX just cannot find what C++ 's GCC normally can via regular conan

Any thoughts? if it's clearly not a conanRS issue feel free to close, thanks for looking

followed instruction but not seeing my library in the build output

Hi first time getting into Rust.. pivoting away from C++.. and I have a custom Conan recipe that is not public.. but have been using it fairly easily for a year or so..

when I went to try the step-by-step instructions for integrating that conan recipe with my test project.. it failed to show any connection or loading had occurred.. is this because the library is private? or did I miss a step possibly?

Cargo.toml

[package]
name = "rust_twsapi_demo"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cxx = "1.0.80"

[build-dependencies]
conan = "0.3.0"

conanfile.txt

[requires]
twsapi/10.17.01@stonks/prod

build.rs

use std::path::Path;
use std::env;

use conan::*;

fn main() {
    let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
    let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
    let conan_profile = format!("{}-{}", target_os, target_arch);

    let command = InstallCommandBuilder::new()
        .with_profile(&conan_profile)
        .build_policy(BuildPolicy::Missing)
        .recipe_path(Path::new("conanfile.txt"))
        .build();

    if let Some(build_info) = command.generate() {
        println!("using conan build info");
        build_info.cargo_emit();
    }
}

Result

cargo -vv build
       Fresh unicode-ident v1.0.5
       Fresh proc-macro2 v1.0.47
       Fresh cc v1.0.74
       Fresh quote v1.0.21
       Fresh syn v1.0.103
       Fresh autocfg v1.1.0
       Fresh memchr v2.5.0
       Fresh serde_derive v1.0.147
       Fresh serde v1.0.147
       Fresh libc v0.2.137
       Fresh aho-corasick v0.7.19
       Fresh ryu v1.0.11
       Fresh cxxbridge-flags v1.0.80
       Fresh regex-syntax v0.6.28
       Fresh itoa v1.0.4
       Fresh hashbrown v0.12.3
       Fresh regex v1.7.0
       Fresh serde_json v1.0.87
       Fresh indexmap v1.9.1
       Fresh which v3.1.1
       Fresh lazy_static v1.4.0
       Fresh conan v0.3.0
       Fresh link-cplusplus v1.0.7
       Fresh cxxbridge-macro v1.0.80
       Fresh cxx v1.0.80
       Fresh rust_twsapi_demo v0.1.0 (/home/emcp/Dev/temp/rust_twsapi_demo)
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.