Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export src dir via cargo #580

Merged
merged 2 commits into from
May 23, 2023
Merged

Export src dir via cargo #580

merged 2 commits into from
May 23, 2023

Conversation

sksat
Copy link
Collaborator

@sksat sksat commented May 17, 2023

概要

Cargo を経由して c2a-core crate のソースファイルのディレクトリを依存先の crate に公開する

Issue/PR

詳細

影響範囲

  • c2a-core crate のユーザー

補足

リリースしたい

@sksat sksat added enhancement New feature or request priority::high priorityg high tools labels May 17, 2023
@sksat sksat self-assigned this May 17, 2023
@sksat sksat requested a review from meltingrabbit May 17, 2023 19:49
Base automatically changed from feature/add-clang-runtime-feature to develop May 23, 2023 09:35
@@ -3,6 +3,8 @@ name = "c2a-core"
version = "3.9.0-beta.6"
edition = "2021"

links = "c2a-core"
Copy link
Collaborator

@meltingrabbit meltingrabbit May 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

元来はコンパイルした後にリンクするときの識別子.
C2A coreは(今は)linkできない(=libビルドできない)ので,build.rsでの識別子としてしか使ってない

@@ -6,6 +6,8 @@ use semver::Version;
use clang::{token::TokenKind::Punctuation, Clang, Index};

fn main() {
println!("cargo:source_dir={}", env!("CARGO_MANIFEST_DIR"));
Copy link
Collaborator

@meltingrabbit meltingrabbit May 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

env!("CARGO_MANIFEST_DIR")

がc2a-core本体がいるpath(で,これは予測不可能(cargoがcrateをあつめてbuildフォルダ?(まあ,ざっくりcrateがおいてある場所)に集める場所なので)

Copy link
Collaborator

@meltingrabbit meltingrabbit May 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

で,そのディレクトリを cargo:source_dir (これはuser定義変数)として取得したい.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

println!("cargo:hoge= ...

は,cargoにhoge optionを ... として伝える機能

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hogeがcargoの知ってる変数であれば,cargoの挙動が変わる.

一方で,source_dirはcargoは知らない変数であり,かつ,この変数をcrateつかいたい側がこの変数をみたいことがある.
そのときにlinksがないと,参照できない

参照の仕方はこう

env::var("DEP_C2A_CORE_SOURCE_DIR").unwrap();

DEP_${links}_変数名

なのは仕様

@sksat sksat merged commit db74c28 into develop May 23, 2023
@sksat sksat deleted the feature/export-src-dir-via-cargo branch May 23, 2023 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority::high priorityg high tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants