Skip to content

Commit

Permalink
chore: fixup OS detection
Browse files Browse the repository at this point in the history
Signed-off-by: Ana Hobden <[email protected]>
  • Loading branch information
Hoverbear committed Sep 21, 2021
1 parent 9216312 commit c89ac3a
Show file tree
Hide file tree
Showing 19 changed files with 73 additions and 54 deletions.
6 changes: 3 additions & 3 deletions cargo-pgx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -560,10 +560,11 @@ The flags are typically set by a linker script:
# Auto-generated by pgx. You may edit this, or delete it to have a new one created.
if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
if [[ $TARGET == "x86_64-apple-darwin" ]] || [[ $TARGET == "aarch64-apple-darwin" ]]; then
UNAME=$(uname)
if [[ $UNAME == "Darwin" ]]; then
TEMP=$(mktemp pgx-XXX)
echo "*_pgx_internals_*" > ${TEMP}
gcc -exported_symbols_list=${TEMP} $@
gcc -exported_symbols_list ${TEMP} $@
rm -rf ${TEMP}
else
TEMP=$(mktemp pgx-XXX)
Expand All @@ -574,7 +575,6 @@ if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
else
gcc -Wl,-undefined,dynamic_lookup $@
fi
```
Which would be configured in `.cargo/config` for supported targets:
Expand Down
8 changes: 4 additions & 4 deletions cargo-pgx/src/commands/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub(crate) fn install_extension(
additional_features,
&extdir,
&base_directory,
);
)?;

println!("{} installing {}", " Finished".bold().green(), extname);
Ok(())
Expand Down Expand Up @@ -130,7 +130,7 @@ fn copy_sql_files(
additional_features: Vec<&str>,
extdir: &PathBuf,
base_directory: &PathBuf,
) {
) -> Result<(), std::io::Error> {
let mut dest = base_directory.clone();
dest.push(extdir);

Expand All @@ -147,8 +147,7 @@ fn copy_sql_files(
None,
false,
true,
)
.unwrap();
)?;
let written = std::fs::read_to_string(&dest).unwrap();
let written = filter_contents(written);
std::fs::write(&dest, written).unwrap();
Expand All @@ -169,6 +168,7 @@ fn copy_sql_files(
}
}
}
Ok(())
}

pub(crate) fn find_library_file(extname: &str, is_release: bool) -> PathBuf {
Expand Down
2 changes: 1 addition & 1 deletion cargo-pgx/src/commands/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub(crate) fn generate_schema(
println!("{} SQL entities", " Discovering".bold().green(),);
let dsym_path = sql_gen_path.resolve_dsym();
let buffer = ByteView::open(dsym_path.as_deref().unwrap_or(&sql_gen_path))?;
let archive = Archive::parse(&buffer).unwrap();
let archive = Archive::parse(&buffer).expect("Could not parse archive");

let mut fns_to_call = Vec::new();
for object in archive.objects() {
Expand Down
7 changes: 4 additions & 3 deletions cargo-pgx/src/templates/pgx-linker-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# Auto-generated by pgx. You may edit this, or delete it to have a new one created.

if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
if [[ $TARGET == "x86_64-apple-darwin" ]] || [[ $TARGET == "aarch64-apple-darwin" ]]; then
UNAME=$(uname)
if [[ $UNAME == "Darwin" ]]; then
TEMP=$(mktemp pgx-XXX)
echo "*_pgx_internals_*" > ${TEMP}
gcc -exported_symbols_list=${TEMP} $@
gcc -exported_symbols_list ${TEMP} $@
rm -rf ${TEMP}
else
TEMP=$(mktemp pgx-XXX)
Expand All @@ -15,4 +16,4 @@ if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
fi
else
gcc -Wl,-undefined,dynamic_lookup $@
fi
fi
7 changes: 4 additions & 3 deletions pgx-examples/aggregate/.cargo/pgx-linker-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# Auto-generated by pgx. You may edit this, or delete it to have a new one created.

if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
if [[ $TARGET == "x86_64-apple-darwin" ]] || [[ $TARGET == "aarch64-apple-darwin" ]]; then
UNAME=$(uname)
if [[ $UNAME == "Darwin" ]]; then
TEMP=$(mktemp pgx-XXX)
echo "*_pgx_internals_*" > ${TEMP}
gcc -exported_symbols_list=${TEMP} $@
gcc -exported_symbols_list ${TEMP} $@
rm -rf ${TEMP}
else
TEMP=$(mktemp pgx-XXX)
Expand All @@ -15,4 +16,4 @@ if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
fi
else
gcc -Wl,-undefined,dynamic_lookup $@
fi
fi
7 changes: 4 additions & 3 deletions pgx-examples/arrays/.cargo/pgx-linker-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# Auto-generated by pgx. You may edit this, or delete it to have a new one created.

if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
if [[ $TARGET == "x86_64-apple-darwin" ]] || [[ $TARGET == "aarch64-apple-darwin" ]]; then
UNAME=$(uname)
if [[ $UNAME == "Darwin" ]]; then
TEMP=$(mktemp pgx-XXX)
echo "*_pgx_internals_*" > ${TEMP}
gcc -exported_symbols_list=${TEMP} $@
gcc -exported_symbols_list ${TEMP} $@
rm -rf ${TEMP}
else
TEMP=$(mktemp pgx-XXX)
Expand All @@ -15,4 +16,4 @@ if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
fi
else
gcc -Wl,-undefined,dynamic_lookup $@
fi
fi
7 changes: 4 additions & 3 deletions pgx-examples/bytea/.cargo/pgx-linker-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# Auto-generated by pgx. You may edit this, or delete it to have a new one created.

if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
if [[ $TARGET == "x86_64-apple-darwin" ]] || [[ $TARGET == "aarch64-apple-darwin" ]]; then
UNAME=$(uname)
if [[ $UNAME == "Darwin" ]]; then
TEMP=$(mktemp pgx-XXX)
echo "*_pgx_internals_*" > ${TEMP}
gcc -exported_symbols_list=${TEMP} $@
gcc -exported_symbols_list ${TEMP} $@
rm -rf ${TEMP}
else
TEMP=$(mktemp pgx-XXX)
Expand All @@ -15,4 +16,4 @@ if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
fi
else
gcc -Wl,-undefined,dynamic_lookup $@
fi
fi
7 changes: 4 additions & 3 deletions pgx-examples/custom_sql/.cargo/pgx-linker-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# Auto-generated by pgx. You may edit this, or delete it to have a new one created.

if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
if [[ $TARGET == "x86_64-apple-darwin" ]] || [[ $TARGET == "aarch64-apple-darwin" ]]; then
UNAME=$(uname)
if [[ $UNAME == "Darwin" ]]; then
TEMP=$(mktemp pgx-XXX)
echo "*_pgx_internals_*" > ${TEMP}
gcc -exported_symbols_list=${TEMP} $@
gcc -exported_symbols_list ${TEMP} $@
rm -rf ${TEMP}
else
TEMP=$(mktemp pgx-XXX)
Expand All @@ -15,4 +16,4 @@ if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
fi
else
gcc -Wl,-undefined,dynamic_lookup $@
fi
fi
7 changes: 4 additions & 3 deletions pgx-examples/custom_types/.cargo/pgx-linker-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# Auto-generated by pgx. You may edit this, or delete it to have a new one created.

if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
if [[ $TARGET == "x86_64-apple-darwin" ]] || [[ $TARGET == "aarch64-apple-darwin" ]]; then
UNAME=$(uname)
if [[ $UNAME == "Darwin" ]]; then
TEMP=$(mktemp pgx-XXX)
echo "*_pgx_internals_*" > ${TEMP}
gcc -exported_symbols_list=${TEMP} $@
gcc -exported_symbols_list ${TEMP} $@
rm -rf ${TEMP}
else
TEMP=$(mktemp pgx-XXX)
Expand All @@ -15,4 +16,4 @@ if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
fi
else
gcc -Wl,-undefined,dynamic_lookup $@
fi
fi
7 changes: 4 additions & 3 deletions pgx-examples/errors/.cargo/pgx-linker-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# Auto-generated by pgx. You may edit this, or delete it to have a new one created.

if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
if [[ $TARGET == "x86_64-apple-darwin" ]] || [[ $TARGET == "aarch64-apple-darwin" ]]; then
UNAME=$(uname)
if [[ $UNAME == "Darwin" ]]; then
TEMP=$(mktemp pgx-XXX)
echo "*_pgx_internals_*" > ${TEMP}
gcc -exported_symbols_list=${TEMP} $@
gcc -exported_symbols_list ${TEMP} $@
rm -rf ${TEMP}
else
TEMP=$(mktemp pgx-XXX)
Expand All @@ -15,4 +16,4 @@ if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
fi
else
gcc -Wl,-undefined,dynamic_lookup $@
fi
fi
7 changes: 4 additions & 3 deletions pgx-examples/operators/.cargo/pgx-linker-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# Auto-generated by pgx. You may edit this, or delete it to have a new one created.

if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
if [[ $TARGET == "x86_64-apple-darwin" ]] || [[ $TARGET == "aarch64-apple-darwin" ]]; then
UNAME=$(uname)
if [[ $UNAME == "Darwin" ]]; then
TEMP=$(mktemp pgx-XXX)
echo "*_pgx_internals_*" > ${TEMP}
gcc -exported_symbols_list=${TEMP} $@
gcc -exported_symbols_list ${TEMP} $@
rm -rf ${TEMP}
else
TEMP=$(mktemp pgx-XXX)
Expand All @@ -15,4 +16,4 @@ if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
fi
else
gcc -Wl,-undefined,dynamic_lookup $@
fi
fi
7 changes: 4 additions & 3 deletions pgx-examples/schemas/.cargo/pgx-linker-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# Auto-generated by pgx. You may edit this, or delete it to have a new one created.

if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
if [[ $TARGET == "x86_64-apple-darwin" ]] || [[ $TARGET == "aarch64-apple-darwin" ]]; then
UNAME=$(uname)
if [[ $UNAME == "Darwin" ]]; then
TEMP=$(mktemp pgx-XXX)
echo "*_pgx_internals_*" > ${TEMP}
gcc -exported_symbols_list=${TEMP} $@
gcc -exported_symbols_list ${TEMP} $@
rm -rf ${TEMP}
else
TEMP=$(mktemp pgx-XXX)
Expand All @@ -15,4 +16,4 @@ if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
fi
else
gcc -Wl,-undefined,dynamic_lookup $@
fi
fi
7 changes: 4 additions & 3 deletions pgx-examples/shmem/.cargo/pgx-linker-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# Auto-generated by pgx. You may edit this, or delete it to have a new one created.

if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
if [[ $TARGET == "x86_64-apple-darwin" ]] || [[ $TARGET == "aarch64-apple-darwin" ]]; then
UNAME=$(uname)
if [[ $UNAME == "Darwin" ]]; then
TEMP=$(mktemp pgx-XXX)
echo "*_pgx_internals_*" > ${TEMP}
gcc -exported_symbols_list=${TEMP} $@
gcc -exported_symbols_list ${TEMP} $@
rm -rf ${TEMP}
else
TEMP=$(mktemp pgx-XXX)
Expand All @@ -15,4 +16,4 @@ if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
fi
else
gcc -Wl,-undefined,dynamic_lookup $@
fi
fi
7 changes: 4 additions & 3 deletions pgx-examples/spi/.cargo/pgx-linker-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# Auto-generated by pgx. You may edit this, or delete it to have a new one created.

if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
if [[ $TARGET == "x86_64-apple-darwin" ]] || [[ $TARGET == "aarch64-apple-darwin" ]]; then
UNAME=$(uname)
if [[ $UNAME == "Darwin" ]]; then
TEMP=$(mktemp pgx-XXX)
echo "*_pgx_internals_*" > ${TEMP}
gcc -exported_symbols_list=${TEMP} $@
gcc -exported_symbols_list ${TEMP} $@
rm -rf ${TEMP}
else
TEMP=$(mktemp pgx-XXX)
Expand All @@ -15,4 +16,4 @@ if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
fi
else
gcc -Wl,-undefined,dynamic_lookup $@
fi
fi
7 changes: 4 additions & 3 deletions pgx-examples/srf/.cargo/pgx-linker-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# Auto-generated by pgx. You may edit this, or delete it to have a new one created.

if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
if [[ $TARGET == "x86_64-apple-darwin" ]] || [[ $TARGET == "aarch64-apple-darwin" ]]; then
UNAME=$(uname)
if [[ $UNAME == "Darwin" ]]; then
TEMP=$(mktemp pgx-XXX)
echo "*_pgx_internals_*" > ${TEMP}
gcc -exported_symbols_list=${TEMP} $@
gcc -exported_symbols_list ${TEMP} $@
rm -rf ${TEMP}
else
TEMP=$(mktemp pgx-XXX)
Expand All @@ -15,4 +16,4 @@ if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
fi
else
gcc -Wl,-undefined,dynamic_lookup $@
fi
fi
7 changes: 4 additions & 3 deletions pgx-examples/strings/.cargo/pgx-linker-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# Auto-generated by pgx. You may edit this, or delete it to have a new one created.

if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
if [[ $TARGET == "x86_64-apple-darwin" ]] || [[ $TARGET == "aarch64-apple-darwin" ]]; then
UNAME=$(uname)
if [[ $UNAME == "Darwin" ]]; then
TEMP=$(mktemp pgx-XXX)
echo "*_pgx_internals_*" > ${TEMP}
gcc -exported_symbols_list=${TEMP} $@
gcc -exported_symbols_list ${TEMP} $@
rm -rf ${TEMP}
else
TEMP=$(mktemp pgx-XXX)
Expand All @@ -15,4 +16,4 @@ if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
fi
else
gcc -Wl,-undefined,dynamic_lookup $@
fi
fi
7 changes: 4 additions & 3 deletions pgx-examples/triggers/.cargo/pgx-linker-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# Auto-generated by pgx. You may edit this, or delete it to have a new one created.

if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
if [[ $TARGET == "x86_64-apple-darwin" ]] || [[ $TARGET == "aarch64-apple-darwin" ]]; then
UNAME=$(uname)
if [[ $UNAME == "Darwin" ]]; then
TEMP=$(mktemp pgx-XXX)
echo "*_pgx_internals_*" > ${TEMP}
gcc -exported_symbols_list=${TEMP} $@
gcc -exported_symbols_list ${TEMP} $@
rm -rf ${TEMP}
else
TEMP=$(mktemp pgx-XXX)
Expand All @@ -15,4 +16,4 @@ if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
fi
else
gcc -Wl,-undefined,dynamic_lookup $@
fi
fi
7 changes: 4 additions & 3 deletions pgx-tests/.cargo/pgx-linker-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# Auto-generated by pgx. You may edit this, or delete it to have a new one created.

if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
if [[ $TARGET == "x86_64-apple-darwin" ]] || [[ $TARGET == "aarch64-apple-darwin" ]]; then
UNAME=$(uname)
if [[ $UNAME == "Darwin" ]]; then
TEMP=$(mktemp pgx-XXX)
echo "*_pgx_internals_*" > ${TEMP}
gcc -exported_symbols_list=${TEMP} $@
gcc -exported_symbols_list ${TEMP} $@
rm -rf ${TEMP}
else
TEMP=$(mktemp pgx-XXX)
Expand All @@ -15,4 +16,4 @@ if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
fi
else
gcc -Wl,-undefined,dynamic_lookup $@
fi
fi
6 changes: 5 additions & 1 deletion pgx/src/datum/sql_entity_graph/pgx_sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,11 @@ fn connect_externs(
"Could not fetch Builtin Type {}.",
iterated_return.1
));
tracing::debug!(from = %item.rust_identifier(), to = iterated_return.1, "Adding Extern after BuiltIn Type (due to return) edge");
tracing::debug!(
from = %item.rust_identifier(),
to = iterated_return.1,
"Adding Extern after BuiltIn Type (due to return) edge"
);
graph.add_edge(
*builtin_index,
index,
Expand Down

0 comments on commit c89ac3a

Please sign in to comment.