integrate with mac build system and add skeleton

This commit is contained in:
Grant Limberg 2021-10-27 17:09:01 -07:00
parent 271dfc0d2b
commit c689c0bd8c
No known key found for this signature in database
GPG key ID: 2BA62CCABBB4095A
3 changed files with 29 additions and 13 deletions

View file

@ -103,8 +103,8 @@ mac-agent: FORCE
osdep/MacDNSHelper.o: osdep/MacDNSHelper.mm
$(CXX) $(CXXFLAGS) -c osdep/MacDNSHelper.mm -o osdep/MacDNSHelper.o
one: $(CORE_OBJS) $(ONE_OBJS) one.o mac-agent
$(CXX) $(CXXFLAGS) -o zerotier-one $(CORE_OBJS) $(ONE_OBJS) one.o $(LIBS)
one: $(CORE_OBJS) $(ONE_OBJS) one.o mac-agent zeroidc
$(CXX) $(CXXFLAGS) -o zerotier-one $(CORE_OBJS) $(ONE_OBJS) one.o $(LIBS) zeroidc/target/libzeroidc.a
# $(STRIP) zerotier-one
ln -sf zerotier-one zerotier-idtool
ln -sf zerotier-one zerotier-cli
@ -112,6 +112,13 @@ one: $(CORE_OBJS) $(ONE_OBJS) one.o mac-agent
zerotier-one: one
zeroidc: zeroidc/target/libzeroidc.a
zeroidc/target/libzeroidc.a:
cd zeroidc && cargo build --target=x86_64-apple-darwin --release
cd zeroidc && cargo build --target=aarch64-apple-darwin --release
cd zeroidc && lipo -create target/x86_64-apple-darwin/release/libzeroidc.a target/aarch64-apple-darwin/release/libzeroidc.a -output target/libzeroidc.a
central-controller:
make ARCH_FLAGS="-arch x86_64" ZT_CONTROLLER=1 one
@ -157,7 +164,7 @@ central-controller-docker: FORCE
docker build --no-cache -t registry.zerotier.com/zerotier-central/ztcentral-controller:${TIMESTAMP} -f ext/central-controller-docker/Dockerfile --build-arg git_branch=$(shell git name-rev --name-only HEAD) .
clean:
rm -rf MacEthernetTapAgent *.dSYM build-* *.a *.pkg *.dmg *.o node/*.o controller/*.o service/*.o osdep/*.o ext/http-parser/*.o $(CORE_OBJS) $(ONE_OBJS) zerotier-one zerotier-idtool zerotier-selftest zerotier-cli zerotier doc/node_modules zt1_update_$(ZT_BUILD_PLATFORM)_$(ZT_BUILD_ARCHITECTURE)_*
rm -rf MacEthernetTapAgent *.dSYM build-* *.a *.pkg *.dmg *.o node/*.o controller/*.o service/*.o osdep/*.o ext/http-parser/*.o $(CORE_OBJS) $(ONE_OBJS) zerotier-one zerotier-idtool zerotier-selftest zerotier-cli zerotier doc/node_modules zt1_update_$(ZT_BUILD_PLATFORM)_$(ZT_BUILD_ARCHITECTURE)_* zeroidc/target/
distclean: clean

View file

@ -9,7 +9,7 @@ fn main() {
let package_name = env::var("CARGO_PKG_NAME").unwrap();
let output_file = target_dir()
.join(format!("{}.hpp", package_name))
.join(format!("{}.h", package_name))
.display()
.to_string();

View file

@ -1,13 +1,22 @@
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}
#[repr(C)]
pub struct ZeroIDC {}
#[no_mangle]
pub extern "C" fn hello_rust() {
println!("Hello, Rust from C!")
pub extern "C" fn zeroidc_new() -> Box<ZeroIDC> {
Box::new(ZeroIDC{})
}
#[no_mangle]
pub extern "C" fn zeroidc_delete(_: Option<Box<ZeroIDC>>) {}
#[no_mangle]
pub extern "C" fn zeroidc_start(idc: &mut ZeroIDC) {
}
#[no_mangle]
pub extern "C" fn zeroidc_stop(idc: &mut ZeroIDC) {
}