From d566ab442503ca0a886f2425e687942d55f95f94 Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Thu, 27 Feb 2025 10:37:42 -0500 Subject: [PATCH 1/2] Update build_tips.md Adds brief descriptions of how to do "bare" (no build system) C and C++ builds - just to show where things should go. --- docs/src/build_tips.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/src/build_tips.md b/docs/src/build_tips.md index 8726886b..51321fce 100644 --- a/docs/src/build_tips.md +++ b/docs/src/build_tips.md @@ -127,6 +127,34 @@ Example of packages using Rust: The Rust toolchain currently used does not work with the `i686-w64-mingw32` (32-bit Windows) platform. + ## C builds + + If your library has no build system like Make, CMake, Meson, or Autoconf, you may need to use the C compiler directly. The C compiler is stored in the `CC` environment variable, and you can direct output to `libdir` (shared libraries) and `bindir` (executables). + + ```sh +# this assumes you are operating out of a Git source named `hello` +# adjust your `cd` appropriately +cd $WORKSPACE/srcdir/hello +mkdir -p ${libdir} # make sure the libdir is instantiated +${CC} -shared -o ${libdir}/libhello.${dlext} -fPIC hello.c # compile the library, save to `libdir` +``` + +This is simply compiling a single shared library, `libhello`, from `hello.c`. + +## C++ builds + +Similarly to C builds, sometimes your C++ libraries will not have a build system associated with them. The C++ compiler is stored in the `CXX` environment variable. + +```sh +# this assumes you are operating out of a Git source named `hello` +# adjust your `cd` appropriately +cd $WORKSPACE/srcdir/hello +mkdir -p ${libdir} +$CXX -shared -std=c++11 -O3 -fPIC -o ${libdir}/libhello.${dlext} src/hello.cpp # you may want to edit the `std` flag, for exampLE +``` + +This is simply compiling a single shared library, `libhello`, from `hello.cpp`. + ## Editing files in the wizard In the wizard, the `vim` editor is available for editing files. But, it doesn't leave any record in the build script. One generally needs to provide patch files or use something like `sed`. If a file needs patching, we suggest using `git` to add the entire worktree to a new repo, make the changes you need, then use `git diff -p` to output a patch that can be included alongside your build recipe. From 2fd4dbf4986c85882dc31762563a9ecdc6c78276 Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Thu, 24 Apr 2025 15:20:03 -0400 Subject: [PATCH 2/2] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mosè Giordano <765740+giordano@users.noreply.github.com> --- docs/src/build_tips.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/src/build_tips.md b/docs/src/build_tips.md index 51321fce..b0582e06 100644 --- a/docs/src/build_tips.md +++ b/docs/src/build_tips.md @@ -130,6 +130,7 @@ Example of packages using Rust: ## C builds If your library has no build system like Make, CMake, Meson, or Autoconf, you may need to use the C compiler directly. The C compiler is stored in the `CC` environment variable, and you can direct output to `libdir` (shared libraries) and `bindir` (executables). +As a high-level example: ```sh # this assumes you are operating out of a Git source named `hello` @@ -144,13 +145,14 @@ This is simply compiling a single shared library, `libhello`, from `hello.c`. ## C++ builds Similarly to C builds, sometimes your C++ libraries will not have a build system associated with them. The C++ compiler is stored in the `CXX` environment variable. +As a high-level example: ```sh # this assumes you are operating out of a Git source named `hello` # adjust your `cd` appropriately cd $WORKSPACE/srcdir/hello mkdir -p ${libdir} -$CXX -shared -std=c++11 -O3 -fPIC -o ${libdir}/libhello.${dlext} src/hello.cpp # you may want to edit the `std` flag, for exampLE +$CXX -shared -std=c++11 -O3 -fPIC -o ${libdir}/libhello.${dlext} src/hello.cpp # you may want to edit the `std` flag, for example ``` This is simply compiling a single shared library, `libhello`, from `hello.cpp`.