This repository was archived by the owner on Sep 20, 2026. It is now read-only.
Repository navigation
formula: SpartanJ/efsw #466
Open
MeteorsLiu
wants to merge
2
commits into
xgo-dev:main
Choose a base branch
from
MeteorsLiu:issue/289-efsw-luna
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "strings" | ||
| ) | ||
|
|
||
| const consumerSource = `#include <iostream> | ||
| #include <cstdlib> | ||
| #include "efsw/efsw.hpp" | ||
|
|
||
| int main() { | ||
| efsw::FileWatcher* fileWatcher = new efsw::FileWatcher(); | ||
|
|
||
| std::cout << "Follows symlinks?: " << fileWatcher->followSymlinks() << std::endl; | ||
|
|
||
| delete fileWatcher; | ||
|
|
||
| return EXIT_SUCCESS; | ||
| } | ||
| ` | ||
|
|
||
| id "SpartanJ/efsw" | ||
|
|
||
| fromVer "1.4.0" | ||
|
|
||
| defaults { | ||
| "shared": "OFF", | ||
| "fPIC": "ON", | ||
| } | ||
|
|
||
| filter => { | ||
| for name, values in target.options { | ||
| if name != "shared" && name != "fPIC" { | ||
| return false | ||
| } | ||
| for value in values { | ||
| if value != "ON" && value != "OFF" { | ||
| return false | ||
| } | ||
| } | ||
| } | ||
| return true | ||
| } | ||
|
|
||
| onBuild ctx => { | ||
| installDir := ctx.outputDir | ||
| shared := target.options["shared"][0] == "ON" | ||
| fPIC := target.options["fPIC"][0] == "ON" | ||
|
|
||
| cmakeLists := filepath.join(ctx.SourceDir, "CMakeLists.txt") | ||
| source := string(os.readFile(cmakeLists)!) | ||
| source = strings.replace( | ||
| source, | ||
| "set(CMAKE_POSITION_INDEPENDENT_CODE ON)", | ||
| "", | ||
| 1, | ||
| ) | ||
| source = strings.replace( | ||
| source, | ||
| "target_compile_options(efsw PRIVATE -Wall -Wno-long-long -fPIC)", | ||
| "target_compile_options(efsw PRIVATE -Wall -Wno-long-long)", | ||
| 1, | ||
| ) | ||
| os.writeFile(cmakeLists, []byte(source), 0o644)! | ||
|
|
||
| c := cmake.new(ctx.SourceDir, filepath.join(ctx.SourceDir, "_build"), installDir) | ||
| c.define "CMAKE_INSTALL_LIBDIR", "lib" | ||
| c.defineBool "BUILD_SHARED_LIBS", shared | ||
| c.defineBool "BUILD_STATIC_LIBS", false | ||
| c.defineBool "BUILD_TEST_APP", false | ||
| c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", fPIC | ||
| c.configure | ||
| c.build | ||
| c.install | ||
|
|
||
| licenseDir := filepath.join(installDir, "licenses") | ||
| os.mkdirAll(licenseDir, 0o755)! | ||
| os.writeFile(filepath.join(licenseDir, "LICENSE"), os.readFile(filepath.join(ctx.SourceDir, "LICENSE"))!, 0o644)! | ||
|
|
||
| libs := ["-L$${libdir}", "-lefsw"] | ||
| osName := target.require["os"][0] | ||
| if osName == "linux" || osName == "freebsd" { | ||
| libs <- "-lm" | ||
| libs <- "-lpthread" | ||
| } else if osName == "darwin" { | ||
| libs <- "-framework" | ||
| libs <- "CoreFoundation" | ||
| libs <- "-framework" | ||
| libs <- "CoreServices" | ||
| } | ||
|
|
||
| pcDir := filepath.join(installDir, "lib", "pkgconfig") | ||
| os.mkdirAll(pcDir, 0o755)! | ||
| pc := pkgconfig.new( | ||
| name = "efsw", | ||
| description = "efsw is a C++ cross-platform file system watcher and notifier.", | ||
| version = "1.4.0", | ||
| libs = libs, | ||
| cflags = ["-I$${includedir}"], | ||
| )! | ||
| out := os.create(filepath.join(pcDir, "efsw.pc"))! | ||
| pc.writeTo(out)! | ||
| out.close()! | ||
|
|
||
| pkgconfig.use installDir | ||
| ctx.setMetadata pkgconfig.lookup("efsw")! | ||
| } | ||
|
|
||
| onTest ctx => { | ||
| installDir := ctx.outputDir | ||
| testDir := filepath.join(ctx.SourceDir, "_llar_consumer") | ||
| os.mkdirAll(testDir, 0o755)! | ||
|
|
||
| consumer := filepath.join(testDir, "consumer.cpp") | ||
| os.writeFile(consumer, []byte(consumerSource), 0o644)! | ||
|
|
||
| pkgconfig.use installDir | ||
| flagsFile := filepath.join(testDir, "efsw.flags") | ||
| os.writeFile(flagsFile, []byte(pkgconfig.lookup("efsw")!), 0o644)! | ||
|
|
||
| binary := filepath.join(testDir, "consumer") | ||
| exec! "c++", "-std=c++11", consumer, "-o", binary, "@"+flagsFile | ||
|
|
||
| if target.options["shared"][0] == "ON" { | ||
| os.setenv("LD_LIBRARY_PATH", filepath.join(installDir, "lib"))! | ||
| os.setenv("DYLD_LIBRARY_PATH", filepath.join(installDir, "lib"))! | ||
|
Comment on lines
+124
to
+126
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] Add the installed DLL directory to Windows test PATH When |
||
| } | ||
| exec! binary | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "path": "SpartanJ/efsw", | ||
| "deps": {} | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Make fPIC=OFF actually disable PIC
Removing only
set(CMAKE_POSITION_INDEPENDENT_CODE ON)does not honor the exposedfPIC=OFFoption on non-MSVC builds: upstreamCMakeLists.txtalso unconditionally adds-fPICto theefswtarget intarget_compile_options. Because this formula builds that target for both shared modes,CMAKE_POSITION_INDEPENDENT_CODE=OFFstill produces position-independent objects, so consumers cannot select the advertised non-PIC variant. Remove or conditionally rewrite that upstream compile option (or otherwise make it depend onfPIC) before configuring.