Skip to content

Commit

Permalink
refactor(build): move crate out dir out of source
Browse files Browse the repository at this point in the history
  • Loading branch information
declantsien committed Feb 26, 2023
1 parent c8ee95f commit dae7cc7
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 40 deletions.
2 changes: 1 addition & 1 deletion rust_src/crates/git/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ extern crate lisp_util;
mod repository;

#[cfg(not(test))]
include!(concat!(env!("CARGO_MANIFEST_DIR"), "/out/c_exports.rs"));
include!(concat!(env!("OUT_DIR"), "/c_exports.rs"));
5 changes: 1 addition & 4 deletions rust_src/crates/git/src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,4 @@ pub fn git_init(path: LispStringRef) -> LispStringRef {
}
}

include!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/out/repository_exports.rs"
));
include!(concat!(env!("OUT_DIR"), "/repository_exports.rs"));
2 changes: 1 addition & 1 deletion rust_src/crates/js/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ mod javascript;
mod subcommands;

#[cfg(not(test))]
include!(concat!(env!("CARGO_MANIFEST_DIR"), "/out/c_exports.rs"));
include!(concat!(env!("OUT_DIR"), "/c_exports.rs"));
2 changes: 1 addition & 1 deletion rust_src/crates/lsp_json/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ extern crate lisp_util;
pub mod parsing;

#[cfg(not(test))]
include!(concat!(env!("CARGO_MANIFEST_DIR"), "/out/c_exports.rs"));
include!(concat!(env!("OUT_DIR"), "/c_exports.rs"));
5 changes: 1 addition & 4 deletions rust_src/crates/lsp_json/src/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,4 @@ fn init_syms() {
def_lisp_sym!(Qarray, "array");
}

include!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/out/parsing_exports.rs"
));
include!(concat!(env!("OUT_DIR"), "/parsing_exports.rs"));
2 changes: 1 addition & 1 deletion rust_src/crates/ng_async/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ extern crate lisp_util;
pub mod ng_async;

#[cfg(not(test))]
include!(concat!(env!("CARGO_MANIFEST_DIR"), "/out/c_exports.rs"));
include!(concat!(env!("OUT_DIR"), "/c_exports.rs"));
5 changes: 1 addition & 4 deletions rust_src/crates/ng_async/src/ng_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,4 @@ fn init_syms() {
def_lisp_sym!(QCoutchannel, "outchannel");
}

include!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/out/ng_async_exports.rs"
));
include!(concat!(env!("OUT_DIR"), "/ng_async_exports.rs"));
2 changes: 1 addition & 1 deletion rust_src/crates/ng_module/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ extern crate lisp_util;
mod ng_module;

#[cfg(not(test))]
include!(concat!(env!("CARGO_MANIFEST_DIR"), "/out/c_exports.rs"));
include!(concat!(env!("OUT_DIR"), "/c_exports.rs"));
5 changes: 1 addition & 4 deletions rust_src/crates/ng_module/src/ng_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,4 @@ unsafe extern "C" fn ng_module_access_current_buffer_contents(
*after_gap_size = z_byte - gpt_byte;
}

include!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/out/ng_module_exports.rs"
));
include!(concat!(env!("OUT_DIR"), "/ng_module_exports.rs"));
2 changes: 1 addition & 1 deletion rust_src/crates/webrender/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ pub use crate::platform::macos;
pub use crate::wrterm::{tip_frame, wr_display_list};

#[cfg(not(test))]
include!(concat!(env!("CARGO_MANIFEST_DIR"), "/out/c_exports.rs"));
include!(concat!(env!("OUT_DIR"), "/c_exports.rs"));
5 changes: 1 addition & 4 deletions rust_src/crates/webrender/src/wrterm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,4 @@ pub extern "C" fn syms_of_wrterm() {
syms_of_wrfont();
}

include!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/out/wrterm_exports.rs"
));
include!(concat!(env!("OUT_DIR"), "/wrterm_exports.rs"));
9 changes: 5 additions & 4 deletions rust_src/ng-bindgen/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,9 @@ fn build_ignored_crates(path: &PathBuf) -> bool {
pub fn generate_crate_exports(path: &PathBuf) -> Result<(), BuildError> {
let modules = find_crate_modules(&path.join("src"))?;

let _ = fs::create_dir(path.join("out"));
let mut out_file = File::create(path.join("out").join("c_exports.rs"))?;
let out_path: PathBuf = [&env_var("OUT_DIR")].iter().collect();
let mut out_file = File::create(out_path.join("c_exports.rs"))?;

generate_crate_c_export_file(&out_file, &modules)?;

let crate_name = get_crate_name(path);
Expand All @@ -506,7 +507,7 @@ pub fn generate_crate_exports(path: &PathBuf) -> Result<(), BuildError> {
crate_name
)?;

write_lisp_fns(&path.join("out"), &out_file, &modules)?;
write_lisp_fns(&out_path, &out_file, &modules)?;

write!(out_file, "}}\n")?;

Expand All @@ -516,7 +517,7 @@ pub fn generate_crate_exports(path: &PathBuf) -> Result<(), BuildError> {
fn get_crate_name(path: &PathBuf) -> String {
let manifest = Manifest::from_path(path.join("Cargo.toml")).unwrap();
match manifest.package {
Some(package) => package.name,
Some(package) => package.name.replace('-', "_"),
None => path_as_str(path.file_name()).to_string(),
}
}
Expand Down
11 changes: 1 addition & 10 deletions src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -737,12 +737,6 @@ gl-stamp: $(libsrc)/make-docfile$(EXEEXT) $(GLOBAL_SOURCES)
globals.h: gl-stamp; @true

rust_srcdir=$(top_srcdir)/rust_src
RUSTFLAGS_FILE=$(top_srcdir)/target/.rustflags
$(RUSTFLAGS_FILE) : FORCE
mkdir -p $(dir $@)
echo "$(CARGO_FLAGS) $(RUSTFLAGS)" > $@.tmp
diff -q $@ $@.tmp || cp $@.tmp $@
rm -f $@.tmp

HEADERS=$(wildcard $(srcdir)/*.h)

Expand All @@ -755,12 +749,9 @@ LIBEMACSNG_CARGO_FILES = $(sort $(shell find ${rust_srcdir} -type f \
-name 'Cargo.*' -o -name "build.rs"))

$(LIBEMACSNG_ARCHIVE) $(LIBEMACSNG_DEP-INFO): FORCE
touch $@
CARGO_BUILD_DEP_INFO_BASEDIR=$(realpath $(top_srcdir)) \
RUSTFLAGS="$(RUSTFLAGS)" \
EMACS_CFLAGS="$(EMACS_CFLAGS)" \
$(CARGO_BUILD) $(CARGO_FLAGS) --manifest-path $(cargo_manifest)
sed -i~ 's/rust_src\//..\/rust_src\//g' $(LIBEMACSNG_DEP-INFO)

clippy:
RUSTFLAGS="$(RUSTFLAGS)" \
Expand Down Expand Up @@ -800,7 +791,7 @@ endif
## existence when setting Vinstallation_directory (FIXME?).
## This goes on to affect various things, and the emacs binary fails
## to start if Vinstallation_directory has the wrong value.
temacs$(EXEEXT): $(LIBXMENU) $(ALLOBJS) $(LIBEMACSNG_ARCHIVE) $(RUSTFLAGS_FILE) $(LIBEGNU_ARCHIVE) $(EMACSRES) \
temacs$(EXEEXT): $(LIBXMENU) $(ALLOBJS) $(LIBEMACSNG_ARCHIVE) $(LIBEGNU_ARCHIVE) $(EMACSRES) \
$(charsets) $(charscript) ${emoji-zwj} $(MAKE_PDUMPER_FINGERPRINT)
ifeq ($(HAVE_BE_APP),yes)
$(AM_V_CXXLD)$(CXX) -o [email protected] \
Expand Down

0 comments on commit dae7cc7

Please sign in to comment.