-
-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #197 from zombodb/oh-no-mac-resolution
Enable new SQL generator on Mac
- Loading branch information
Showing
54 changed files
with
301 additions
and
147 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
// Copyright 2020 ZomboDB, LLC <[email protected]>. All rights reserved. Use of this source code is | ||
// governed by the MIT license that can be found in the LICENSE file. | ||
|
||
use std::io::Write; | ||
use std::path::PathBuf; | ||
use std::{ | ||
io::Write, | ||
path::PathBuf, | ||
os::unix::fs::PermissionsExt, | ||
}; | ||
|
||
pub(crate) fn create_crate_template( | ||
path: PathBuf, | ||
|
@@ -13,6 +16,8 @@ pub(crate) fn create_crate_template( | |
create_control_file(&path, name)?; | ||
create_cargo_toml(&path, name)?; | ||
create_dotcargo_config(&path, name)?; | ||
create_linker_script(&path, name)?; | ||
create_sql_generator_binary(&path, name)?; | ||
create_lib_rs(&path, name, is_bgworker)?; | ||
create_git_ignore(&path, name)?; | ||
|
||
|
@@ -68,6 +73,45 @@ fn create_dotcargo_config(path: &PathBuf, _name: &str) -> Result<(), std::io::Er | |
Ok(()) | ||
} | ||
|
||
fn create_linker_script(path: &PathBuf, _name: &str) -> Result<(), std::io::Error> { | ||
let mut filename = path.clone(); | ||
|
||
filename.push(".cargo"); | ||
|
||
std::fs::create_dir_all(&filename)?; | ||
|
||
filename.push("pgx-linker-script.sh"); | ||
let mut file = std::fs::File::create(&filename)?; | ||
|
||
file.write_all(include_bytes!("../templates/pgx-linker-script.sh"))?; | ||
drop(file); | ||
|
||
let mut perms = std::fs::metadata(&filename)?.permissions(); | ||
perms.set_mode(0o755); | ||
std::fs::set_permissions(&filename, perms)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
fn create_sql_generator_binary(path: &PathBuf, name: &str) -> Result<(), std::io::Error> { | ||
let mut filename = path.clone(); | ||
|
||
filename.push("src"); | ||
filename.push("bin"); | ||
|
||
std::fs::create_dir_all(&filename)?; | ||
|
||
filename.push("sql-generator.rs"); | ||
let mut file = std::fs::File::create(filename)?; | ||
|
||
file.write_all(format!("\ | ||
/* Auto-generated by pgx. You may edit this, or delete it to have a new one created. */\n\ | ||
pgx::pg_binary_magic!({});\n\ | ||
", name).as_bytes())?; | ||
|
||
Ok(()) | ||
} | ||
|
||
fn create_lib_rs(path: &PathBuf, name: &str, is_bgworker: bool) -> Result<(), std::io::Error> { | ||
let mut filename = path.clone(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.