Skip to content

Commit

Permalink
Add support for running on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
lfittl committed Jan 1, 2024
1 parent 776b2f8 commit 022fbd5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@ on:
branches:
- main
- "[0-9].x"
- windows-support

name: Continuous integration

jobs:
ci:
env:
RUSTFLAGS: ${{ matrix.rust == 'nightly' && '-Z sanitizer=leak' || '' }}
runs-on: ubuntu-latest
RUSTFLAGS: ${{ matrix.rust == 'nightly' && matrix.os == 'ubuntu-latest' && '-Z sanitizer=leak' || '' }}
strategy:
fail-fast: false
matrix:
rust:
- stable
- nightly
os:
- ubuntu-latest
- windows-latest
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
Expand Down
13 changes: 10 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let makefile_path = build_path.join("Makefile");
let out_header_path = out_dir.join(LIBRARY_NAME).with_extension("h");
let out_protobuf_path = out_dir.join("protobuf");
let target = env::var("TARGET").unwrap();

// Configure cargo through stdout
println!("cargo:rerun-if-changed={}", makefile_path.display()); // Includes version number
Expand All @@ -37,10 +38,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Compile the C library.
let mut make = Command::new("make");

make.env_remove("PROFILE").arg("-C").arg(&out_dir).arg("build");
if target.contains("msvc") {
make = Command::new("nmake");
make.arg("/F Makefile.msvc");
make.current_dir(&out_dir);
} else {
make.env_remove("PROFILE").arg("-C").arg(&out_dir).arg("build");

if env::var("PROFILE").unwrap() == "debug" {
make.arg("DEBUG=1");
if env::var("PROFILE").unwrap() == "debug" {
make.arg("DEBUG=1");
}
}

let status = make.stdin(Stdio::null()).stdout(Stdio::inherit()).stderr(Stdio::inherit()).status()?;
Expand Down
2 changes: 1 addition & 1 deletion libpg_query
Submodule libpg_query updated 88 files
+1 −0 .gitattributes
+38 −1 .github/workflows/ci.yml
+4 −0 .gitignore
+36 −36 Makefile
+108 −0 Makefile.msvc
+1 −1 examples/scan.c
+1 −1 protobuf/pg_query.proto
+65 −13 scripts/extract_source.rb
+16 −3 scripts/generate_fingerprint_outfuncs.rb
+11 −6 scripts/generate_protobuf_and_funcs.rb
+149 −0 scripts/pg_config_overrides.h
+0 −0 src/include/pg_query_enum_defs.c
+0 −0 src/include/pg_query_fingerprint_conds.c
+1 −1 src/include/pg_query_fingerprint_defs.c
+0 −0 src/include/pg_query_json_helper.c
+0 −0 src/include/pg_query_outfuncs_conds.c
+1 −1 src/include/pg_query_outfuncs_defs.c
+0 −0 src/include/pg_query_readfuncs_conds.c
+1 −1 src/include/pg_query_readfuncs_defs.c
+9 −0 src/pg_query.c
+4 −5 src/pg_query_fingerprint.c
+6 −0 src/pg_query_outfuncs_json.c
+1 −0 src/pg_query_outfuncs_protobuf.c
+1 −0 src/pg_query_outfuncs_protobuf_cpp.cc
+1 −1 src/pg_query_parse.c
+6 −4 src/pg_query_parse_plpgsql.c
+1 −0 src/pg_query_readfuncs_protobuf.c
+1 −1 src/pg_query_split.c
+0 −0 src/postgres/guc-file.c
+0 −33 src/postgres/include/common/ip.h
+1 −1 src/postgres/include/miscadmin.h
+1 −1 src/postgres/include/nodes/nodes.h
+3 −3 src/postgres/include/parser/parser.h
+136 −2 src/postgres/include/pg_config.h
+7 −7 src/postgres/include/pg_config_os.h
+1 −1 src/postgres/include/pgstat.h
+2 −2 src/postgres/include/pl_gram.h
+11 −11 src/postgres/include/plpgsql.h
+17 −0 src/postgres/include/port/atomics/arch-hppa.h
+101 −0 src/postgres/include/port/atomics/generic-msvc.h
+106 −0 src/postgres/include/port/atomics/generic-sunpro.h
+59 −0 src/postgres/include/port/win32.h
+3 −0 src/postgres/include/port/win32/arpa/inet.h
+1 −0 src/postgres/include/port/win32/dlfcn.h
+1 −0 src/postgres/include/port/win32/grp.h
+7 −0 src/postgres/include/port/win32/netdb.h
+3 −0 src/postgres/include/port/win32/netinet/in.h
+7 −0 src/postgres/include/port/win32/netinet/tcp.h
+3 −0 src/postgres/include/port/win32/pwd.h
+20 −0 src/postgres/include/port/win32/sys/resource.h
+3 −0 src/postgres/include/port/win32/sys/select.h
+26 −0 src/postgres/include/port/win32/sys/socket.h
+17 −0 src/postgres/include/port/win32/sys/un.h
+3 −0 src/postgres/include/port/win32/sys/wait.h
+34 −0 src/postgres/include/port/win32_msvc/dirent.h
+1 −0 src/postgres/include/port/win32_msvc/sys/file.h
+1 −0 src/postgres/include/port/win32_msvc/sys/param.h
+1 −0 src/postgres/include/port/win32_msvc/sys/time.h
+9 −0 src/postgres/include/port/win32_msvc/unistd.h
+3 −0 src/postgres/include/port/win32_msvc/utime.h
+594 −0 src/postgres/include/port/win32_port.h
+0 −20 src/postgres/include/postmaster/auxprocess.h
+0 −17 src/postgres/include/postmaster/fork_process.h
+1 −1 src/postgres/include/postmaster/postmaster.h
+1 −1 src/postgres/include/storage/ipc.h
+2 −2 src/postgres/include/tcop/tcopprot.h
+1 −1 src/postgres/include/utils/builtins.h
+3 −3 src/postgres/include/utils/elog.h
+4 −4 src/postgres/include/utils/guc.h
+2 −2 src/postgres/include/utils/memutils.h
+1 −1 src/postgres/include/utils/palloc.h
+0 −56 src/postgres/include/utils/pidfile.h
+0 −5,321 src/postgres/src_backend_nodes_copyfuncs.funcs.c
+0 −3,354 src/postgres/src_backend_nodes_equalfuncs.funcs.c
+38 −0 src/postgres/src_backend_nodes_nodes.c
+0 −2,220 src/postgres/src_backend_postmaster_postmaster.c
+17 −152 src/postgres/src_backend_utils_error_elog.c
+1 −1 src/postgres/src_backend_utils_init_globals.c
+8 −63 src/postgres/src_backend_utils_mb_mbutils.c
+0 −2 src/postgres/src_backend_utils_misc_guc_tables.c
+78 −4 src/postgres/src_port_pg_bitutils.c
+3 −3 src/postgres/src_port_snprintf.c
+79 −0 src/postgres/src_port_strlcpy.c
+0 −39 src/postgres/src_port_strnlen.c
+9 −5 test/deparse.c
+3 −1 test/fingerprint_tests.c
+6 −5 test/parse_plpgsql.c
+8 −10 test/split.c

0 comments on commit 022fbd5

Please sign in to comment.