Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
deno
提交
89794d5d
D
deno
项目概览
张重言
/
deno
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
deno
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
89794d5d
编写于
8月 28, 2019
作者:
B
Bert Belder
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
build: make it possible to pass arbitrary env vars to rustc
上级
590463bd
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
37 addition
and
41 deletion
+37
-41
build_extra/rust/run.py
build_extra/rust/run.py
+18
-21
build_extra/rust/rust.gni
build_extra/rust/rust.gni
+17
-18
cli/BUILD.gn
cli/BUILD.gn
+2
-2
未找到文件。
build_extra/rust/run.py
浏览文件 @
89794d5d
#!/usr/bin/env python
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
# This file just executes its arguments, except that also adds GN_OUT_DIR and
# CARGO_PKG_VERSION to the environ. This is for compatibility with cargo.
# This file just executes its arguments, except that it allows overriding
# environment variables using command-line arguments.
import
subprocess
import
sys
import
os
import
re
args
=
sys
.
argv
[
1
:
]
args
=
[
]
env
=
os
.
environ
.
copy
()
if
sys
.
platform
==
'win32'
:
...
...
@@ -27,24 +29,19 @@ if sys.platform == 'win32':
env
[
"GN_OUT_DIR"
]
=
os
.
path
.
abspath
(
"."
)
assert
os
.
path
.
isdir
(
env
[
"GN_OUT_DIR"
])
# Some crates (e.g. 'typenum') generate source files and place them in the
# directory indicated by the 'OUT_DIR' environment variable, which is normally
# set by Cargo. We pre-generate these files and store them in the source repo.
# Therefore, set 'OUT_DIR' so these crates can find their generated sources.
for
i
,
arg
in
enumerate
(
args
):
match
=
re
.
search
(
'--generated-source-dir=(.*)'
,
arg
)
if
match
:
env
[
"OUT_DIR"
]
=
os
.
path
.
abspath
(
match
.
group
(
1
))
del
args
[
i
]
break
# Set the CARGO_PKG_VERSION env variable if provided as an argument
# When building with Cargo this variable is set automatically
for
i
,
arg
in
enumerate
(
args
):
match
=
re
.
search
(
'--cargo-pkg-version="?([^"]*)"?'
,
arg
)
# Environment variables can be specified on the command line using
# '--env=variable=value' flags. These flags are not passed through to rustc.
# This is useful to set env vars that are normally automatically set by Cargo,
# e.g. CARGO_PKG_NAME, CARGO_PKG_VERSION, OUT_DIR, etc.
for
arg
in
sys
.
argv
[
1
:]:
match
=
re
.
search
(
'--env=([^=]+)=(.*)'
,
arg
)
if
match
:
env
[
"CARGO_PKG_VERSION"
]
=
match
.
group
(
1
)
del
args
[
i
]
break
key
,
value
=
match
.
groups
()
if
key
==
"OUT_DIR"
:
# OUT_DIR needs to contain an absolute path.
value
=
os
.
path
.
abspath
(
value
)
env
[
key
]
=
value
else
:
args
.
append
(
arg
)
sys
.
exit
(
subprocess
.
call
(
args
,
env
=
env
))
build_extra/rust/rust.gni
浏览文件 @
89794d5d
...
...
@@ -63,6 +63,7 @@ template("_rust_crate") {
"crate_version",
"deps",
"edition",
"env",
"features",
"generated_source_dir",
"inputs",
...
...
@@ -234,24 +235,6 @@ template("_rust_crate") {
"--color=always",
]
if (defined(generated_source_dir)) {
args += [
# Some crates (e.g. 'typenum') generate source files and place them in
# the directory indicated by the 'OUT_DIR' environment variable, which
# is normally set by Cargo. This flag tells run.py to set 'OUT_DIR' to
# the path where the current crate can find its generated sources.
"--generated-source-dir=" +
rebase_path(generated_source_dir, root_build_dir),
]
}
if (defined(crate_version)) {
args += [
# This is used to set env variables for Cargo build compatibility
"--cargo-pkg-version=$crate_version",
]
}
if (is_win) {
# Proc-macro crates need to be linked by rustc itself, because rustc
# doesn't expose all the information necessary to produce the correct
...
...
@@ -318,6 +301,22 @@ template("_rust_crate") {
sources += [ info.out_path ]
deps += [ info.label ]
}
if (defined(generated_source_dir)) {
args += [
# Some crates (e.g. 'typenum') generate source files and place them in
# the directory indicated by the 'OUT_DIR' environment variable, which
# is normally set by Cargo. This flag tells run.py to set 'OUT_DIR' to
# the path where the current crate can find its generated sources.
"--env=OUT_DIR=" + rebase_path(generated_source_dir, root_build_dir),
]
}
if (defined(env)) {
foreach(e, env) {
args += [ "--env=$e" ]
}
}
}
}
...
...
cli/BUILD.gn
浏览文件 @
89794d5d
...
...
@@ -179,10 +179,10 @@ rust_executable("deno") {
# Extract version from Cargo.toml
# TODO integrate this into rust.gni by allowing the rust_executable template
# to specify a cargo.toml from which it will extract a version.
crate_version = deno_cargo_info.version
inputs = [
"Cargo.toml",
]
env = [ "CARGO_PKG_VERSION=${deno_cargo_info.version}" ]
}
rust_test("cli_test") {
...
...
@@ -194,10 +194,10 @@ rust_test("cli_test") {
]
# Extract version from Cargo.toml
crate_version = deno_cargo_info.version
inputs = [
"Cargo.toml",
]
env = [ "CARGO_PKG_VERSION=${deno_cargo_info.version}" ]
}
# Generates the core TypeScript type library for deno that will be
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录