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

Linker for Windows #538

Merged
merged 44 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
5bfd80b
validate Pointer incl. tests
flavioBachmann Jul 14, 2022
e9f6a16
using cargo clippy for coding style as well as cargo fmt
flavioBachmann Jul 14, 2022
66bc397
multi-type declarations incl. tests
flavioBachmann Jul 14, 2022
1de9bd9
Merge branch 'master' into master
ghaith Jul 14, 2022
a8a1b36
Merge branch 'PLC-lang:master' into master
flavioBachmann Jul 15, 2022
df59ecd
Merge branch 'PLC-lang:master' into master
flavioBachmann Jul 15, 2022
aef5948
subcommand as well as simple build description file
flavioBachmann Jul 19, 2022
292eef4
improved subcommand
flavioBachmann Jul 19, 2022
c230105
improved build description file
flavioBachmann Jul 20, 2022
4716576
adding libraries and parsing them
flavioBachmann Jul 22, 2022
6414dc5
documentation and minor improvements
flavioBachmann Jul 25, 2022
a33f5dd
Merge branch 'PLC-lang:master' into master
flavioBachmann Jul 25, 2022
aa511e1
Pull Request improvements
flavioBachmann Jul 26, 2022
1f97b5d
Merge branch 'master' of https://github.com/flavioBachmann/rusty
flavioBachmann Jul 26, 2022
5f1ec14
improvements from review
flavioBachmann Jul 27, 2022
aa20938
adding sysroot and target-triple as inline parameters for subcommand
flavioBachmann Jul 27, 2022
9c69f6a
merged
FlavioSchuricht Aug 3, 2022
738dcd3
Merge branch 'master' of https://github.com/flavioBachmann/rusty
FlavioSchuricht Aug 3, 2022
fc4b856
multi architecutre (target & sysroot)
FlavioSchuricht Aug 3, 2022
29bd0d2
typo
flavioBachmann Aug 3, 2022
1c42da2
one target without sysroot possible
flavioBachmann Aug 3, 2022
3803096
add debug messsage
flavioBachmann Aug 3, 2022
d555219
bug fix
flavioBachmann Aug 3, 2022
0f8930c
format issues
flavioBachmann Aug 3, 2022
4d18383
ignore one test for windows due to unavailable linker
flavioBachmann Aug 3, 2022
47da4a8
message for ignored test
flavioBachmann Aug 3, 2022
c6e3a0f
linker flag added, works for linux
flavioBachmann Aug 5, 2022
abe2fac
linker for windows
Aug 8, 2022
85bce83
ignore for windows tests
flavioBachmann Aug 8, 2022
53ddd1f
Review comments for multitarget
ghaith Aug 8, 2022
67f93f6
Remove common parameters from the subcommand
ghaith Aug 8, 2022
42d0bf1
Change the plcX.json to real names, remove unused md file, remove opt…
ghaith Aug 9, 2022
40ac46a
Merge branch 'multi_arch' into flavioBachmann/master
ghaith Aug 9, 2022
151cc35
Fixed test issues after merge
ghaith Aug 9, 2022
07b8956
Merge remote-tracking branch 'origin/master' into flavioBachmann/master
ghaith Aug 9, 2022
d4a9834
Reactivate a test, remove the new snap (accidental commit)
ghaith Aug 9, 2022
998cf42
Use tempfile while compiling
ghaith Aug 9, 2022
3d37502
Change the path of the called command, still fails on windows
ghaith Aug 9, 2022
6a7b5ea
windows tests works
flavioBachmann Aug 10, 2022
68ddd22
windows tests works
flavioBachmann Aug 10, 2022
17adcb8
windows linker finds libs in build directory
flavioBachmann Aug 10, 2022
0e4becb
Merge branch 'master' of https://github.com/flavioBachmann/rusty
flavioBachmann Aug 10, 2022
189fc25
Merge branch 'master' of https://github.com/flavioBachmann/rusty
flavioBachmann Aug 10, 2022
8c02953
Merge branch 'master' of https://github.com/flavioBachmann/rusty
flavioBachmann Aug 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ serde_json = "1"
toml = "0.5"
lazy_static = "1.4.0"
shell-words = "1.1.0"
which = "4.2.5"
tempfile = "3"

[dev-dependencies]
num = "0.4"
Expand Down
32 changes: 8 additions & 24 deletions src/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::diagnostics::Diagnostic;
use crate::diagnostics::ErrNo;
use crate::make_absolute;
use crate::resolve_environment_variables;
use crate::FormatOption;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -40,17 +38,21 @@ impl Project {
files: self
.files
.into_iter()
.map(|it| make_absolute(&it, root))
.map(|it| if it.is_absolute() { it } else { root.join(it) })
.collect(),
libraries: self
.libraries
.into_iter()
.map(|it| Libraries {
path: make_absolute(&it.path, root),
path: if it.path.is_absolute() {
it.path
} else {
root.join(it.path)
},
include_path: it
.include_path
.into_iter()
.map(|it| make_absolute(&it, root))
.map(|it| if it.is_absolute() { it } else { root.join(it) })
.collect(),
..it
})
Expand All @@ -67,34 +69,16 @@ impl Project {
}
}

pub fn get_project_from_file(build_config: &Path, root: &Path) -> Result<Project, Diagnostic> {
pub fn get_project_from_file(build_config: &Path) -> Result<Project, Diagnostic> {
//read from file
let content = fs::read_to_string(build_config)?;

//convert file to Object
let project = Project::try_parse(&content)?;

check_libs_exist(&project.libraries, root)?;
Ok(project)
}

fn check_libs_exist(libraries: &[Libraries], root: &Path) -> Result<(), Diagnostic> {
for library in libraries {
let path = root.join(&library.path);
let path = path.join(&format!("lib{}.so", library.name));
if !path.is_file() {
return Err(Diagnostic::GeneralError {
message: format!(
"The library could not be found at : {}",
path.to_string_lossy()
),
err_no: ErrNo::general__io_err,
});
}
}
Ok(())
}

#[cfg(test)]
mod tests {
use std::path::PathBuf;
Expand Down
14 changes: 13 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ pub struct CompileParameters {
)]
pub error_format: ErrorFormat,

#[clap(
name = "linker",
long,
help = "Define a custom (cc compatible) linker command",
global = true
)]
pub linker: Option<String>,

#[clap(subcommand)]
pub commands: Option<SubCommands>,
}
Expand Down Expand Up @@ -624,7 +632,9 @@ mod cli_tests {
"--target",
"targettest",
"--target",
"othertarget"
"othertarget",
"--linker",
"cc"
))
.unwrap();
if let Some(commands) = parameters.commands {
Expand All @@ -633,6 +643,7 @@ mod cli_tests {
build_config,
build_location,
lib_location,
..
} => {
assert_eq!(build_config, Some("src/ProjectPlc.json".to_string()));
assert_eq!(build_location, Some("bin/build".to_string()));
Expand All @@ -647,6 +658,7 @@ mod cli_tests {
parameters.target,
vec!["targettest".to_string(), "othertarget".to_string()]
);
assert_eq!(parameters.linker, Some("cc".to_string()));
}
}

Expand Down
Loading