aboutsummaryrefslogtreecommitdiff
path: root/macros
diff options
context:
space:
mode:
Diffstat (limited to 'macros')
-rw-r--r--macros/Cargo.toml3
-rw-r--r--macros/src/lib.rs66
2 files changed, 66 insertions, 3 deletions
diff --git a/macros/Cargo.toml b/macros/Cargo.toml
index 8339549a..0c008c88 100644
--- a/macros/Cargo.toml
+++ b/macros/Cargo.toml
@@ -23,3 +23,6 @@ proc-macro-error = "1"
quote = "1"
syn = "1"
rtic-syntax = "1.0.0"
+
+[features]
+debugprint = []
diff --git a/macros/src/lib.rs b/macros/src/lib.rs
index adcd7316..13b6a7c2 100644
--- a/macros/src/lib.rs
+++ b/macros/src/lib.rs
@@ -7,7 +7,7 @@
extern crate proc_macro;
use proc_macro::TokenStream;
-use std::{fs, path::Path};
+use std::{env, fs, path::Path};
use rtic_syntax::Settings;
@@ -42,9 +42,69 @@ pub fn app(args: TokenStream, input: TokenStream) -> TokenStream {
let ts = codegen::app(&app, &analysis, &extra);
+ // Default output path: <project_dir>/target/
+ let mut out_dir = Path::new("target");
+
+ // Get output directory from Cargo environment
+ // TODO don't want to break builds if OUT_DIR is not set, is this ever the case?
+ let out_str = env::var("OUT_DIR").unwrap_or_else(|_| "".to_string());
+
+ // Assuming we are building for a thumbv* target
+ let target_triple_prefix = "thumbv";
+
+ // Check for special scenario where default target/ directory is not present
+ //
+ // This is configurable in .cargo/config:
+ //
+ // [build]
+ // target-dir = "target"
+ #[cfg(feature = "debugprint")]
+ println!("OUT_DIR\n{:#?}", out_str);
+
+ if !out_dir.exists() {
+ // Set out_dir to OUT_DIR
+ out_dir = Path::new(&out_str);
+
+ // Default build path, annotated below:
+ // $(pwd)/target/thumbv7em-none-eabihf/debug/build/cortex-m-rtic-<HASH>/out/
+ // <project_dir>/<target-dir>/<TARGET>/debug/build/cortex-m-rtic-<HASH>/out/
+ //
+ // traverse up to first occurrence of TARGET, approximated with starts_with("thumbv")
+ // and use the parent() of this path
+ //
+ // If no "target" directory is found, <project_dir>/<out_dir_root> is used
+ for path in out_dir.ancestors() {
+ if let Some(dir) = path.components().last() {
+ if dir
+ .as_os_str()
+ .to_str()
+ .unwrap()
+ .starts_with(target_triple_prefix)
+ //|| path.ends_with(&out_dir_root)
+ {
+ if let Some(out) = path.parent() {
+ out_dir = out;
+ #[cfg(feature = "debugprint")]
+ println!("{:#?}\n", out_dir);
+ break;
+ } else {
+ // If no parent, just use it
+ out_dir = path;
+ break;
+ }
+ }
+ }
+ }
+ } else {
+ #[cfg(feature = "debugprint")]
+ println!("\ntarget/ exists\n");
+ }
+
// Try to write the expanded code to disk
- if Path::new("target").exists() {
- fs::write("target/rtic-expansion.rs", ts.to_string()).ok();
+ if let Some(out_str) = out_dir.to_str() {
+ #[cfg(feature = "debugprint")]
+ println!("Write file:\n{}/rtic-expansion.rs\n", out_str);
+ fs::write(format!("{}/rtic-expansion.rs", out_str), ts.to_string()).ok();
}
ts.into()
> * middleware/file: correctly parse the stanza Parsing the file stanza would give precedence to 'transfer' and ignore other bits if it wasn't specified. This change fixes the parsing. The actually external CNAME retrieval is working fine (once the upstream is correctly parsed). This wasn't caught in tests, because we lack a parsing test for this. Fixes #657 * Add tests 2017-04-30Install: split build targets (#656)Gravatar Miek Gieben 1-3/+13 Allows one to use `make -f Makefile.release build-arm` to just get an Arm binary. 2017-04-30Remove annoying INFO from k8s middleware (#655)Gravatar John Belamaric 1-3/+1 2017-04-29middleware/cache: don't cache expired RRSIGs (#641)Gravatar Miek Gieben 7-62/+172 Check message for expired sig and don't cache those. Aside: This hack of caching entire messages is probably something we should stop doing at some point in the future and do this on a per RRset basis. Fixes #367 #635 2017-04-28Update vendor with `go dep`Gravatar Yong Tang 8408-13844/+2469780 This fix updates vendor with `go dep` Signed-off-by: Yong Tang <yong.tang.github@outlook.com> 2017-04-28Add vendor setup with `go dep`Gravatar Yong Tang 3-1/+443 This fix adds vendor setup with `go dep` Signed-off-by: Yong Tang <yong.tang.github@outlook.com> 2017-04-27update readme (#650)Gravatar Miek Gieben 1-3/+4 * update readme * Add slack Also add the slack channel. 2017-04-26middleware/proxy: Kill goroutines on stop (#646)Gravatar Miek Gieben 5-5/+112 * middleware/proxy: Kill goroutines on stop Ports caddy's https://github.com/mholt/caddy/commit/59bf71c2932c3b814a6a1211c492a1aa9f71d4a1 Excludes the proxy_test.go test part though. Fixes #644 * Add tests 2017-04-24Fix health race (#645)Gravatar Miek Gieben 6-28/+26 * Revert "middleware/proxy: Make Unhealthy a pointer (#615)" This reverts commit acbf522cebdcd53c26d153c1d9267d709ba75f64. * middleware/proxy: add proper locking This add the proper locking around `Unhealthy`. 2017-04-24Point users to deployment repo (#643)Gravatar John Belamaric 1-23/+3 2017-04-24Pprof listen (#639)Gravatar Chris O'Haver 4-9/+34 * add listen addr option * Add listen address option to pprof * There is configuration * code styling 2017-04-22msg.Service: add HostType() method (#627)Gravatar Miek Gieben 3-40/+114 This method parses the Host field in the service. It returns 1 or 3 things 1) it is a host 2) an IPv4 address or an 3) IPv6 address. This simplifies some code a bit and allows for 1 way of parsing the Host field. This *only* parse the Host field, Mail and/or Text values should be checked separately. We reuse the dns.TypeXXX values for this as to not invent anything new. 2017-04-21Fix go pprof lib link (#638)Gravatar Chris O'Haver 1-1/+1 2017-04-21Fix link to SkyDNS (#637)Gravatar Dominic 1-1/+1 Url was wrong 2017-04-20Fix TLS error message (#634)Gravatar Yue Ko 1-1/+1 Print corresponding error message when TLS initialization fails. 2017-04-20Add MAINTAINERS (#633)Gravatar Miek Gieben 2-0/+10 Add a MAINTAINERS file. It's not generated and not as elaborate (i.e. no focus areas) as the one prometheus uses. But it's a start. Generated with `git shortlog -s -n`, everyone with more than 5 commits. Docs are put in `Makefile.release`. Fixes #566 2017-04-19Clean up the tls middleware README (#631)Gravatar John Belamaric 1-4/+22 2017-04-19Update the various Kubernetes middleware README files. (#630)Gravatar John Belamaric 3-174/+21 2017-04-19Add fallthrough support for Kubernetes (#626)Gravatar John Belamaric 7-9/+122 * Add fallthrough support for Kubernetes This enables registering other services in the same zone as Kubernetes services. This also re-orders the middleware chain so that Kubernetes comes before other types, in order to make this work out-of-the-box. * Remove extra line 2017-04-18Tracing for gRPC Server (#619)Gravatar John Belamaric 6-11/+72 * Implements tracing in the native gRPC server * Undo some unnecessary changes * Properly revert trace/setup.go this time * Some very very basic tests * Remove warning for non-Trace middleware