Skip to content

Commit

Permalink
Updated makefile to include 'copy' target and use debug build for em_…
Browse files Browse the repository at this point in the history
…proxy binaries (#3)
  • Loading branch information
mahee96 authored Dec 8, 2024
1 parent f0b28a1 commit 37eafbf
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ em_proxy.h
/em_proxy.xcframework
/em_proxy.xcframework.zip
/include
*.a
77 changes: 50 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,82 @@ add_targets:
@echo "add_targets"
rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios

build:

compile:
@echo "build aarch64-apple-ios"
@cargo build --release --target aarch64-apple-ios
@# @cargo build --release --target aarch64-apple-ios
@cargo build --target aarch64-apple-ios
@echo "lipo"
@lipo -create \
@# @lipo -create \
-output target/lib$(TARGET)-ios.a \
target/aarch64-apple-ios/release/lib$(TARGET).a
@lipo -create \
-output target/lib$(TARGET)-ios.a \
target/aarch64-apple-ios/debug/lib$(TARGET).a

@echo "build aarch64-apple-ios-sim"
@cargo build --release --target aarch64-apple-ios-sim
@# @cargo build --release --target aarch64-apple-ios-sim
@cargo build --target aarch64-apple-ios-sim

@echo "build x86_64-apple-ios"
@cargo build --release --target x86_64-apple-ios
@# @cargo build --release --target x86_64-apple-ios
@cargo build --target x86_64-apple-ios

@lipo -create \
@# @lipo -create \
-output target/lib$(TARGET)-sim.a \
target/aarch64-apple-ios-sim/release/lib$(TARGET).a \
target/x86_64-apple-ios/release/lib$(TARGET).a
@lipo -create \
-output target/lib$(TARGET)-sim.a \
target/aarch64-apple-ios-sim/debug/lib$(TARGET).a \
target/x86_64-apple-ios/debug/lib$(TARGET).a

copy:
@echo "copying binaries:"
@if [ -d "target" ]; then \
echo " target/lib$(TARGET)-sim.a -> lib${TARGET}-sim.a"; \
cp "target/lib$(TARGET)-sim.a" "lib${TARGET}-sim.a"; \
echo " target/lib$(TARGET)-ios.a -> lib${TARGET}-ios.a"; \
cp "target/lib$(TARGET)-ios.a" "lib${TARGET}-ios.a"; \
fi

build: compile copy

clean:
@echo "clean"
@if [ -d "include" ]; then \
echo "cleaning include"; \
rm -r include; \
fi
rm -r include; \
fi
@if [ -d "target" ]; then \
echo "cleaning target"; \
rm -r target; \
fi
rm -r target; \
fi
@if [ -d "$(TARGET).xcframework" ]; then \
echo "cleaning $(TARGET).xcframework"; \
rm -r $(TARGET).xcframework; \
fi
rm -r $(TARGET).xcframework; \
fi
@if [ -f "$(TARGET).xcframework.zip" ]; then \
echo "cleaning $(TARGET).xcframework.zip"; \
rm $(TARGET).xcframework.zip; \
fi
rm $(TARGET).xcframework.zip; \
fi
@rm -f *.a

xcframework: build
@echo "xcframework"

@if [ -d "include" ]; then \
echo "cleaning include"; \
rm -rf include; \
fi
rm -rf include; \
fi
@mkdir include
@mkdir include/$(TARGET)
@cp $(TARGET).h include/$(TARGET)
@cp module.modulemap include/$(TARGET)

@if [ -d "$(TARGET).xcframework" ]; then \
echo "cleaning $(TARGET).xcframework"; \
rm -rf $(TARGET).xcframework; \
rm -rf $(TARGET).xcframework; \
fi
@xcodebuild \
-create-xcframework \
Expand All @@ -71,25 +94,25 @@ xcframework_frameworks: build

@if [ -d "include" ]; then \
echo "cleaning include"; \
rm -rf include; \
fi
rm -rf include; \
fi
@mkdir include
@mkdir include/$(TARGET)
@cp $(TARGET).h include/$(TARGET)
@cp module.modulemap include/$(TARGET)

@if [ -d "target/ios" ]; then \
echo "cleaning target/ios"; \
rm -rf target/ios; \
fi
rm -rf target/ios; \
fi
@mkdir target/ios
@mkdir target/ios/$(TARGET).framework
@mkdir target/ios/$(TARGET).framework/Headers

@if [ -d "target/sim" ]; then \
echo "cleaning target/sim"; \
rm -rf target/sim; \
fi
rm -rf target/sim; \
fi
@mkdir target/sim
@mkdir target/sim/$(TARGET).framework
@mkdir target/sim/$(TARGET).framework/Headers
Expand All @@ -108,8 +131,8 @@ xcframework_frameworks: build

@if [ -d "$(TARGET).xcframework" ]; then \
echo "cleaning $(TARGET).xcframework"; \
rm -rf $(TARGET).xcframework; \
fi
rm -rf $(TARGET).xcframework; \
fi
@xcodebuild -create-xcframework \
-library target/sim/$(TARGET).framework \
-headers include/ \
Expand All @@ -121,6 +144,6 @@ zip: xcframework
@echo "zip"
@if [ -f "$(TARGET).xcframework.zip" ]; then \
echo "cleaning $(TARGET).xcframework.zip"; \
rm $(TARGET).xcframework.zip; \
fi
rm $(TARGET).xcframework.zip; \
fi
zip -r $(TARGET).xcframework.zip $(TARGET).xcframework

0 comments on commit 37eafbf

Please sign in to comment.