{"id":18635784,"url":"https://github.com/xpack-dev-tools/build-helper","last_synced_at":"2025-04-11T08:30:48.163Z","repository":{"id":25431611,"uuid":"95119307","full_name":"xpack-dev-tools/build-helper","owner":"xpack-dev-tools","description":"Common scripts used in other XBB build scripts","archived":false,"fork":false,"pushed_at":"2022-10-03T20:26:27.000Z","size":1291,"stargazers_count":3,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T11:39:02.655Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xpack-dev-tools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":"ilegeul","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2017-06-22T13:37:14.000Z","updated_at":"2022-05-29T13:43:25.000Z","dependencies_parsed_at":"2023-01-14T02:43:43.990Z","dependency_job_id":null,"html_url":"https://github.com/xpack-dev-tools/build-helper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xpack-dev-tools%2Fbuild-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xpack-dev-tools%2Fbuild-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xpack-dev-tools%2Fbuild-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xpack-dev-tools%2Fbuild-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xpack-dev-tools","download_url":"https://codeload.github.com/xpack-dev-tools/build-helper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248361471,"owners_count":21090907,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T05:26:34.194Z","updated_at":"2025-04-11T08:30:47.582Z","avatar_url":"https://github.com/xpack-dev-tools.png","language":"Shell","funding_links":["https://ko-fi.com/ilegeul"],"categories":[],"sub_categories":[],"readme":"# build-helper\n\nCommon script used in other build scripts.\n\n- `host-functions-source.sh`: to be included with `source` in the host build script\n- `container-functions-source.sh`: to be included with `source` in the container build script\n\nDeprecated:\n\n- `builder-helper.sh`: used in the first generation of build scripts.\n\n## Patches\n\nThe code used to download and extract archives can also be used\nto post-patch the downloaded files. For this a patch file must be\nplaced in the `patches` folder, and the name must be passed as the\nthird param to `extract()`.\n\n## Memo\n\nThe code to apply the patch (`common-functions-source.sh:extract()`) does\nthe following:\n\n```sh\ncd sources/binutils\n\npatch -p0 \u003c \"binutils-2.31.patch\"\npatch -p1 \u003c \"binutils-2.31.patch.diff\"\n```\n\nNote: the `.patch.diff` files have an extra level, like `a/` `b/` which\nmust be skipped.\n\nThe patch is applied from the library source folder, so it must be created\nwith the library relative path.\n\nFor example, to create a binutils patch, use:\n\n```sh\ncd sources/binutils\n\ncp bfd/ihex.c bfd/ihex-patched.c\nvi bfd/ihex-patched.c\ndiff -u bfd/ihex.c bfd/ihex-patched.c \u003e patches/binutils-2.31.patch\n```\n\nAlternatively, multiple changes can be generated by Git:\n\n```sh\ngit init\ngit add -A\ngit commit -m all\n```\n\nPerform changes as usual.\n\nTo create a patch with the uncommitted changes that will be consumed\nwith `patch`:\n\n```sh\ngit diff --no-prefix -u \u003e file.patch\n```\n\nFor completeness, to create a patch with the uncommitted changes that\nwill be consumeed with `git apply file.git-patch`.\n\n```sh\ngit diff \u003e file.git-patch\n```\n\nIt is also possible to create patches with git and consume them with patch\n\n```sh\ngit diff --no-prefix -u \u003e file.patch\n```\n\n## GitHub archives\n\nNormally the URL uses the  look like:\n\n```sh\n  local libxxx_archive=\"${libxxx_src_folder_name}.tar.gz\"\n  local libxxx_url=\"https://ftp.gnu.org/gnu/libxxx/${libxxx_archive}\"\n\n    download_and_extract \"${libxxx_url}\" \"${libxxx_archive}\" \\\n      \"${libxxx_src_folder_name}\"\n\n```\n\nFor projects which download GitHub releases or even tags:\n\n```sh\nfunction build_libxxx()\n{\n  # https://github.com/Homebrew/homebrew-core/blob/master/Formula/libxxx.rb\n\n  local libxxx_version=\"$1\"\n\n  local libxxx_src_folder_name=\"libxxx-${libxxx_version}\"\n\n  local libxxx_archive=\"${libxxx_src_folder_name}.tar.gz\"\n  # GitHub release archive.\n  local libxxx_github_archive=\"v${libxxx_version}.tar.gz\"\n  local libxxx_github_url=\"https://github.com/libxxx/libxxx/archive/${libxxx_github_archive}\"\n\n  local libxxx_folder_name=\"${libxxx_src_folder_name}\"\n\n  mkdir -pv \"${LOGS_FOLDER_PATH}/${libxxx_folder_name}\"\n\n  local libxxx_stamp_file_path=\"${INSTALL_FOLDER_PATH}/stamp-${libxxx_folder_name}-installed\"\n  if [ ! -f \"${libxxx_stamp_file_path}\" ]\n  then\n\n    cd \"${SOURCES_FOLDER_PATH}\"\n\n    download_and_extract \"${libxxx_github_url}\" \"${libxxx_archive}\" \\\n      \"${libxxx_src_folder_name}\"\n\n    (\n      mkdir -pv \"${LIBS_BUILD_FOLDER_PATH}/${libxxx_folder_name}\"\n      cd \"${LIBS_BUILD_FOLDER_PATH}/${libxxx_folder_name}\"\n\n      xbb_activate_installed_dev\n\n      CPPFLAGS=\"${XBB_CPPFLAGS}\"\n      CFLAGS=\"${XBB_CFLAGS_NO_W}\"\n      CXXFLAGS=\"${XBB_CXXFLAGS_NO_W}\"\n      LDFLAGS=\"${XBB_LDFLAGS_LIB}\"\n\n      if [ \"${TARGET_PLATFORM}\" == \"linux\" ]\n      then\n        LDFLAGS+=\" -Wl,-rpath,${LD_LIBRARY_PATH}\"\n      fi\n\n      export CPPFLAGS\n      export CFLAGS\n      export CXXFLAGS\n      export LDFLAGS\n\n      if [ ! -f \"config.status\" ]\n      then\n        (\n          if [ \"${IS_DEVELOP}\" == \"y\" ]\n          then\n            env | sort\n          fi\n\n          echo\n          echo \"Running libxxx configure...\"\n\n          if [ \"${IS_DEVELOP}\" == \"y\" ]\n          then\n            run_verbose bash \"${SOURCES_FOLDER_PATH}/${libxxx_src_folder_name}/configure\" --help\n          fi\n\n          config_options=()\n\n          config_options+=(\"--prefix=${LIBS_INSTALL_FOLDER_PATH}\")\n\n          config_options+=(\"--build=${BUILD}\")\n          config_options+=(\"--host=${HOST}\")\n          config_options+=(\"--target=${TARGET}\")\n\n          run_verbose bash ${DEBUG} \"${SOURCES_FOLDER_PATH}/${libxxx_src_folder_name}/configure\" \\\n            \"${config_options[@]}\"\n\n          cp \"config.log\" \"${LOGS_FOLDER_PATH}/${libxxx_folder_name}/config-log-$(ndate).txt\"\n        ) 2\u003e\u00261 | tee \"${LOGS_FOLDER_PATH}/${libxxx_folder_name}/configure-output-$(ndate).txt\"\n      fi\n\n      (\n        echo\n        echo \"Running libxxx make...\"\n\n        # Build.\n        run_verbose make -j ${JOBS}\n\n        if [ \"${WITH_TESTS}\" == \"y\" ]\n        then\n          run_verbose make -j1 check\n        fi\n\n        if [ \"${WITH_STRIP}\" == \"y\" ]\n        then\n          run_verbose make install-strip\n        else\n          run_verbose make install\n        fi\n\n      ) 2\u003e\u00261 | tee \"${LOGS_FOLDER_PATH}/${libxxx_folder_name}/make-output-$(ndate).txt\"\n\n      copy_license \\\n        \"${SOURCES_FOLDER_PATH}/${libxxx_src_folder_name}\" \\\n        \"${libxxx_folder_name}\"\n\n    )\n\n    touch \"${libxxx_stamp_file_path}\"\n\n  else\n    echo \"Library libxxx already installed.\"\n  fi\n\n```\n\n## Links\n\n- \u003chttps://git-scm.com/docs/git-diff\u003e\n- \u003chttps://git-scm.com/docs/git-apply\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxpack-dev-tools%2Fbuild-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxpack-dev-tools%2Fbuild-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxpack-dev-tools%2Fbuild-helper/lists"}