SUPERAndroidAnalyzer / super

Secure, Unified, Powerful and Extensible Rust Android Analyzer
https://superanalyzer.rocks/
GNU General Public License v3.0
421 stars 59 forks source link

Implement tap completion script generation #96

Closed panicbit closed 8 years ago

panicbit commented 8 years ago

This does not include packaging of the completion scripts.

panicbit commented 8 years ago

I'll change the generate_cli stuff then.

Razican commented 8 years ago

So, for packaging: cargo-deb uses the Cargo.toml file, where you can specify any file that will exist after calling cargo build --release and where they will be stored in the system path.

I've been researching with @Br1oP and seems that for Bash in Debian/RedHat based distributions, scripts go in /usr/share/bash-completion/completions/.

For ZSH they go in /usr/share/zsh/site-functions/, and for FISH they go in /usr/share/fish/vendor_completions.d. For the cargo-deb implementation it's straightforward, for the RPM is not so easy, but I can explain it briefly:

The spec file is in rpmbuild/super.spec. In the %install section you will need to first create the directories:

mkdir -p %{buildroot}%{_datadir}/bash-completion/completions
mkdir -p %{buildroot}%{_datadir}/fish/vendor_completions.d
mkdir -p %{buildroot}%{_datadir}/zsh/site-functions (only once we have ZSH working)

And then install the actual files, but I don't get them generated in my setup with your branch :/

Br1oP commented 8 years ago

For ZSH, it might be different depending on the distro. For example, in Debian Jessie I think it is /usr/share/zsh/vendor-completions/. We should look into it in more detail.

Razican commented 8 years ago

OK, now I understand where the files are generated, in target/debug/build/super-{hash}/out/. Which is not really useful, since it will change in each build. But it can be changed. Instead of using env!("OUT_DIR"), we should use env!("CARGO_TARGET_DIR"). More info. They will be generated in target/release.

panicbit commented 8 years ago

@Razican Turns out that CARGO_TARGET_DIR is a variable that you can pass to cargo. For buildscripts there is only really OUT_DIR, so I did OUT_DIR/../../. The scripts will now be generated in target/release/build/. See http://doc.crates.io/environment-variables.html#environment-variables-cargo-sets-for-build-scripts

Razican commented 8 years ago

@panicbit could that have any issue in platforms other than Unix? Maybe it would be better to create a PathBuf and pop the last two components?

panicbit commented 8 years ago

It's probably not an issue, but I agree, we should use Path.

panicbit commented 8 years ago

Done :smiley:

panicbit commented 8 years ago

Yeah, I'll take a look as soon as I'm off the train :)

panicbit commented 8 years ago

Done :)